2 * Sone - SonePartTest.java - Copyright © 2013 David Roden
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.
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.
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/>.
18 package net.pterodactylus.sone.text;
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;
25 import net.pterodactylus.sone.data.Mocks;
26 import net.pterodactylus.sone.data.Sone;
28 import org.junit.Test;
31 * Unit test for {@link SonePart}.
33 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
35 public class SonePartTest {
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);
42 public void sonePartIsNotAPlainTextPart() {
43 assertThat(sonePart.isPlainText(), is(false));
47 public void sonePartIsNotAFreenetLink() {
48 assertThat(sonePart.isFreenetLink(), is(false));
52 public void sonePartCanStoreAndReturnSone() {
53 assertThat(sonePart.getSone(), is(sone));
57 public void sonePartTextIsTheNiceNameOfTheSone() {
58 assertThat(sonePart.getText(), is(getNiceName(sone)));
62 public void twoSonePartsAreEqualIfTheirSonesAreEqual() {
63 SonePart secondSonePart = new SonePart(sone);
64 assertThat(sonePart, is(secondSonePart));
68 public void equalSonePartsHaveEqualHashCodes() {
69 SonePart secondSonePart = new SonePart(sone);
70 assertThat(sonePart.hashCode(), is(secondSonePart.hashCode()));
74 public void nullIsNotEqualToASonePart() {
75 assertThat(sonePart, not(is((Object) null)));