1 package net.pterodactylus.sone.text;
3 import static org.hamcrest.MatcherAssert.assertThat;
4 import static org.hamcrest.Matchers.is;
9 * Unit test for {@link FreenetLinkPart}.
11 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
13 public class FreenetLinkPartTest {
15 private final FreenetLinkPart part = new FreenetLinkPart("link", "text", "title", true);
18 public void linkIsRetainedCorrectly() {
19 assertThat(part.getLink(), is("link"));
23 public void textIsRetainedCorrectly() {
24 assertThat(part.getText(), is("text"));
28 public void titleIsRetainedCorrectly() {
29 assertThat(part.getTitle(), is("title"));
33 public void trustedIsRetainedCorrectly() {
34 assertThat(part.isTrusted(), is(true));
38 public void textIsUsedAsTitleIfNoTextIsGiven() {
39 assertThat(new FreenetLinkPart("link", "text", true).getTitle(), is("text"));
42 @Test(expected = NullPointerException.class)
43 public void nullIsNotAllowedForLink() {
44 new FreenetLinkPart(null, "text", "title", true);
47 @Test(expected = NullPointerException.class)
48 public void nullIsNotAllowedForText() {
49 new FreenetLinkPart("link", null, "title", true);
52 @Test(expected = NullPointerException.class)
53 public void nullIsNotAllowedForLinkInSecondaryConstructor() {
54 new FreenetLinkPart(null, "text", true);
57 @Test(expected = NullPointerException.class)
58 public void nullIsNotAllowedForTextInSecondaryConstructor() {
59 new FreenetLinkPart("link", null, true);
62 @Test(expected = NullPointerException.class)
63 public void nullIsNotAllowedForTitle() {
64 new FreenetLinkPart("link", "text", null, true);