How to use caseInsensitiveMapsSuccessfulTestCases method of org.assertj.core.internal.maps.Maps_assertContainsOnlyKeys_Test class

Best Assertj code snippet using org.assertj.core.internal.maps.Maps_assertContainsOnlyKeys_Test.caseInsensitiveMapsSuccessfulTestCases

Source:Maps_assertContainsOnlyKeys_Test.java Github

copy

Full Screen

...79 @ParameterizedTest80 @MethodSource({81 "unmodifiableMapsSuccessfulTestCases",82 "modifiableMapsSuccessfulTestCases",83 "caseInsensitiveMapsSuccessfulTestCases",84 })85 void should_pass(Map<String, String> actual, String[] expected) {86 // GIVEN87 int initialSize = actual.size();88 // WHEN/THEN89 assertThatNoException().as(actual.getClass().getName())90 .isThrownBy(() -> maps.assertContainsOnlyKeys(info, actual, expected));91 then(actual).hasSize(initialSize);92 }93 private static Stream<Arguments> unmodifiableMapsSuccessfulTestCases() {94 return Stream.of(arguments(emptyMap(), emptyKeys()),95 arguments(singletonMap("name", "Yoda"), array("name")),96 arguments(new SingletonMap<>("name", "Yoda"), array("name")),97 arguments(unmodifiableMap(mapOf(entry("name", "Yoda"), entry("job", "Jedi"))), array("name", "job")),98 arguments(unmodifiableMap(mapOf(entry("name", "Yoda"), entry("job", "Jedi"))), array("job", "name")),99 arguments(ImmutableMap.of("name", "Yoda", "job", "Jedi"), array("name", "job")),100 arguments(ImmutableMap.of("name", "Yoda", "job", "Jedi"), array("job", "name")),101 arguments(Jdk11.Map.of("name", "Yoda", "job", "Jedi"), array("name", "job")),102 arguments(Jdk11.Map.of("name", "Yoda", "job", "Jedi"), array("job", "name")));103 }104 private static Stream<Arguments> modifiableMapsSuccessfulTestCases() {105 return Stream.of(MODIFIABLE_MAPS)106 .flatMap(supplier -> Stream.of(arguments(mapOf(supplier, entry("name", "Yoda"), entry("job", "Jedi")),107 array("name", "job")),108 arguments(mapOf(supplier, entry("name", "Yoda"), entry("job", "Jedi")),109 array("job", "name"))));110 }111 private static Stream<Arguments> caseInsensitiveMapsSuccessfulTestCases() {112 return Stream.of(ArrayUtils.add(CASE_INSENSITIVE_MAPS, CaseInsensitiveMap::new))113 .flatMap(supplier -> Stream.of(arguments(mapOf(supplier, entry("NAME", "Yoda"), entry("Job", "Jedi")),114 array("name", "job")),115 arguments(mapOf(supplier, entry("NAME", "Yoda"), entry("Job", "Jedi")),116 array("job", "name")),117 arguments(mapOf(supplier, entry("NAME", "Yoda"), entry("Job", "Jedi")),118 array("Name", "Job")),119 arguments(mapOf(supplier, entry("NAME", "Yoda"), entry("Job", "Jedi")),120 array("Job", "Name"))));121 }122 @Test123 void should_pass_with_MultiValueMapAdapter() {124 // GIVEN125 MultiValueMapAdapter<String, String> actual = new MultiValueMapAdapter<>(mapOf(entry("name", list("Yoda"))));...

Full Screen

Full Screen

caseInsensitiveMapsSuccessfulTestCases

Using AI Code Generation

copy

Full Screen

1package org.assertj.core.internal.maps;2import static org.assertj.core.api.Assertions.assertThat;3import static org.assertj.core.error.ShouldContainOnlyKeys.shouldContainOnlyKeys;4import static org.assertj.core.test.Maps.mapOf;5import static org.assertj.core.test.TestData.someInfo;6import static org.mockito.Mockito.verify;7import java.util.Map;8import org.assertj.core.api.AssertionInfo;9import org.assertj.core.internal.MapsBaseTest;10import org.junit.jupiter.api.Test;11class Maps_assertContainsOnlyKeys_Test extends MapsBaseTest {12 void should_pass_if_actual_contains_only_expected_keys() {13 maps.assertContainsOnlyKeys(someInfo(), actual, "name", "id");14 }15 void should_pass_if_actual_contains_only_expected_keys_with_different_casing() {16 maps.assertContainsOnlyKeys(someInfo(), actual, "NaMe", "iD");17 }18 void should_pass_if_actual_contains_only_expected_keys_in_different_order() {19 maps.assertContainsOnlyKeys(someInfo(), actual, "id", "name");20 }21 void should_pass_if_actual_contains_only_expected_keys_in_different_order_with_different_casing() {22 maps.assertContainsOnlyKeys(someInfo(), actual, "ID", "NaMe");23 }24 void should_fail_if_actual_is_null() {25 assertThatNullPointerException().isThrownBy(() -> maps.assertContainsOnlyKeys(someInfo(), null, "name"))26 .withMessage(actualIsNull());27 }28 void should_fail_if_expected_keys_array_is_null() {29 assertThatNullPointerException().isThrownBy(() -> maps.assertContainsOnlyKeys(someInfo(), actual, (String[]) null))30 .withMessage(keysToLookForIsNull());31 }32 void should_fail_if_expected_keys_array_is_empty() {33 assertThatIllegalArgumentException().isThrownBy(() -> maps.assertContainsOnlyKeys(someInfo(), actual))34 .withMessage(keysToLookForIsEmpty());35 }36 void should_fail_if_actual_does_not_contain_expected_keys() {37 AssertionInfo info = someInfo();38 Throwable error = catchThrowable(() -> maps.assertContainsOnlyKeys(info, actual, "name", "color"));39 assertThat(error).isInstanceOf(AssertionError.class);40 verify(failures).failure(info, shouldContainOnlyKeys(actual, mapOf(entry("color", "blue")), set

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful