Add tests for isFreenetLink() and isPlainText().
[Sone.git] / src / test / java / net / pterodactylus / sone / text / SonePartTest.java
1 /*
2  * Sone - SonePartTest.java - Copyright © 2013 David Roden
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 package net.pterodactylus.sone.text;
19
20 import static net.pterodactylus.sone.template.SoneAccessor.getNiceName;
21 import static org.hamcrest.MatcherAssert.assertThat;
22 import static org.hamcrest.Matchers.is;
23 import static org.hamcrest.Matchers.not;
24
25 import net.pterodactylus.sone.data.Mocks;
26 import net.pterodactylus.sone.data.Sone;
27
28 import org.junit.Test;
29
30 /**
31  * Unit test for {@link SonePart}.
32  *
33  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
34  */
35 public class SonePartTest {
36
37         private final Mocks mocks = new Mocks();
38         private final Sone sone = mocks.mockSone("Sone").withName("NiceSone").withProfileName("N.", "Ice", "Name").create();
39         private final SonePart sonePart = new SonePart(sone);
40
41         @Test
42         public void sonePartIsNotAPlainTextPart() {
43                 assertThat(sonePart.isPlainText(), is(false));
44         }
45
46         @Test
47         public void sonePartIsNotAFreenetLink() {
48                 assertThat(sonePart.isFreenetLink(), is(false));
49         }
50
51         @Test
52         public void sonePartCanStoreAndReturnSone() {
53                 assertThat(sonePart.getSone(), is(sone));
54         }
55
56         @Test
57         public void sonePartTextIsTheNiceNameOfTheSone() {
58                 assertThat(sonePart.getText(), is(getNiceName(sone)));
59         }
60
61         @Test
62         public void twoSonePartsAreEqualIfTheirSonesAreEqual() {
63                 SonePart secondSonePart = new SonePart(sone);
64                 assertThat(sonePart, is(secondSonePart));
65         }
66
67         @Test
68         public void equalSonePartsHaveEqualHashCodes() {
69                 SonePart secondSonePart = new SonePart(sone);
70                 assertThat(sonePart.hashCode(), is(secondSonePart.hashCode()));
71         }
72
73         @Test
74         public void nullIsNotEqualToASonePart() {
75                 assertThat(sonePart, not(is((Object) null)));
76         }
77
78 }