}
+ public static class GetTrusteesTests extends Common {
+
+ @Test
+ public void getTrusteesSendsCorrectCommand() throws Exception {
+ TestFcpConnection fcpConnection = createConnectionThatSendsTrustees();
+ WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection);
+ Identity identity = new Identity("test-owner", "Test Owner", "request-uri", emptySet(), emptyMap());
+ webOfTrustPlugin.getTrustees(identity, "test");
+ assertThat(fcpConnection.sentMessages.get(0), allOf(
+ isNamed(equalTo("FCPPluginMessage")),
+ hasField("Identifier", notNullValue()),
+ hasField("PluginName", equalTo("plugins.WebOfTrust.WebOfTrust")),
+ hasField("Param.Message", equalTo("GetTrustees")),
+ hasField("Param.Identity", equalTo("test-owner")),
+ hasField("Param.Context", equalTo("test"))
+ ));
+ }
+
+ @Test
+ public void getTrusteesThrowsExceptionWhenDifferentReplyIsSentByPlugin() {
+ FcpConnection fcpConnection = createConnectionThatSendsOtherMessage();
+ WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection);
+ Identity identity = new Identity("test-owner", "Test Owner", "request-uri", emptySet(), emptyMap());
+ assertThrows(FcpException.class, () -> webOfTrustPlugin.getTrustees(identity, "test"));
+ }
+
+ @Test
+ public void getTrusteesParsesTheResponseCorrectly() throws Exception {
+ TestFcpConnection fcpConnection = createConnectionThatSendsTrustees();
+ WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection);
+ Identity identity = new Identity("test-owner", "Test Owner", "request-uri", emptySet(), emptyMap());
+ Map<Identity, IdentityTrust> trustees = webOfTrustPlugin.getTrustees(identity, "test");
+ assertThat(trustees, allOf(
+ hasEntry(hasId("id0"), allOf(IdentityTrustMatchers.hasTrust(123), hasComment("comment0"))),
+ hasEntry(hasId("id1"), allOf(IdentityTrustMatchers.hasTrust(99), hasComment("comment1")))
+ ));
+ }
+
+ private TestFcpConnection createConnectionThatSendsTrustees() {
+ return createConnection("Identities",
+ entries("Identity0", "id0", "Nickname0", "nickname0", "RequestURI0", "request-uri0", "Value0", "123", "Comment0", "comment0", "Properties0.Property0.Name", "property1", "Properties0.Property0.Value", "value1"),
+ entries("Identity1", "id1", "Nickname1", "nickname1", "RequestURI1", "request-uri1", "Value1", "99", "Comment1", "comment1", "Contexts1.Context0", "context1", "Contexts1.Context1", "context2"),
+ entries("Amount", "2")
+ );
+ }
+
+ }
+
private static class Common {
@SafeVarargs