From: David ‘Bombe’ Roden Date: Mon, 25 Aug 2014 18:56:27 +0000 (+0200) Subject: Return own identities even if they don’t have the correct context. X-Git-Tag: 0.9-rc1^2~3^2~149 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=8c37a133cd15e9b271079c2330b2e25ac0c45898;p=Sone.git Return own identities even if they don’t have the correct context. --- diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityLoader.java b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityLoader.java index e19cbfc..75ec828 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityLoader.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityLoader.java @@ -17,9 +17,11 @@ package net.pterodactylus.sone.freenet.wot; +import static java.util.Collections.emptySet; import static net.pterodactylus.sone.freenet.wot.Context.extractContext; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -59,6 +61,7 @@ public class IdentityLoader { for (OwnIdentity ownIdentity : ownIdentities) { if (identityDoesNotHaveTheCorrectContext(ownIdentity)) { + currentIdentities.put(ownIdentity, Collections.emptySet()); continue; } diff --git a/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityLoaderTest.java b/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityLoaderTest.java index 4772302..98e187d 100644 --- a/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityLoaderTest.java +++ b/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityLoaderTest.java @@ -25,6 +25,7 @@ import static java.util.Collections.emptySet; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; @@ -33,6 +34,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; @@ -118,10 +120,11 @@ public class IdentityLoaderTest { verify(webOfTrustConnector).loadTrustedIdentities(eq(ownIdentities.get(1)), eq(of("Test"))); verify(webOfTrustConnector, never()).loadTrustedIdentities(eq(ownIdentities.get(2)), any(Optional.class)); verify(webOfTrustConnector).loadTrustedIdentities(eq(ownIdentities.get(3)), eq(of("Test"))); - assertThat(identities.keySet(), hasSize(3)); - assertThat(identities.keySet(), containsInAnyOrder(ownIdentities.get(0), ownIdentities.get(1), ownIdentities.get(3))); + assertThat(identities.keySet(), hasSize(4)); + assertThat(identities.keySet(), containsInAnyOrder(ownIdentities.get(0), ownIdentities.get(1), ownIdentities.get(2), ownIdentities.get(3))); verifyIdentitiesForOwnIdentity(identities, ownIdentities.get(0), createTrustedIdentitiesForFirstOwnIdentity()); verifyIdentitiesForOwnIdentity(identities, ownIdentities.get(1), createTrustedIdentitiesForSecondOwnIdentity()); + verifyIdentitiesForOwnIdentity(identities, ownIdentities.get(2), Collections.emptySet()); verifyIdentitiesForOwnIdentity(identities, ownIdentities.get(3), createTrustedIdentitiesForFourthOwnIdentity()); }