-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
173 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
backend/src/test/java/ca/bc/gov/nrs/api/v1/endpoints/ExceptionsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package ca.bc.gov.nrs.api.v1.endpoints; | ||
|
||
import org.junit.Assert; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import ca.bc.gov.nrs.vdyp.backend.v1.api.impl.exceptions.Exceptions; | ||
import ca.bc.gov.nrs.vdyp.backend.v1.api.impl.exceptions.NotFoundException; | ||
import ca.bc.gov.nrs.vdyp.backend.v1.api.impl.exceptions.ProjectionExecutionException; | ||
import ca.bc.gov.nrs.vdyp.backend.v1.api.impl.exceptions.ProjectionRequestValidationException; | ||
|
||
public class ExceptionsTest { | ||
|
||
@Test | ||
void ProjectionExecutionExceptionTest() { | ||
|
||
var e1 = new ProjectionExecutionException(new IllegalStateException("illegal")); | ||
Assert.assertEquals("illegal", e1.getCause().getMessage()); | ||
|
||
var e2 = new ProjectionExecutionException("validation error"); | ||
Assert.assertEquals("validation error", e2.getMessage()); | ||
|
||
var e3 = new ProjectionExecutionException(new IllegalStateException("illegal"), "validation error"); | ||
Assert.assertEquals("illegal", e3.getCause().getMessage()); | ||
Assert.assertEquals("validation error", e3.getMessage()); | ||
} | ||
|
||
@Test | ||
void ProjectionRequestValidationExceptionTest() { | ||
|
||
var e1 = new ProjectionRequestValidationException(new IllegalStateException("illegal")); | ||
Assert.assertEquals("illegal", e1.getCause().getMessage()); | ||
|
||
var e2 = new ProjectionRequestValidationException("validation error"); | ||
Assert.assertEquals("validation error", e2.getMessage()); | ||
|
||
var e3 = new ProjectionRequestValidationException(new IllegalStateException("illegal"), "validation error"); | ||
Assert.assertEquals("illegal", e3.getCause().getMessage()); | ||
Assert.assertEquals("validation error", e3.getMessage()); | ||
} | ||
|
||
@Test | ||
void NotFoundExceptionTest() { | ||
|
||
var e1 = new NotFoundException(); | ||
Assert.assertEquals(null, e1.getCause()); | ||
} | ||
|
||
@Test | ||
void ExceptionsClassTest() { | ||
|
||
var e1 = new ProjectionRequestValidationException("validation error"); | ||
String message1 = Exceptions.getMessage(e1, "while performation operation f, "); | ||
Assert.assertTrue(message1.startsWith("while performation operation f, saw")); | ||
Assert.assertTrue(message1.endsWith("validation error")); | ||
|
||
var e2 = new ProjectionRequestValidationException(new IllegalStateException("illegal"), "validation error"); | ||
String message2 = Exceptions.getMessage(e2, "while performation operation f, "); | ||
Assert.assertTrue(message2.startsWith("while performation operation f, saw")); | ||
Assert.assertTrue(message2.endsWith("illegal")); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
backend/src/test/java/ca/bc/gov/nrs/api/v1/endpoints/FileHelperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package ca.bc.gov.nrs.api.v1.endpoints; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.file.Files; | ||
import java.nio.file.NoSuchFileException; | ||
import java.nio.file.Path; | ||
|
||
import org.junit.Assert; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import ca.bc.gov.nrs.vdyp.backend.v1.utils.FileHelper; | ||
|
||
public class FileHelperTest { | ||
|
||
@Test | ||
void testGetStubResourceFile() throws IOException { | ||
InputStream is = FileHelper.getStubResourceFile("Output_Log.txt"); | ||
Assert.assertNotNull(is); | ||
} | ||
|
||
@Test | ||
void testGetAndDeleteFile() throws IOException { | ||
Path tempFilePath = Files.createTempFile("pre_", "_post"); | ||
|
||
InputStream is1 = FileHelper.getForReading(tempFilePath); | ||
Assert.assertNotNull(is1); | ||
|
||
FileHelper.delete(tempFilePath); | ||
|
||
Assert.assertThrows(NoSuchFileException.class, () -> FileHelper.getForReading(tempFilePath)); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
backend/src/test/java/ca/bc/gov/nrs/api/v1/endpoints/ParameterNamesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package ca.bc.gov.nrs.api.v1.endpoints; | ||
|
||
import org.junit.Assert; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import ca.bc.gov.nrs.vdyp.backend.v1.gen.api.ParameterNames; | ||
|
||
/** test ParameterNamesTest for Sonar coverage purposes only */ | ||
public class ParameterNamesTest { | ||
|
||
@Test | ||
void test() { | ||
Assert.assertEquals("historyInputData", ParameterNames.HISTORY_INPUT_DATA); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters