✅ Stabilize timing-dependent test
[Sone.git] / src / test / java / net / pterodactylus / sone / core / WebOfTrustUpdaterTest.java
1 package net.pterodactylus.sone.core;
2
3 import static java.lang.Thread.sleep;
4 import static java.util.concurrent.TimeUnit.SECONDS;
5 import static org.hamcrest.MatcherAssert.assertThat;
6 import static org.hamcrest.Matchers.containsString;
7 import static org.hamcrest.Matchers.is;
8 import static org.hamcrest.Matchers.not;
9 import static org.mockito.ArgumentMatchers.eq;
10 import static org.mockito.Mockito.*;
11
12 import java.util.concurrent.CountDownLatch;
13
14 import net.pterodactylus.sone.core.WebOfTrustUpdaterImpl.AddContextJob;
15 import net.pterodactylus.sone.core.WebOfTrustUpdaterImpl.RemoveContextJob;
16 import net.pterodactylus.sone.core.WebOfTrustUpdaterImpl.SetPropertyJob;
17 import net.pterodactylus.sone.core.WebOfTrustUpdaterImpl.SetTrustJob;
18 import net.pterodactylus.sone.core.WebOfTrustUpdaterImpl.WebOfTrustContextUpdateJob;
19 import net.pterodactylus.sone.core.WebOfTrustUpdaterImpl.WebOfTrustUpdateJob;
20 import net.pterodactylus.sone.freenet.plugin.PluginException;
21 import net.pterodactylus.sone.freenet.wot.Identity;
22 import net.pterodactylus.sone.freenet.wot.OwnIdentity;
23 import net.pterodactylus.sone.freenet.wot.Trust;
24 import net.pterodactylus.sone.freenet.wot.WebOfTrustConnector;
25 import net.pterodactylus.sone.freenet.wot.WebOfTrustException;
26
27 import org.junit.Test;
28 import org.mockito.invocation.InvocationOnMock;
29 import org.mockito.stubbing.Answer;
30
31 /**
32  * Unit test for {@link WebOfTrustUpdaterImpl} and its subclasses.
33  */
34 public class WebOfTrustUpdaterTest {
35
36         private static final String CONTEXT = "test-context";
37         private static final Integer SCORE = 50;
38         private static final Integer OTHER_SCORE = 25;
39         private static final String TRUST_COMMENT = "set in a test";
40         private static final String PROPERTY_NAME = "test-property";
41         private final WebOfTrustConnector webOfTrustConnector = mock(WebOfTrustConnector.class);
42         private final WebOfTrustUpdaterImpl webOfTrustUpdater = new WebOfTrustUpdaterImpl(webOfTrustConnector);
43         private final OwnIdentity ownIdentity = when(mock(OwnIdentity.class).getId()).thenReturn("own-identity-id").getMock();
44         private final WebOfTrustUpdateJob successfulWebOfTrustUpdateJob = createWebOfTrustUpdateJob(true);
45         private final WebOfTrustUpdateJob failingWebOfTrustUpdateJob = createWebOfTrustUpdateJob(false);
46         private final WebOfTrustContextUpdateJob contextUpdateJob = webOfTrustUpdater.new WebOfTrustContextUpdateJob(ownIdentity, CONTEXT);
47         private final AddContextJob addContextJob = webOfTrustUpdater.new AddContextJob(ownIdentity, CONTEXT);
48         private final RemoveContextJob removeContextJob = webOfTrustUpdater.new RemoveContextJob(ownIdentity, CONTEXT);
49         private final Identity trustee = when(mock(Identity.class).getId()).thenReturn("trustee-id").getMock();
50
51         private WebOfTrustUpdateJob createWebOfTrustUpdateJob(final boolean success) {
52                 return webOfTrustUpdater.new WebOfTrustUpdateJob() {
53                         @Override
54                         public void run() {
55                                 super.run();
56                                 try {
57                                         sleep(100);
58                                 } catch (InterruptedException ie1) {
59                                         throw new RuntimeException(ie1);
60                                 }
61                                 finish(success);
62                         }
63                 };
64         }
65
66         @Test
67         public void webOfTrustUpdateJobWaitsUntilFinishedHasBeenCalledAndReturnsSuccess() throws InterruptedException {
68                 new Thread(successfulWebOfTrustUpdateJob).start();
69                 assertThat(successfulWebOfTrustUpdateJob.waitForCompletion(), is(true));
70         }
71
72         @Test
73         public void webOfTrustUpdateJobWaitsUntilFinishedHasBeenCalledAndReturnsFailure() throws InterruptedException {
74                 new Thread(failingWebOfTrustUpdateJob).start();
75                 assertThat(failingWebOfTrustUpdateJob.waitForCompletion(), is(false));
76         }
77
78         @Test
79         public void webOfTrustContextUpdateJobsAreEqualIfTheirClassOwnIdentityAndContextAreEqual() {
80                 WebOfTrustContextUpdateJob secondContextUpdateJob = webOfTrustUpdater.new WebOfTrustContextUpdateJob(ownIdentity, CONTEXT);
81                 assertThat(contextUpdateJob.equals(secondContextUpdateJob), is(true));
82                 assertThat(secondContextUpdateJob.equals(contextUpdateJob), is(true));
83                 assertThat(contextUpdateJob.hashCode(), is(secondContextUpdateJob.hashCode()));
84         }
85
86         @Test
87         public void webOfTrustContextUpdatesJobsAreNotEqualIfTheirClassDiffers() {
88                 assertThat(contextUpdateJob.equals(addContextJob), is(false));
89         }
90
91         @Test
92         public void webOfTrustContextUpdateJobToStringContainsIdentityAndContext() {
93                 assertThat(contextUpdateJob.toString(), containsString(ownIdentity.toString()));
94                 assertThat(contextUpdateJob.toString(), containsString(CONTEXT));
95         }
96
97         @Test
98         public void webOfTrustContextUpdateJobsAreNotEqualIfTheIdentitiesDiffer() {
99                 OwnIdentity ownIdentity = mock(OwnIdentity.class);
100                 WebOfTrustContextUpdateJob secondContextUpdateJob = webOfTrustUpdater.new WebOfTrustContextUpdateJob(ownIdentity, CONTEXT);
101                 assertThat(contextUpdateJob.equals(secondContextUpdateJob), is(false));
102                 assertThat(secondContextUpdateJob.equals(contextUpdateJob), is(false));
103         }
104
105         @Test
106         public void webOfTrustContextUpdateJobsAreNotEqualIfTheirContextsDiffer() {
107                 WebOfTrustContextUpdateJob secondContextUpdateJob = webOfTrustUpdater.new WebOfTrustContextUpdateJob(ownIdentity, CONTEXT + CONTEXT);
108                 assertThat(contextUpdateJob.equals(secondContextUpdateJob), is(false));
109                 assertThat(secondContextUpdateJob.equals(contextUpdateJob), is(false));
110         }
111
112         @Test
113         public void webOfTrustContextUpdateJobsAreNotEqualToNull() {
114                 assertThat(contextUpdateJob.equals(null), is(false));
115         }
116
117         @Test
118         public void addContextJobAddsTheContext() throws PluginException {
119                 addContextJob.run();
120                 verify(webOfTrustConnector).addContext(eq(ownIdentity), eq(CONTEXT));
121                 verify(ownIdentity).addContext(eq(CONTEXT));
122                 assertThat(addContextJob.waitForCompletion(), is(true));
123         }
124
125         @Test
126         public void exceptionWhileAddingAContextIsExposed() throws PluginException {
127                 doThrow(PluginException.class).when(webOfTrustConnector).addContext(eq(ownIdentity), eq(CONTEXT));
128                 addContextJob.run();
129                 verify(webOfTrustConnector).addContext(eq(ownIdentity), eq(CONTEXT));
130                 verify(ownIdentity, never()).addContext(eq(CONTEXT));
131                 assertThat(addContextJob.waitForCompletion(), is(false));
132         }
133
134         @Test
135         public void removeContextJobRemovesTheContext() throws PluginException {
136                 removeContextJob.run();
137                 verify(webOfTrustConnector).removeContext(eq(ownIdentity), eq(CONTEXT));
138                 verify(ownIdentity).removeContext(eq(CONTEXT));
139                 assertThat(removeContextJob.waitForCompletion(), is(true));
140         }
141
142         @Test
143         public void exceptionWhileRemovingAContextIsExposed() throws PluginException {
144                 doThrow(PluginException.class).when(webOfTrustConnector).removeContext(eq(ownIdentity), eq(CONTEXT));
145                 removeContextJob.run();
146                 verify(webOfTrustConnector).removeContext(eq(ownIdentity), eq(CONTEXT));
147                 verify(ownIdentity, never()).removeContext(eq(CONTEXT));
148                 assertThat(removeContextJob.waitForCompletion(), is(false));
149         }
150
151         @Test
152         public void settingAPropertySetsTheProperty() throws PluginException {
153                 String propertyName = "property-name";
154                 String propertyValue = "property-value";
155                 SetPropertyJob setPropertyJob = webOfTrustUpdater.new SetPropertyJob(ownIdentity, propertyName, propertyValue);
156                 setPropertyJob.run();
157                 verify(webOfTrustConnector).setProperty(eq(ownIdentity), eq(propertyName), eq(propertyValue));
158                 verify(ownIdentity).setProperty(eq(propertyName), eq(propertyValue));
159                 assertThat(setPropertyJob.waitForCompletion(), is(true));
160         }
161
162         @Test
163         public void settingAPropertyToNullRemovesTheProperty() throws PluginException {
164                 String propertyName = "property-name";
165                 SetPropertyJob setPropertyJob = webOfTrustUpdater.new SetPropertyJob(ownIdentity, propertyName, null);
166                 setPropertyJob.run();
167                 verify(webOfTrustConnector).removeProperty(eq(ownIdentity), eq(propertyName));
168                 verify(ownIdentity).removeProperty(eq(propertyName));
169                 assertThat(setPropertyJob.waitForCompletion(), is(true));
170         }
171
172         @Test
173         public void pluginExceptionWhileSettingAPropertyIsHandled() throws PluginException {
174                 String propertyName = "property-name";
175                 String propertyValue = "property-value";
176                 doThrow(PluginException.class).when(webOfTrustConnector).setProperty(eq(ownIdentity), eq(propertyName), eq(propertyValue));
177                 SetPropertyJob setPropertyJob = webOfTrustUpdater.new SetPropertyJob(ownIdentity, propertyName, propertyValue);
178                 setPropertyJob.run();
179                 verify(webOfTrustConnector).setProperty(eq(ownIdentity), eq(propertyName), eq(propertyValue));
180                 verify(ownIdentity, never()).setProperty(eq(propertyName), eq(propertyValue));
181                 assertThat(setPropertyJob.waitForCompletion(), is(false));
182         }
183
184         @Test
185         public void setPropertyJobsWithSameClassPropertyAndValueAreEqual() {
186                 String propertyName = "property-name";
187                 String propertyValue = "property-value";
188                 SetPropertyJob firstSetPropertyJob = webOfTrustUpdater.new SetPropertyJob(ownIdentity, propertyName, propertyValue);
189                 SetPropertyJob secondSetPropertyJob = webOfTrustUpdater.new SetPropertyJob(ownIdentity, propertyName, propertyValue);
190                 assertThat(firstSetPropertyJob, is(secondSetPropertyJob));
191                 assertThat(secondSetPropertyJob, is(firstSetPropertyJob));
192                 assertThat(firstSetPropertyJob.hashCode(), is(secondSetPropertyJob.hashCode()));
193         }
194
195         @Test
196         public void setPropertyJobsWithDifferentClassesAreNotEqual() {
197                 String propertyName = "property-name";
198                 String propertyValue = "property-value";
199                 SetPropertyJob firstSetPropertyJob = webOfTrustUpdater.new SetPropertyJob(ownIdentity, propertyName, propertyValue);
200                 SetPropertyJob secondSetPropertyJob = webOfTrustUpdater.new SetPropertyJob(ownIdentity, propertyName, propertyValue) {
201                 };
202                 assertThat(firstSetPropertyJob, not(is(secondSetPropertyJob)));
203         }
204
205         @Test
206         public void nullIsNotASetProjectJobEither() {
207                 String propertyName = "property-name";
208                 String propertyValue = "property-value";
209                 SetPropertyJob setPropertyJob = webOfTrustUpdater.new SetPropertyJob(ownIdentity, propertyName, propertyValue);
210                 assertThat(setPropertyJob, not(is((Object) null)));
211         }
212
213         @Test
214         public void setPropertyJobsWithDifferentPropertiesAreNotEqual() {
215                 String propertyName = "property-name";
216                 String propertyValue = "property-value";
217                 SetPropertyJob firstSetPropertyJob = webOfTrustUpdater.new SetPropertyJob(ownIdentity, propertyName, propertyValue);
218                 SetPropertyJob secondSetPropertyJob = webOfTrustUpdater.new SetPropertyJob(ownIdentity, propertyName + "2", propertyValue);
219                 assertThat(firstSetPropertyJob, not(is(secondSetPropertyJob)));
220         }
221
222         @Test
223         public void setPropertyJobsWithDifferentOwnIdentitiesAreNotEqual() {
224                 OwnIdentity otherOwnIdentity = mock(OwnIdentity.class);
225                 String propertyName = "property-name";
226                 String propertyValue = "property-value";
227                 SetPropertyJob firstSetPropertyJob = webOfTrustUpdater.new SetPropertyJob(ownIdentity, propertyName, propertyValue);
228                 SetPropertyJob secondSetPropertyJob = webOfTrustUpdater.new SetPropertyJob(otherOwnIdentity, propertyName, propertyValue);
229                 assertThat(firstSetPropertyJob, not(is(secondSetPropertyJob)));
230         }
231
232         @Test
233         public void setTrustJobSetsTrust() throws PluginException {
234                 SetTrustJob setTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT);
235                 setTrustJob.run();
236                 verify(webOfTrustConnector).setTrust(eq(ownIdentity), eq(trustee), eq(SCORE), eq(TRUST_COMMENT));
237                 verify(trustee).setTrust(eq(ownIdentity), eq(new Trust(SCORE, null, 0)));
238                 assertThat(setTrustJob.waitForCompletion(), is(true));
239         }
240
241         @Test
242         public void settingNullTrustRemovesTrust() throws WebOfTrustException {
243                 SetTrustJob setTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, null, TRUST_COMMENT);
244                 setTrustJob.run();
245                 verify(webOfTrustConnector).removeTrust(eq(ownIdentity), eq(trustee));
246                 verify(trustee).removeTrust(eq(ownIdentity));
247                 assertThat(setTrustJob.waitForCompletion(), is(true));
248         }
249
250         @Test
251         public void exceptionWhileSettingTrustIsCaught() throws PluginException {
252                 doThrow(PluginException.class).when(webOfTrustConnector).setTrust(eq(ownIdentity), eq(trustee), eq(SCORE), eq(TRUST_COMMENT));
253                 SetTrustJob setTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT);
254                 setTrustJob.run();
255                 verify(webOfTrustConnector).setTrust(eq(ownIdentity), eq(trustee), eq(SCORE), eq(TRUST_COMMENT));
256                 verify(trustee, never()).setTrust(eq(ownIdentity), eq(new Trust(SCORE, null, 0)));
257                 assertThat(setTrustJob.waitForCompletion(), is(false));
258         }
259
260         @Test
261         public void setTrustJobsWithDifferentClassesAreNotEqual() {
262                 SetTrustJob firstSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT);
263                 SetTrustJob secondSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT) {
264                 };
265                 assertThat(firstSetTrustJob, not(is(secondSetTrustJob)));
266                 assertThat(secondSetTrustJob, not(is(firstSetTrustJob)));
267         }
268
269         @Test
270         public void setTrustJobsWithDifferentTrustersAreNotEqual() {
271                 SetTrustJob firstSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT);
272                 SetTrustJob secondSetTrustJob = webOfTrustUpdater.new SetTrustJob(mock(OwnIdentity.class), trustee, SCORE, TRUST_COMMENT);
273                 assertThat(firstSetTrustJob, not(is(secondSetTrustJob)));
274                 assertThat(secondSetTrustJob, not(is(firstSetTrustJob)));
275         }
276
277         @Test
278         public void setTrustJobsWithDifferentTrusteesAreNotEqual() {
279                 SetTrustJob firstSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT);
280                 SetTrustJob secondSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, mock(Identity.class), SCORE, TRUST_COMMENT);
281                 assertThat(firstSetTrustJob, not(is(secondSetTrustJob)));
282                 assertThat(secondSetTrustJob, not(is(firstSetTrustJob)));
283         }
284
285         @Test
286         public void setTrustJobsWithDifferentScoreAreEqual() {
287                 SetTrustJob firstSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT);
288                 SetTrustJob secondSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, OTHER_SCORE, TRUST_COMMENT);
289                 assertThat(firstSetTrustJob, is(secondSetTrustJob));
290                 assertThat(secondSetTrustJob, is(firstSetTrustJob));
291                 assertThat(firstSetTrustJob.hashCode(), is(secondSetTrustJob.hashCode()));
292         }
293
294         @Test
295         public void setTrustJobDoesNotEqualNull() {
296                 SetTrustJob setTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT);
297                 assertThat(setTrustJob, not(is((Object) null)));
298         }
299
300         @Test
301         public void toStringOfSetTrustJobContainsIdsOfTrusterAndTrustee() {
302                 SetTrustJob setTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT);
303                 assertThat(setTrustJob.toString(), containsString(ownIdentity.getId()));
304                 assertThat(setTrustJob.toString(), containsString(trustee.getId()));
305         }
306
307         @Test
308         public void webOfTrustUpdaterStopsWhenItShould() {
309                 webOfTrustUpdater.stop();
310                 webOfTrustUpdater.serviceRun();
311         }
312
313         @Test
314         public void webOfTrustUpdaterStopsAfterItWasStarted() {
315                 webOfTrustUpdater.start();
316                 webOfTrustUpdater.stop();
317         }
318
319         @Test
320         public void removePropertyRemovesProperty() throws InterruptedException, PluginException {
321                 final CountDownLatch wotCallTriggered = new CountDownLatch(1);
322                 doAnswer(new Answer<Void>() {
323                         @Override
324                         public Void answer(InvocationOnMock invocation) throws Throwable {
325                                 wotCallTriggered.countDown();
326                                 return null;
327                         }
328                 }).when(webOfTrustConnector).removeProperty(eq(ownIdentity), eq(PROPERTY_NAME));
329                 webOfTrustUpdater.removeProperty(ownIdentity, PROPERTY_NAME);
330                 webOfTrustUpdater.start();
331                 assertThat(wotCallTriggered.await(1, SECONDS), is(true));
332         }
333
334         @Test
335         public void multipleCallsToSetPropertyAreCollapsed() throws InterruptedException, PluginException {
336                 final CountDownLatch wotCallTriggered = new CountDownLatch(1);
337                 doAnswer(new Answer<Void>() {
338                         @Override
339                         public Void answer(InvocationOnMock invocation) throws Throwable {
340                                 wotCallTriggered.countDown();
341                                 return null;
342                         }
343                 }).when(webOfTrustConnector).removeProperty(eq(ownIdentity), eq(PROPERTY_NAME));
344                 webOfTrustUpdater.removeProperty(ownIdentity, PROPERTY_NAME);
345                 webOfTrustUpdater.removeProperty(ownIdentity, PROPERTY_NAME);
346                 webOfTrustUpdater.start();
347                 assertThat(wotCallTriggered.await(1, SECONDS), is(true));
348                 verify(webOfTrustConnector).removeProperty(eq(ownIdentity), eq(PROPERTY_NAME));
349         }
350
351         @Test
352         public void addContextWaitWaitsForTheContextToBeAdded() {
353                 webOfTrustUpdater.start();
354                 assertThat(webOfTrustUpdater.addContextWait(ownIdentity, CONTEXT), is(true));
355                 verify(ownIdentity).addContext(eq(CONTEXT));
356         }
357
358         @Test
359         public void removeContextRemovesAContext() throws InterruptedException, PluginException {
360                 webOfTrustUpdater.start();
361                 final CountDownLatch removeContextTrigger = new CountDownLatch(1);
362                 doAnswer(new Answer<Void>() {
363                         @Override
364                         public Void answer(InvocationOnMock invocation) throws Throwable {
365                                 removeContextTrigger.countDown();
366                                 return null;
367                         }
368                 }).when(ownIdentity).removeContext(eq(CONTEXT));
369                 webOfTrustUpdater.removeContext(ownIdentity, CONTEXT);
370                 removeContextTrigger.await(1, SECONDS);
371                 verify(webOfTrustConnector).removeContext(eq(ownIdentity), eq(CONTEXT));
372                 verify(ownIdentity).removeContext(eq(CONTEXT));
373         }
374
375         @Test
376         public void removeContextRequestsAreCoalesced() throws InterruptedException, PluginException {
377                 final CountDownLatch contextRemovedTrigger = new CountDownLatch(1);
378                 doAnswer(new Answer<Void>() {
379                         @Override
380                         public Void answer(InvocationOnMock invocation) throws Throwable {
381                                 contextRemovedTrigger.countDown();
382                                 return null;
383                         }
384                 }).when(ownIdentity).removeContext(eq(CONTEXT));
385                 for (int i = 1; i <= 2; i++) {
386                         /* this is so fucking volatile. */
387                         if (i > 1) {
388                                 sleep(200);
389                         }
390                         new Thread(new Runnable() {
391                                 public void run() {
392                                         webOfTrustUpdater.removeContext(ownIdentity, CONTEXT);
393                                 }
394                         }).start();
395                 }
396                 webOfTrustUpdater.start();
397                 assertThat(contextRemovedTrigger.await(1, SECONDS), is(true));
398                 verify(webOfTrustConnector).removeContext(eq(ownIdentity), eq(CONTEXT));
399                 verify(ownIdentity).removeContext(eq(CONTEXT));
400         }
401
402         @Test
403         public void setTrustSetsTrust() throws InterruptedException, PluginException {
404                 final CountDownLatch trustSetTrigger = new CountDownLatch(1);
405                 doAnswer(new Answer<Void>() {
406                         @Override
407                         public Void answer(InvocationOnMock invocation) throws Throwable {
408                                 trustSetTrigger.countDown();
409                                 return null;
410                         }
411                 }).when(trustee).setTrust(eq(ownIdentity), eq(new Trust(SCORE, null, 0)));
412                 webOfTrustUpdater.start();
413                 webOfTrustUpdater.setTrust(ownIdentity, trustee, SCORE, TRUST_COMMENT);
414                 assertThat(trustSetTrigger.await(1, SECONDS), is(true));
415                 verify(trustee).setTrust(eq(ownIdentity), eq(new Trust(SCORE, null, 0)));
416                 verify(webOfTrustConnector).setTrust(eq(ownIdentity), eq(trustee), eq(SCORE), eq(TRUST_COMMENT));
417         }
418
419         @Test
420         public void setTrustRequestsAreCoalesced() throws InterruptedException, PluginException {
421                 final CountDownLatch firstTrigger = new CountDownLatch(1);
422                 doAnswer((Answer<Void>) invocation -> {
423                         firstTrigger.countDown();
424                         return null;
425                 }).when(trustee).setTrust(eq(ownIdentity), eq(new Trust(SCORE, null, 0)));
426                 Identity secondTrustee = when(mock(Identity.class).getId()).thenReturn("trustee-id2").getMock();
427                 final CountDownLatch secondTrigger = new CountDownLatch(1);
428                 doAnswer((Answer<Void>) invocation -> {
429                         secondTrigger.countDown();
430                         return null;
431                 }).when(secondTrustee).setTrust(eq(ownIdentity), eq(new Trust(SCORE, null, 0)));
432                 webOfTrustUpdater.setTrust(ownIdentity, trustee, SCORE, TRUST_COMMENT);
433                 webOfTrustUpdater.setTrust(ownIdentity, secondTrustee, SCORE, TRUST_COMMENT);
434                 webOfTrustUpdater.setTrust(ownIdentity, trustee, SCORE, TRUST_COMMENT);
435                 webOfTrustUpdater.start();
436                 assertThat(firstTrigger.await(1, SECONDS), is(true));
437                 assertThat(secondTrigger.await(1, SECONDS), is(true));
438                 verify(trustee, times(1)).setTrust(eq(ownIdentity), eq(new Trust(SCORE, null, 0)));
439                 verify(webOfTrustConnector).setTrust(eq(ownIdentity), eq(trustee), eq(SCORE), eq(TRUST_COMMENT));
440         }
441
442 }