62648a1638fa3a8262f8016cc6c4077222bfbcaf
[Sone.git] / src / test / java / net / pterodactylus / sone / text / LinkPartTest.java
1 package net.pterodactylus.sone.text;
2
3 import static org.hamcrest.MatcherAssert.assertThat;
4 import static org.hamcrest.Matchers.is;
5
6 import org.junit.Test;
7
8 /**
9  * Unit test for {@link LinkPart}.
10  *
11  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
12  */
13 public class LinkPartTest {
14
15         private final LinkPart part = new LinkPart("link", "text", "title");
16
17         @Test
18         public void linkIsRetainedCorrectly() {
19                 assertThat(part.getLink(), is("link"));
20         }
21
22         @Test
23         public void textIsRetainedCorrectly() {
24                 assertThat(part.getText(), is("text"));
25         }
26
27         @Test
28         public void titleIsRetainedCorrectly() {
29                 assertThat(part.getTitle(), is("title"));
30         }
31
32         @Test
33         public void linkIsUsedAsTitleIfNoTitleIsGiven() {
34                 assertThat(new LinkPart("link", "text").getTitle(), is("link"));
35         }
36
37         @Test(expected = NullPointerException.class)
38         public void nullIsNotAllowedForLink() {
39                 new LinkPart(null, "text", "title");
40         }
41
42         @Test(expected = NullPointerException.class)
43         public void nullIsNotAllowedForText() {
44                 new LinkPart("link", null, "title");
45         }
46
47         @Test(expected = NullPointerException.class)
48         public void nullIsNotAllowedForLinkInSecondaryConstructor() {
49                 new LinkPart(null, "text");
50         }
51
52         @Test(expected = NullPointerException.class)
53         public void nullIsNotAllowedForTextInSecondaryConstructor() {
54                 new LinkPart("link", null);
55         }
56
57         @Test(expected = NullPointerException.class)
58         public void nullIsNotAllowedForTitle() {
59                 new LinkPart("link", "text", null);
60         }
61
62 }