org.assertj.core.data.MapEntry Java Examples
The following examples show how to use
org.assertj.core.data.MapEntry.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JAXRSClientTest.java From feign with Apache License 2.0 | 6 votes |
@Test public void testContentTypeWithoutCharset2() throws Exception { server.enqueue(new MockResponse() .setBody("AAAAAAAA")); final JaxRSClientTestInterface api = newBuilder() .target(JaxRSClientTestInterface.class, "http://localhost:" + server.getPort()); final Response response = api.getWithContentType(); // Response length should not be null assertEquals("AAAAAAAA", Util.toString(response.body().asReader(UTF_8))); MockWebServerAssertions.assertThat(server.takeRequest()) .hasHeaders( MapEntry.entry("Accept", Collections.singletonList("text/plain")), MapEntry.entry("Content-Type", Collections.singletonList("text/plain"))) .hasMethod("GET"); }
Example #2
Source File: LiiklusCloudEventTest.java From liiklus with MIT License | 6 votes |
@Test public void deserialization() { String id = UUID.randomUUID().toString(); Map<String, String> headers = Stream.of( entry("ce_specversion", "1.0"), entry("ce_id", id), entry("ce_type", "com.example.event"), entry("ce_source", "/tests"), entry("ce_datacontenttype", "text/plain") ).collect(Collectors.toMap(MapEntry::getKey, MapEntry::getValue)); LiiklusCloudEvent event = LiiklusCloudEvent.of(null, headers); assertThat(event) .returns("1.0", LiiklusCloudEvent::getSpecversion) .returns(id, LiiklusCloudEvent::getId) .returns("com.example.event", LiiklusCloudEvent::getType) .returns("/tests", LiiklusCloudEvent::getRawSource) .returns("text/plain", LiiklusCloudEvent::getMediaTypeOrNull); }
Example #3
Source File: LiiklusCloudEventTest.java From liiklus with MIT License | 6 votes |
@Test public void deserialization() { String id = UUID.randomUUID().toString(); Map<String, String> headers = Stream.of( entry("ce_specversion", "1.0"), entry("ce_id", id), entry("ce_type", "com.example.event"), entry("ce_source", "/tests"), entry("ce_comexamplefoo", "foo"), entry("ce_comexamplebar", "bar") ).collect(Collectors.toMap(MapEntry::getKey, MapEntry::getValue)); LiiklusCloudEvent event = LiiklusCloudEvent.of(null, headers); assertThat(event.getRawExtensions()).containsOnly( entry("comexamplefoo", "foo"), entry("comexamplebar", "bar") ); }
Example #4
Source File: MessageIdMapperTest.java From james-project with Apache License 2.0 | 6 votes |
@Test void setFlagsShouldAddFlagsWhenAddUpdateMode() throws Exception { Flags initialFlags = new Flags(Flag.RECENT); message1.setUid(mapperProvider.generateMessageUid()); message1.setModSeq(mapperProvider.generateModSeq(benwaInboxMailbox)); message1.setFlags(initialFlags); sut.save(message1); MessageId messageId = message1.getMessageId(); Multimap<MailboxId, UpdatedFlags> flags = sut.setFlags(messageId, ImmutableList.of(message1.getMailboxId()), new Flags(Flag.ANSWERED), FlagsUpdateMode.ADD); Flags newFlags = new FlagsBuilder() .add(Flag.RECENT) .add(Flag.ANSWERED) .build(); ModSeq modSeq = mapperProvider.highestModSeq(benwaInboxMailbox); UpdatedFlags expectedUpdatedFlags = UpdatedFlags.builder() .uid(message1.getUid()) .modSeq(modSeq) .oldFlags(initialFlags) .newFlags(newFlags) .build(); assertThat(flags.asMap()) .containsOnly(MapEntry.entry(benwaInboxMailbox.getMailboxId(), ImmutableList.of(expectedUpdatedFlags))); }
Example #5
Source File: MimeDecodingMailetTest.java From james-project with Apache License 2.0 | 6 votes |
@Test void serviceShouldChangeAttributeWhenDefined() throws MessagingException { FakeMailetConfig mailetConfig = FakeMailetConfig.builder() .mailetName("Test") .mailetContext(mailetContext) .setProperty(MimeDecodingMailet.ATTRIBUTE_PARAMETER_NAME, MAIL_ATTRIBUTE.asString()) .build(); testee.init(mailetConfig); FakeMail mail = FakeMail.defaultFakeMail(); String text = "Attachment content"; String content = "Content-Transfer-Encoding: 8bit\r\n" + "Content-Type: application/octet-stream; charset=utf-8\r\n\r\n" + text; String expectedKey = "mimePart1"; AttributeValue<?> value = AttributeValue.ofAny(ImmutableMap.of(expectedKey, content.getBytes(StandardCharsets.UTF_8))); mail.setAttribute(new Attribute(MAIL_ATTRIBUTE, value)); byte[] expectedValue = text.getBytes(StandardCharsets.UTF_8); testee.service(mail); Optional<Map<String, byte[]>> processedAttribute = AttributeUtils.getValueAndCastFromMail(mail, MAIL_ATTRIBUTE, MAP_STRING_BYTES_CLASS); assertThat(processedAttribute).hasValueSatisfying(map -> assertThat(map) .containsExactly(MapEntry.entry(expectedKey, expectedValue))); }
Example #6
Source File: JAXRSClientTest.java From feign with Apache License 2.0 | 6 votes |
@Test public void testConsumesMultipleWithContentTypeHeaderAndBody() throws Exception { server.enqueue(new MockResponse().setBody("AAAAAAAA")); final JaxRSClientTestInterfaceWithJaxRsContract api = newBuilder() .contract(new JAXRSContract()) // use JAXRSContract .target(JaxRSClientTestInterfaceWithJaxRsContract.class, "http://localhost:" + server.getPort()); final Response response = api.consumesMultipleWithContentTypeHeaderAndBody("application/json;charset=utf-8", "body"); assertEquals("AAAAAAAA", Util.toString(response.body().asReader(UTF_8))); MockWebServerAssertions.assertThat(server.takeRequest()) .hasHeaders(MapEntry.entry("Content-Type", Collections.singletonList("application/json;charset=utf-8"))) .hasMethod("POST"); }
Example #7
Source File: BaseServiceImplTest.java From commercetools-sync-java with Apache License 2.0 | 6 votes |
@Test void cacheKeysToIds_WithAllCachedKeys_ShouldMakeNoRequestAndReturnCachedEntry() { //preparation final PagedQueryResult pagedQueryResult = mock(PagedQueryResult.class); final Product mockProductResult = mock(Product.class); final String key = "testKey"; final String id = "testId"; when(mockProductResult.getKey()).thenReturn(key); when(mockProductResult.getId()).thenReturn(id); when(pagedQueryResult.getResults()).thenReturn(singletonList(mockProductResult)); when(client.execute(any())).thenReturn(completedFuture(pagedQueryResult)); service.getIdFromCacheOrFetch(key).toCompletableFuture().join(); //test final Map<String, String> optional = service.cacheKeysToIds(singleton("testKey")).toCompletableFuture().join(); //assertions assertThat(optional).containsExactly(MapEntry.entry(key, id)); verify(client, times(1)).execute(any(ProductQuery.class)); }
Example #8
Source File: RemoteDeliveryConfigurationTest.java From james-project with Apache License 2.0 | 6 votes |
@Test public void createFinalJavaxPropertiesShouldProvidePropertiesWithMinimalConfiguration() { String helo = "domain.com"; FakeMailetConfig mailetConfig = FakeMailetConfig.builder() .setProperty(RemoteDeliveryConfiguration.HELO_NAME, helo) .build(); Properties properties = new RemoteDeliveryConfiguration(mailetConfig, mock(DomainList.class)).createFinalJavaxProperties(); assertThat(properties) .containsOnly(MapEntry.entry("mail.smtp.ssl.enable", "false"), MapEntry.entry("mail.smtp.sendpartial", "false"), MapEntry.entry("mail.smtp.ehlo", "true"), MapEntry.entry("mail.smtp.connectiontimeout", "60000"), MapEntry.entry("mail.smtp.localhost", helo), MapEntry.entry("mail.smtp.timeout", "180000"), MapEntry.entry("mail.debug", "false"), MapEntry.entry("mail.smtp.starttls.enable", "false")); }
Example #9
Source File: JavaAnnotationTest.java From ArchUnit with Apache License 2.0 | 6 votes |
@Test public void visits_first_level_parameters() { JavaClasses classes = importClasses( AnnotationWithFirstLevelParameters.class, ClassWithAnnotationWithFirstLevelParameters.class, Class1.class, Class2.class, SomeEnum.class); JavaAnnotation<JavaClass> annotation = classes.get(ClassWithAnnotationWithFirstLevelParameters.class) .getAnnotationOfType(AnnotationWithFirstLevelParameters.class.getName()); Map<Enum<?>, JavaEnumConstant> enumConstants = getEnumConstants(classes.get(SomeEnum.class)); ParametersStoringVisitor visitor = new ParametersStoringVisitor(); annotation.accept(visitor); MapEntry<String, Object>[] expectedParameters = expectedParametersWithOffset1("", classes, enumConstants); assertThat(visitor.getVisitedParameters()) .contains(expectedParameters) .hasSize(expectedParameters.length); }
Example #10
Source File: OkHttpClientTest.java From feign with Apache License 2.0 | 6 votes |
@Test public void testContentTypeWithoutCharset() throws Exception { server.enqueue(new MockResponse() .setBody("AAAAAAAA")); OkHttpClientTestInterface api = newBuilder() .target(OkHttpClientTestInterface.class, "http://localhost:" + server.getPort()); Response response = api.getWithContentType(); // Response length should not be null assertEquals("AAAAAAAA", Util.toString(response.body().asReader(Util.UTF_8))); MockWebServerAssertions.assertThat(server.takeRequest()) .hasHeaders( MapEntry.entry("Accept", Collections.singletonList("text/plain")), MapEntry.entry("Content-Type", Collections.singletonList("text/plain"))) .hasMethod("GET"); }
Example #11
Source File: BrowseServiceTest.java From archiva with Apache License 2.0 | 6 votes |
@Test public void metadatagetthenadd() throws Exception { scanRepo( TEST_REPO_ID ); waitForScanToComplete( TEST_REPO_ID ); BrowseService browseService = getBrowseService( authorizationHeader, false ); Map<String, String> metadatas = toMap( browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", TEST_REPO_ID ) ); assertThat( metadatas ).isNotNull().isEmpty(); browseService.addMetadata( "commons-cli", "commons-cli", "1.0", "wine", "bordeaux", TEST_REPO_ID ); metadatas = toMap( browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", TEST_REPO_ID ) ); assertThat( metadatas ).isNotNull().isNotEmpty().contains( MapEntry.entry( "wine", "bordeaux" ) ); }
Example #12
Source File: HeaderTranslatorTest.java From ditto with Eclipse Public License 2.0 | 6 votes |
@Test public void translateMixedDittoHeadersRetainKnownHeaders() { final String correlationId = "correlation-id"; final MapEntry<String, String> customHeader = entry("foo", "bar"); final MapEntry<String, String> customHeader2 = entry("websocket", "example-ws-header-value"); final DittoHeaders dittoHeaders = DittoHeaders.newBuilder() .dryRun(true) .correlationId(correlationId) .putHeader(customHeader.getKey(), customHeader.getValue()) .putHeader(customHeader2.getKey(), customHeader2.getValue()) .build(); final Map<String, String> expected = new HashMap<>(); expected.put(DittoHeaderDefinition.CORRELATION_ID.getKey(), correlationId); expected.put(DittoHeaderDefinition.DRY_RUN.getKey(), Boolean.TRUE.toString()); final HeaderTranslator underTest = HeaderTranslator.of(DittoHeaderDefinition.values()); assertThat(underTest.retainKnownHeaders(dittoHeaders)).isEqualTo(expected); }
Example #13
Source File: RemoteDeliveryConfigurationTest.java From james-project with Apache License 2.0 | 6 votes |
@Test public void createFinalJavaxPropertiesShouldProvidePropertiesWithFullConfigurationWithoutGateway() { String helo = "domain.com"; int connectionTimeout = 1856; FakeMailetConfig mailetConfig = FakeMailetConfig.builder() .setProperty(RemoteDeliveryConfiguration.SSL_ENABLE, "true") .setProperty(RemoteDeliveryConfiguration.SENDPARTIAL, "true") .setProperty(RemoteDeliveryConfiguration.CONNECTIONTIMEOUT, String.valueOf(connectionTimeout)) .setProperty(RemoteDeliveryConfiguration.START_TLS, "true") .setProperty(RemoteDeliveryConfiguration.HELO_NAME, helo) .build(); Properties properties = new RemoteDeliveryConfiguration(mailetConfig, mock(DomainList.class)).createFinalJavaxProperties(); assertThat(properties) .containsOnly(MapEntry.entry("mail.smtp.ssl.enable", "true"), MapEntry.entry("mail.smtp.sendpartial", "true"), MapEntry.entry("mail.smtp.ehlo", "true"), MapEntry.entry("mail.smtp.connectiontimeout", String.valueOf(connectionTimeout)), MapEntry.entry("mail.smtp.localhost", helo), MapEntry.entry("mail.smtp.timeout", "180000"), MapEntry.entry("mail.debug", "false"), MapEntry.entry("mail.smtp.starttls.enable", "true")); }
Example #14
Source File: GitConfigurationSourceIntegrationTest.java From cfg4j with Apache License 2.0 | 5 votes |
@Test void getConfigurationReadsFromGivenPath() throws Exception { try (GitConfigurationSource gitConfigurationSource = getSourceForRemoteRepoWithDefaults()) { Environment environment = new ImmutableEnvironment("/otherApplicationConfigs/"); assertThat(gitConfigurationSource.getConfiguration(environment)).contains(MapEntry.entry("some.setting", "otherAppSetting")); } }
Example #15
Source File: RemoteDeliveryConfigurationTest.java From james-project with Apache License 2.0 | 5 votes |
@Test public void createFinalJavaxPropertiesShouldProvidePropertiesWithFullConfigurationWithGateway() { String helo = "domain.com"; int connectionTimeout = 1856; FakeMailetConfig mailetConfig = FakeMailetConfig.builder() .setProperty(RemoteDeliveryConfiguration.SSL_ENABLE, "true") .setProperty(RemoteDeliveryConfiguration.SENDPARTIAL, "true") .setProperty(RemoteDeliveryConfiguration.CONNECTIONTIMEOUT, String.valueOf(connectionTimeout)) .setProperty(RemoteDeliveryConfiguration.START_TLS, "true") .setProperty(RemoteDeliveryConfiguration.HELO_NAME, helo) .setProperty(RemoteDeliveryConfiguration.GATEWAY, "gateway.domain.com") .setProperty(RemoteDeliveryConfiguration.GATEWAY_USERNAME, "user") .setProperty(RemoteDeliveryConfiguration.GATEWAY_PASSWORD, "password") .build(); Properties properties = new RemoteDeliveryConfiguration(mailetConfig, mock(DomainList.class)).createFinalJavaxProperties(); assertThat(properties) .containsOnly(MapEntry.entry("mail.smtp.ssl.enable", "true"), MapEntry.entry("mail.smtp.sendpartial", "true"), MapEntry.entry("mail.smtp.ehlo", "true"), MapEntry.entry("mail.smtp.connectiontimeout", String.valueOf(connectionTimeout)), MapEntry.entry("mail.smtp.localhost", helo), MapEntry.entry("mail.smtp.timeout", "180000"), MapEntry.entry("mail.debug", "false"), MapEntry.entry("mail.smtp.starttls.enable", "true"), MapEntry.entry("mail.smtp.auth", "true")); }
Example #16
Source File: AbstractSharedPreferencesAssert.java From assertj-android with Apache License 2.0 | 5 votes |
public S doesNotContain(String key, boolean value) { isNotNull(); assertThat(actual.getAll()) .overridingErrorMessage("Expected preferences not to contain <%s> but it does.", stringOf(key, value)) .doesNotContain(MapEntry.entry(key, value)); return myself; }
Example #17
Source File: AbstractSharedPreferencesAssert.java From assertj-android with Apache License 2.0 | 5 votes |
public S contains(String key, String value) { isNotNull(); assertThat(actual.getAll()) .overridingErrorMessage("Expected preferences to contain <%s> but it does not.", stringOf(key, value)) .contains(MapEntry.entry(key, value)); return myself; }
Example #18
Source File: JsonBasedPropertiesProviderTest.java From cfg4j with Apache License 2.0 | 5 votes |
@Test void readsTextBlock() throws Exception { String path = "org/cfg4j/source/propertiesprovider/JsonBasedPropertiesProviderTest_readsTextBlock.json"; try (InputStream input = getClass().getClassLoader().getResourceAsStream(path)) { assertThat(provider.getProperties(input)).containsExactly(MapEntry.entry("content", "I'm just a text block document")); } }
Example #19
Source File: JsonBasedPropertiesProviderTest.java From cfg4j with Apache License 2.0 | 5 votes |
@Test void readsLists() throws Exception { String path = "org/cfg4j/source/propertiesprovider/JsonBasedPropertiesProviderTest_readsLists.json"; try (InputStream input = getClass().getClassLoader().getResourceAsStream(path)) { assertThat(provider.getProperties(input)).containsOnly(MapEntry.entry("whitelist", "a,b,33"), MapEntry.entry("blacklist", "x,y,z")); } }
Example #20
Source File: ToStringTest.java From TweetwallFX with MIT License | 5 votes |
@Test public void testMapKeyValue_2args() { final Map<String, Object> result = map( KEY1, VALUE1); assertThat(result).containsExactly( MapEntry.entry(KEY1, VALUE1) ); }
Example #21
Source File: JsonBasedPropertiesProviderTest.java From cfg4j with Apache License 2.0 | 5 votes |
@Test void readsNestedValues() throws Exception { String path = "org/cfg4j/source/propertiesprovider/JsonBasedPropertiesProviderTest_readsNestedValues.json"; try (InputStream input = getClass().getClassLoader().getResourceAsStream(path)) { assertThat(provider.getProperties(input)).containsOnly(MapEntry.entry("some.setting", "masterValue"), MapEntry.entry("some.integerSetting", 42)); } }
Example #22
Source File: JsonBasedPropertiesProviderTest.java From cfg4j with Apache License 2.0 | 5 votes |
@Test void readsSingleValues() throws Exception { String path = "org/cfg4j/source/propertiesprovider/JsonBasedPropertiesProviderTest_readsSingleValues.json"; try (InputStream input = getClass().getClassLoader().getResourceAsStream(path)) { assertThat(provider.getProperties(input)).containsOnly(MapEntry.entry("setting", "masterValue"), MapEntry.entry("integerSetting", 42)); } }
Example #23
Source File: YamlBasedPropertiesProviderTest.java From cfg4j with Apache License 2.0 | 5 votes |
@Test void supportsReferences() throws Exception { String path = "org/cfg4j/source/propertiesprovider/YamlBasedPropertiesProviderTest_supportsReferences.yaml"; try (InputStream input = getClass().getClassLoader().getResourceAsStream(path)) { assertThat(provider.getProperties(input)).containsOnly( MapEntry.entry("wheelA.radius", "25cm"), MapEntry.entry("wheelA.color", "black"), MapEntry.entry("wheelB.radius", "25cm"), MapEntry.entry("wheelB.color", "black") ); } }
Example #24
Source File: YamlBasedPropertiesProviderTest.java From cfg4j with Apache License 2.0 | 5 votes |
@Test void readsLists() throws Exception { String path = "org/cfg4j/source/propertiesprovider/YamlBasedPropertiesProviderTest_readsLists.yaml"; try (InputStream input = getClass().getClassLoader().getResourceAsStream(path)) { assertThat(provider.getProperties(input)).containsOnly(MapEntry.entry("whitelist", "a,b,33"), MapEntry.entry("blacklist", "x,y,z")); } }
Example #25
Source File: CacheCalculationTest.java From ehcache3 with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Test public void getAll() { expect(cache.getAll(asSet(1))).containsExactly(MapEntry.entry(1, null)); changesOf(0, 1, 0, 0); cache.put(1, "a"); cache.put(2, "b"); changesOf(0, 0, 2, 0); expect(cache.getAll(asSet(1, 2, 3))).containsKeys(1, 2); changesOf(2, 1, 0, 0); }
Example #26
Source File: MailboxACLTest.java From james-project with Apache License 2.0 | 5 votes |
@Test void usersACLShouldReturnOnlyUsersMapWhenSomeUserEntries() throws Exception { MailboxACL.Rfc4314Rights rights = MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("aei"); MailboxACL mailboxACL = new MailboxACL( ImmutableMap.of(EntryKey.createUserEntryKey(USERNAME_1), MailboxACL.FULL_RIGHTS, EntryKey.createGroupEntryKey("group"), MailboxACL.FULL_RIGHTS, EntryKey.createUserEntryKey(USERNAME_2), rights, EntryKey.createGroupEntryKey("group2"), MailboxACL.NO_RIGHTS)); assertThat(mailboxACL.ofPositiveNameType(NameType.user)) .containsOnly( MapEntry.entry(EntryKey.createUserEntryKey(USERNAME_1), MailboxACL.FULL_RIGHTS), MapEntry.entry(EntryKey.createUserEntryKey(USERNAME_2), rights)); }
Example #27
Source File: AbstractSharedPreferencesAssert.java From assertj-android with Apache License 2.0 | 5 votes |
public S contains(String key, Set<String> value) { isNotNull(); assertThat(actual.getAll()) .overridingErrorMessage("Expected preferences to contain <%s> but it does not.", stringOf(key, value)) .contains(MapEntry.entry(key, value)); return myself; }
Example #28
Source File: AbstractSharedPreferencesAssert.java From assertj-android with Apache License 2.0 | 5 votes |
public S doesNotContain(String key, String value) { isNotNull(); assertThat(actual.getAll()) .overridingErrorMessage("Expected preferences not to contain <%s> but it does.", stringOf(key, value)) .doesNotContain(MapEntry.entry(key, value)); return myself; }
Example #29
Source File: AbstractSharedPreferencesAssert.java From assertj-android with Apache License 2.0 | 5 votes |
public S contains(String key, long value) { isNotNull(); assertThat(actual.getAll()) .overridingErrorMessage("Expected preferences to contain <%s> but it does not.", stringOf(key, value)) .contains(MapEntry.entry(key, value)); return myself; }
Example #30
Source File: InternationalizationServiceSingletonIT.java From wisdom with Apache License 2.0 | 5 votes |
@Test public void testManagementOfABundleContainingInternationalizationFiles() throws FileNotFoundException, BundleException { Bundle bundle = osgi.installAndStart("local:/i18n", bundle() .add("i18n/app.properties", new FileInputStream("src/test/resources/integration/app.properties")) .add("i18n/app_fr.properties", new FileInputStream("src/test/resources/integration/app_fr.properties")) .build()); bundles.add(bundle); Map<String, String> messages = service.getAllMessages(Locale.FRENCH); assertThat(messages).contains( MapEntry.entry("app.name", "mon application") ); messages = service.getAllMessages(Locale.CHINA); assertThat(messages).contains( MapEntry.entry("app.name", "my application") ); messages = service.getAllMessages(Locale.ENGLISH); assertThat(messages).contains( MapEntry.entry("app.name", "my application") ); messages = service.getAllMessages(Locale.GERMAN); assertThat(messages).contains( MapEntry.entry("app.name", "my application") ); bundle.stop(); messages = service.getAllMessages(Locale.FRENCH); assertThat(messages).doesNotContainKey("app.name"); messages = service.getAllMessages(Locale.GERMAN); assertThat(messages).doesNotContainKey("app.name"); }