Return own identities even if they don’t have the correct context.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 25 Aug 2014 18:56:27 +0000 (20:56 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 25 Aug 2014 18:56:27 +0000 (20:56 +0200)
src/main/java/net/pterodactylus/sone/freenet/wot/IdentityLoader.java
src/test/java/net/pterodactylus/sone/freenet/wot/IdentityLoaderTest.java

index e19cbfc..75ec828 100644 (file)
 
 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.<Identity>emptySet());
                                continue;
                        }
 
index 4772302..98e187d 100644 (file)
@@ -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.<Identity>emptySet());
                verifyIdentitiesForOwnIdentity(identities, ownIdentities.get(3), createTrustedIdentitiesForFourthOwnIdentity());
        }