- public void setTrustJobSetsTrust() throws PluginException {
- SetTrustJob setTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT);
- setTrustJob.run();
- verify(webOfTrustConnector).setTrust(eq(ownIdentity), eq(trustee), eq(SCORE), eq(TRUST_COMMENT));
- verify(trustee).setTrust(eq(ownIdentity), eq(new Trust(SCORE, null, 0)));
- assertThat(setTrustJob.waitForCompletion(), is(true));
- }
-
- @Test
- public void settingNullTrustRemovesTrust() throws WebOfTrustException {
- SetTrustJob setTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, null, TRUST_COMMENT);
- setTrustJob.run();
- verify(webOfTrustConnector).removeTrust(eq(ownIdentity), eq(trustee));
- verify(trustee).removeTrust(eq(ownIdentity));
- assertThat(setTrustJob.waitForCompletion(), is(true));
- }
-
- @Test
- public void exceptionWhileSettingTrustIsCaught() throws PluginException {
- doThrow(PluginException.class).when(webOfTrustConnector).setTrust(eq(ownIdentity), eq(trustee), eq(SCORE), eq(TRUST_COMMENT));
- SetTrustJob setTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT);
- setTrustJob.run();
- verify(webOfTrustConnector).setTrust(eq(ownIdentity), eq(trustee), eq(SCORE), eq(TRUST_COMMENT));
- verify(trustee, never()).setTrust(eq(ownIdentity), eq(new Trust(SCORE, null, 0)));
- assertThat(setTrustJob.waitForCompletion(), is(false));
- }
-
- @Test
- public void setTrustJobsWithDifferentClassesAreNotEqual() {
- SetTrustJob firstSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT);
- SetTrustJob secondSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT) {
- };
- assertThat(firstSetTrustJob, not(is(secondSetTrustJob)));
- assertThat(secondSetTrustJob, not(is(firstSetTrustJob)));
- }
-
- @Test
- public void setTrustJobsWithDifferentTrustersAreNotEqual() {
- SetTrustJob firstSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT);
- SetTrustJob secondSetTrustJob = webOfTrustUpdater.new SetTrustJob(mock(OwnIdentity.class), trustee, SCORE, TRUST_COMMENT);
- assertThat(firstSetTrustJob, not(is(secondSetTrustJob)));
- assertThat(secondSetTrustJob, not(is(firstSetTrustJob)));
- }
-
- @Test
- public void setTrustJobsWithDifferentTrusteesAreNotEqual() {
- SetTrustJob firstSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT);
- SetTrustJob secondSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, mock(Identity.class), SCORE, TRUST_COMMENT);
- assertThat(firstSetTrustJob, not(is(secondSetTrustJob)));
- assertThat(secondSetTrustJob, not(is(firstSetTrustJob)));
- }
-
- @Test
- public void setTrustJobsWithDifferentScoreAreEqual() {
- SetTrustJob firstSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT);
- SetTrustJob secondSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, OTHER_SCORE, TRUST_COMMENT);
- assertThat(firstSetTrustJob, is(secondSetTrustJob));
- assertThat(secondSetTrustJob, is(firstSetTrustJob));
- assertThat(firstSetTrustJob.hashCode(), is(secondSetTrustJob.hashCode()));
- }
-
- @Test
- public void setTrustJobDoesNotEqualNull() {
- SetTrustJob setTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT);
- assertThat(setTrustJob, not(is((Object) null)));
- }
-
- @Test
- public void toStringOfSetTrustJobContainsIdsOfTrusterAndTrustee() {
- SetTrustJob setTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT);
- assertThat(setTrustJob.toString(), containsString(ownIdentity.getId()));
- assertThat(setTrustJob.toString(), containsString(trustee.getId()));
- }
-
- @Test