Skip to content

Commit

Permalink
refactor: use JUnit 5 expectations
Browse files Browse the repository at this point in the history
* JUnit 5 has a better way to assert on an expected exception.
* Cleaned up an unncessary type specification.
* Fixed a typo.
* Cleaned up an import.
  • Loading branch information
swalchemist committed Oct 14, 2023
1 parent 8bac1c8 commit f925fca
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

class JsonUtilsTest {
private static final String jsonTestObjectString = "{\"pattern\":\"/pattern\",\"group\":\"group\",\"limit\":1000,\"category\":\"category\"}";
Expand Down Expand Up @@ -69,13 +69,10 @@ void testSerializeExcludingProperties() {

@Test
void testSerializeExcludingPropertiesInnerCallFails() {
Map<String, String> groupProperties = JsonUtils.readValue(jsonTestObjectString, new TypeReference<Map<String, String>>() {});
try {
JsonUtils.serializeExcludingProperties(groupProperties, "limit.unkonwn");
fail("not expected");
} catch (Exception e) {
assertTrue(e instanceof JsonUtils.JsonUtilException);
}
Map<String, String> groupProperties = JsonUtils.readValue(jsonTestObjectString, new TypeReference<>() {});
assertThrows(JsonUtils.JsonUtilException.class, () -> {
JsonUtils.serializeExcludingProperties(groupProperties, "limit.unknown");
});
}

@Test
Expand Down

0 comments on commit f925fca

Please sign in to comment.