-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from techatpark/perf-prep
Welcome Test cases
- Loading branch information
Showing
8 changed files
with
66 additions
and
22 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
57 changes: 57 additions & 0 deletions
57
src/test/java/com/techatpark/sjson/core/BooleanParserTest.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,57 @@ | ||
package com.techatpark.sjson.core; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
import java.io.IOException; | ||
import java.io.StringReader; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
/** | ||
* Tests for Boolean Parsers. | ||
*/ | ||
class BooleanParserTest { | ||
|
||
final ObjectMapper objectMapper = new ObjectMapper(); | ||
|
||
/** | ||
* Tests Valid Boolean Values. | ||
* <p> | ||
* Steps: | ||
* 1) Pass valid boolean value ( originalValue ). | ||
* 2) Get JSON String from Jackson. | ||
* 3) Read JSON String as Java Object using SJson. | ||
* <p> | ||
* Expected Result: | ||
* This value should be equal to originalValue. | ||
* @param originalValue - Valid Boolean Value | ||
* @throws IOException | ||
*/ | ||
@ParameterizedTest | ||
@ValueSource(booleans = {true, false}) | ||
void testValid(final Boolean originalValue) throws IOException { | ||
String jsonString = objectMapper.writeValueAsString(originalValue); | ||
Assertions.assertEquals(originalValue , | ||
new Json().read(new StringReader(jsonString))); | ||
} | ||
/** | ||
* Tests invalid Boolean Values. | ||
* <p> | ||
* Steps: | ||
* 1) Pass invalid boolean value ( invalidJson ). | ||
* 3) Read JSON String as Java Object using SJson. | ||
* <p> | ||
* Expected Result: | ||
* IllegalArgumentException should be thrown . | ||
* @param invalidJson - Valid Boolean Value | ||
*/ | ||
@ParameterizedTest | ||
@ValueSource(strings = {"tru", "fals"}) | ||
void testInvalid(final String invalidJson) { | ||
assertThrows(IllegalArgumentException.class, | ||
() -> new Json().read(new StringReader(invalidJson))); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.