From 8c37a133cd15e9b271079c2330b2e25ac0c45898 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 25 Aug 2014 20:56:27 +0200 Subject: [PATCH] =?utf8?q?Return=20own=20identities=20even=20if=20they=20d?= =?utf8?q?on=E2=80=99t=20have=20the=20correct=20context.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../java/net/pterodactylus/sone/freenet/wot/IdentityLoader.java | 3 +++ .../net/pterodactylus/sone/freenet/wot/IdentityLoaderTest.java | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) 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()); } -- 2.7.4