- for (int i = 1; i <= 2; i++) {
- /* this is so fucking volatile. */
- if (i > 1) {
- sleep(200);
- }
- new Thread(new Runnable() {
- public void run() {
- webOfTrustUpdater.setTrust(ownIdentity, trustee, SCORE, TRUST_COMMENT);
- }
- }).start();
- }
+ Identity secondTrustee = when(mock(Identity.class).getId()).thenReturn("trustee-id2").getMock();
+ final CountDownLatch secondTrigger = new CountDownLatch(1);
+ doAnswer((Answer<Void>) invocation -> {
+ secondTrigger.countDown();
+ return null;
+ }).when(secondTrustee).setTrust(eq(ownIdentity), eq(new Trust(SCORE, null, 0)));
+ webOfTrustUpdater.setTrust(ownIdentity, trustee, SCORE, TRUST_COMMENT);
+ webOfTrustUpdater.setTrust(ownIdentity, secondTrustee, SCORE, TRUST_COMMENT);
+ webOfTrustUpdater.setTrust(ownIdentity, trustee, SCORE, TRUST_COMMENT);