1 package net.pterodactylus.sone.data.impl;
3 import static org.mockito.Mockito.mock;
5 import net.pterodactylus.sone.data.Client;
6 import net.pterodactylus.sone.data.Sone;
7 import net.pterodactylus.sone.freenet.wot.Identity;
8 import net.pterodactylus.sone.freenet.wot.OwnIdentity;
10 import org.junit.Test;
13 * Unit test for {@link AbstractSoneBuilder}.
15 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
17 public class AbstractSoneBuilderTest {
19 private final AbstractSoneBuilder soneBuilder = new AbstractSoneBuilder() {
21 public Sone build() throws IllegalStateException {
26 private final Client client = new Client("Test Client", "1.0");
29 public void localSoneIsValidated() {
30 Identity ownIdentity = mock(OwnIdentity.class);
31 soneBuilder.local().from(ownIdentity).lastUpdated(1).using(client).build();
34 @Test(expected = IllegalStateException.class)
35 public void localSoneIsNotValidatedIfIdentityIsNotAnOwnIdentity() {
36 Identity identity = mock(Identity.class);
37 soneBuilder.local().from(identity).lastUpdated(1).using(client).build();
40 @Test(expected = IllegalStateException.class)
41 public void localSoneIsNotValidatedIfIdentityIsNull() {
42 soneBuilder.local().lastUpdated(1).using(client).build();
46 public void remoteSoneIsValidated() {
47 Identity identity = mock(Identity.class);
48 soneBuilder.from(identity).lastUpdated(1).using(client).build();
51 @Test(expected = IllegalStateException.class)
52 public void remoteSoneIsNotValidatedIfIdentityIsNull() {
53 soneBuilder.lastUpdated(1).using(client).build();
56 @Test(expected = IllegalStateException.class)
57 public void localSoneIsNotValidatedWithoutUpdateTime() {
58 Identity identity = mock(OwnIdentity.class);
59 soneBuilder.from(identity).local().using(client).build();
62 @Test(expected = IllegalStateException.class)
63 public void remoteSoneIsNotValidatedWithoutUpdateTime() {
64 Identity identity = mock(Identity.class);
65 soneBuilder.from(identity).using(client).build();
68 @Test(expected = IllegalStateException.class)
69 public void localSoneIsNotValidatedWithoutClient() {
70 Identity identity = mock(OwnIdentity.class);
71 soneBuilder.from(identity).local().lastUpdated(1L).build();
74 @Test(expected = IllegalStateException.class)
75 public void remoteSoneIsNotValidatedWithoutClient() {
76 Identity identity = mock(Identity.class);
77 soneBuilder.from(identity).lastUpdated(1L).build();