/** * Use the given {@link Function} to extract a value from the {@link Map}'s entries. * The extracted values are stored in a new list becoming the object under test. * <p> * Let's take a look at an example to make things clearer : * <pre><code class='java'> // Build a Map that associates family roles and name of the Simpson familly * Map<String, CartoonCharacter> characters = new HashMap<>(); * characters.put("dad", new CartoonCharacter("Omer")); * characters.put("mom", new CartoonCharacter("Marge")); * characters.put("girl", new CartoonCharacter("Lisa")); * characters.put("boy", new CartoonCharacter("Bart")); * * assertThat(characters).extractingFromEntries(e -> e.getValue().getName()) * .containsOnly("Omer", "Marge", "Lisa", "Bart");</code></pre> * * @param extractor the extractor function to extract a value from an entry of the Map under test. * @return a new assertion object whose object under test is the list of values extracted * @since 3.12.0 */ @CheckReturnValue public AbstractListAssert<?, List<?>, Object, ObjectAssert<Object>> extractingFromEntries(Function<? super Map.Entry<K, V>, Object> extractor) { isNotNull(); List<Object> extractedObjects = actual.entrySet().stream() .map(extractor::apply) .collect(toList()); return newListAssertInstance(extractedObjects).as(info.description()); }
isNotNull(); List<Object> extractedValues = Stream.of(keys).map(actual::get).collect(Collectors.toList()); String extractedPropertiesOrFieldsDescription = extractedDescriptionOf(keys);
isNotNull(); List<Object> extractedValues = Stream.of(keys).map(actual::get).collect(Collectors.toList()); String extractedPropertiesOrFieldsDescription = extractedDescriptionOf(keys);
private void assertValidConfig(Config config) { assertThat(config.getFeatureMap()).isNotNull(); assertThat(config.getFeatureMap().get("video")).isNotNull(); assertThat(config.getFeatureMap().get("audio")).isNotNull(); assertThat(config.getFeatureMap().get("speech")).isNotNull(); assertThat(config.getFeatureMap().get("random")).isNull(); }
@Test public void testGetDataProviderMethodShouldInitializeMapUsedForCaching() { // Given: doReturn(null).when(testMethod).getAnnotation(UseDataProvider.class); underTest.dataProviderMethods = null; // When: underTest.getDataProviderMethods(testMethod); // Then: assertThat(underTest.dataProviderMethods).isNotNull(); }
assertThat( props ).isNotNull().doesNotContainKey( "deleteKey" );
@Test public void projectSettings() throws Exception { @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") ValueMap valueMap = new ValueMap(cartographer.fromJson(PROJECT_SETTINGS_JSON_SAMPLE)); assertThat(valueMap.getValueMap("Amplitude")) .isNotNull() .hasSize(4) .contains(MapEntry.entry("apiKey", "ad3c426eb736d7442a65da8174bc1b1b")) .contains(MapEntry.entry("trackNamedPages", true)) .contains(MapEntry.entry("trackCategorizedPages", true)) .contains(MapEntry.entry("trackAllPages", false)); assertThat(valueMap.getValueMap("Flurry")) .isNotNull() .hasSize(4) .contains(MapEntry.entry("apiKey", "8DY3D6S7CCWH54RBJ9ZM")) .contains(MapEntry.entry("captureUncaughtExceptions", false)) .contains(MapEntry.entry("useHttps", true)) .contains(MapEntry.entry("sessionContinueSeconds", 10.0)); }