parent
c61a1dace1
commit
e9431ce416
|
@ -11,7 +11,6 @@ import static org.hamcrest.Matchers.*;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class AssertNestedMapUnitTest {
|
public class AssertNestedMapUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenNestedMap_whenUseJupiterAssertTrueWithoutCasting_thenTest() {
|
void givenNestedMap_whenUseJupiterAssertTrueWithoutCasting_thenTest() {
|
||||||
Map<String, Object> innerMap = Map.of("city", "Chicago");
|
Map<String, Object> innerMap = Map.of("city", "Chicago");
|
||||||
|
@ -26,8 +25,8 @@ public class AssertNestedMapUnitTest {
|
||||||
Map<String, Map<String, Object>> outerMap = Map.of("address", innerMap);
|
Map<String, Map<String, Object>> outerMap = Map.of("address", innerMap);
|
||||||
|
|
||||||
assertAll(
|
assertAll(
|
||||||
() -> assertTrue(outerMap.containsKey("address")),
|
() -> assertTrue(outerMap.containsKey("address")),
|
||||||
() -> assertEquals(outerMap.get("address").get("city"), "Chicago")
|
() -> assertEquals(outerMap.get("address").get("city"), "Chicago")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +44,8 @@ public class AssertNestedMapUnitTest {
|
||||||
Map<String, Object> innerMap = Map.of("city", "Chicago");
|
Map<String, Object> innerMap = Map.of("city", "Chicago");
|
||||||
Map<String, Map<String, Object>> outerMap = Map.of("address", innerMap);
|
Map<String, Map<String, Object>> outerMap = Map.of("address", innerMap);
|
||||||
assertAll(
|
assertAll(
|
||||||
() -> assertThat(outerMap, hasKey("address")),
|
() -> assertThat(outerMap, hasKey("address")),
|
||||||
() -> assertThat(outerMap.get("address"), hasEntry("city", "Chicago"))
|
() -> assertThat(outerMap.get("address"), hasEntry("city", "Chicago"))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +81,6 @@ public class AssertNestedMapUnitTest {
|
||||||
assertThat(outerMap, hasNestedMapEntry("address", innerMap));
|
assertThat(outerMap, hasNestedMapEntry("address", innerMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenNestedMap_whenUseHamcrestAssertThatWithCasting_thenTest() {
|
void givenNestedMap_whenUseHamcrestAssertThatWithCasting_thenTest() {
|
||||||
Map<String, Object> innerMap = Map.of("city", "Chicago");
|
Map<String, Object> innerMap = Map.of("city", "Chicago");
|
||||||
|
|
Loading…
Reference in New Issue