Replace Fetched with Kotlin version
[Sone.git] / src / test / java / net / pterodactylus / sone / text / TextFilterTest.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.hamcrest.MatcherAssert;
7 import org.hamcrest.Matchers;
8 import org.junit.Test;
9
10 /**
11  * JUnit test for {@link TextFilter}.
12  *
13  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
14  */
15 public class TextFilterTest {
16
17         @Test
18         public void textFilterCanBeCreated() {
19                 new TextFilter();
20         }
21
22         @Test
23         public void textFilterRemovesHttpLinkToSameHost() {
24                 String textWithHttpLink = "Some text with an http://foo.bar/link.html in it.";
25                 assertThat(TextFilter.filter("foo.bar", textWithHttpLink), is("Some text with an link.html in it."));
26         }
27
28         @Test
29         public void textFilterRemovesHttpsLinkToSameHost() {
30                 String textWithHttpLink = "Some text with an https://foo.bar/link.html in it.";
31                 assertThat(TextFilter.filter("foo.bar", textWithHttpLink), is("Some text with an link.html in it."));
32         }
33
34         @Test
35         public void textWithoutALinkIsReturnedUnmodified() {
36                 String textWithHttpLink = "Some text without a link in it.";
37                 assertThat(TextFilter.filter("foo.bar", textWithHttpLink), is("Some text without a link in it."));
38         }
39
40         @Test
41         public void nothingIsRemovedWhenThereIsNoHostHeader() {
42                 String textWithHttpLink = "Some text with an https://foo.bar/link.html in it.";
43                 assertThat(TextFilter.filter(null, textWithHttpLink), is("Some text with an https://foo.bar/link.html in it."));
44         }
45
46         @Test
47         public void textFilterDoesNotRemoveLinksToDifferentHost() {
48                 String textWithHttpLink = "Some text with an https://foo.bar/link.html in it.";
49                 assertThat(TextFilter.filter("bar.baz", textWithHttpLink), is("Some text with an https://foo.bar/link.html in it."));
50         }
51
52 }