mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 04:42:07 -08:00
Clean up tests by removing deprecated calls to assertThat and unnecessary use of hamcrest
This commit is contained in:
parent
8d324692b0
commit
98580b08ff
6 changed files with 79 additions and 56 deletions
|
|
@ -4,8 +4,7 @@ import org.junit.After;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class MagePreferencesTest {
|
||||
@Before
|
||||
|
|
@ -20,28 +19,28 @@ public class MagePreferencesTest {
|
|||
|
||||
@Test
|
||||
public void testIgnoreList() throws Exception {
|
||||
assertThat(MagePreferences.ignoreList("test.com.xx").size(), is(0));
|
||||
assertThat(MagePreferences.removeIgnoredUser("test.com.xx", "test"), is(false));
|
||||
assertEquals(0, MagePreferences.ignoreList("test.com.xx").size());
|
||||
assertFalse(MagePreferences.removeIgnoredUser("test.com.xx", "test"));
|
||||
|
||||
MagePreferences.addIgnoredUser("test.com.xx", "test");
|
||||
assertThat(MagePreferences.ignoreList("test.com.xx").size(), is(1));
|
||||
assertThat(MagePreferences.ignoreList("other.com.xx").size(), is(0));
|
||||
assertEquals(1, MagePreferences.ignoreList("test.com.xx").size());
|
||||
assertEquals(0, MagePreferences.ignoreList("other.com.xx").size());
|
||||
|
||||
MagePreferences.addIgnoredUser("test.com.xx", "lul");
|
||||
assertThat(MagePreferences.ignoreList("test.com.xx").size(), is(2));
|
||||
assertEquals(2, MagePreferences.ignoreList("test.com.xx").size());
|
||||
|
||||
assertThat(MagePreferences.ignoreList("test.com.xx").contains("test"), is(true));
|
||||
assertThat(MagePreferences.ignoreList("test.com.xx").contains("lul"), is(true));
|
||||
assertTrue(MagePreferences.ignoreList("test.com.xx").contains("test"));
|
||||
assertTrue(MagePreferences.ignoreList("test.com.xx").contains("lul"));
|
||||
|
||||
assertThat(MagePreferences.removeIgnoredUser("test.com.xx", "test"), is(true));
|
||||
assertThat(MagePreferences.removeIgnoredUser("test.com.xx", "test"), is(false));
|
||||
assertThat(MagePreferences.ignoreList("test.com.xx").size(), is(1));
|
||||
assertTrue(MagePreferences.removeIgnoredUser("test.com.xx", "test"));
|
||||
assertFalse(MagePreferences.removeIgnoredUser("test.com.xx", "test"));
|
||||
assertEquals(1, MagePreferences.ignoreList("test.com.xx").size());
|
||||
|
||||
assertThat(MagePreferences.removeIgnoredUser("test.com.xx", "lul"), is(true));
|
||||
assertThat(MagePreferences.removeIgnoredUser("test.com.xx", "lul"), is(false));
|
||||
assertThat(MagePreferences.ignoreList("test.com.xx").size(), is(0));
|
||||
assertTrue(MagePreferences.removeIgnoredUser("test.com.xx", "lul"));
|
||||
assertFalse(MagePreferences.removeIgnoredUser("test.com.xx", "lul"));
|
||||
assertEquals(0, MagePreferences.ignoreList("test.com.xx").size());
|
||||
|
||||
assertThat(MagePreferences.ignoreList("test.com.xx").contains("test"), is(false));
|
||||
assertThat(MagePreferences.ignoreList("test.com.xx").contains("lul"), is(false));
|
||||
assertFalse(MagePreferences.ignoreList("test.com.xx").contains("test"));
|
||||
assertFalse(MagePreferences.ignoreList("test.com.xx").contains("lul"));
|
||||
}
|
||||
}
|
||||
|
|
@ -5,9 +5,7 @@ import org.junit.After;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static junit.framework.TestCase.*;
|
||||
|
||||
public class IgnoreListTest {
|
||||
|
||||
|
|
@ -23,42 +21,69 @@ public class IgnoreListTest {
|
|||
|
||||
@Test
|
||||
public void ignoreListEmpty() throws Exception {
|
||||
assertThat(IgnoreList.getIgnoreListInfo("test.com.xx"), is("<font color=yellow>Current ignore list on test.com.xx (total: 0): []</font>"));
|
||||
assertEquals(IgnoreList.getIgnoreListInfo("test.com.xx"), "<font color=yellow>Current ignore list on test.com.xx (total: 0): []</font>");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ignoreList() throws Exception {
|
||||
final String test = IgnoreList.ignore("test.com.xx", "test");
|
||||
assertEquals(test, "Added test to your ignore list on test.com.xx (total: 1)");
|
||||
|
||||
final String kranken = IgnoreList.ignore("test.com.xx", "kranken");
|
||||
assertThat(IgnoreList.getIgnoreListInfo("test.com.xx"), is("<font color=yellow>Current ignore list on test.com.xx (total: 2): [kranken, test]</font>"));
|
||||
assertThat(test, is("Added test to your ignore list on test.com.xx (total: 1)"));
|
||||
assertThat(kranken, is("Added kranken to your ignore list on test.com.xx (total: 2)"));
|
||||
assertEquals(kranken, "Added kranken to your ignore list on test.com.xx (total: 2)");
|
||||
|
||||
assertEquals(IgnoreList.getIgnoreListInfo("test.com.xx"), "<font color=yellow>Current ignore list on test.com.xx (total: 2): [kranken, test]</font>");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ignore() throws Exception {
|
||||
assertThat(IgnoreList.userIsIgnored("test.com.xx", "kranken"), is(false));
|
||||
final String r = IgnoreList.ignore("test.com.xx", "kranken");
|
||||
assertThat(IgnoreList.userIsIgnored("test.com.xx", "kranken"), is(true));
|
||||
assertEquals(r, "Added kranken to your ignore list on test.com.xx (total: 1)");
|
||||
ignore_a_user("kranken");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reported bug: https://github.com/magefree/mage/issues/9682
|
||||
*/
|
||||
@Test
|
||||
public void ignoreNameWithSpaces() {
|
||||
ignore_a_user("test test test");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reported bug: https://github.com/magefree/mage/issues/9682
|
||||
*/
|
||||
@Test
|
||||
public void ignoreSpaceName() {
|
||||
ignore_a_user(" ");
|
||||
}
|
||||
|
||||
private void ignore_a_user(String username) {
|
||||
assertFalse(IgnoreList.userIsIgnored("test.com.xx", username));
|
||||
|
||||
final String responce = IgnoreList.ignore("test.com.xx", username);
|
||||
assertEquals(responce, "Added " + username + " to your ignore list on test.com.xx (total: 1)");
|
||||
|
||||
assertTrue(IgnoreList.userIsIgnored("test.com.xx", username));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ignoreAgain() throws Exception {
|
||||
assertThat(IgnoreList.userIsIgnored("test.com.xx", "kranken"), is(false));
|
||||
assertFalse(IgnoreList.userIsIgnored("test.com.xx", "kranken"));
|
||||
IgnoreList.ignore("test.com.xx", "kranken");
|
||||
final String r = IgnoreList.ignore("test.com.xx", "kranken");
|
||||
assertThat(IgnoreList.userIsIgnored("test.com.xx", "kranken"), is(true));
|
||||
assertEquals(r, "kranken is already on your ignore list on test.com.xx");
|
||||
|
||||
final String response = IgnoreList.ignore("test.com.xx", "kranken");
|
||||
assertEquals(response, "kranken is already on your ignore list on test.com.xx");
|
||||
|
||||
assertTrue(IgnoreList.userIsIgnored("test.com.xx", "kranken"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ignoreDefaultResponse() throws Exception {
|
||||
final String r1 = IgnoreList.ignore("test.com.xx", "");
|
||||
final String r2 = IgnoreList.ignore("test.com.xx", null);
|
||||
assertThat(IgnoreList.getIgnoreListInfo("test.com.xx"), is("<font color=yellow>Current ignore list on test.com.xx (total: 0): []</font>"));
|
||||
assertEquals(r1, r2);
|
||||
assertEquals(r2, "<font color=yellow>Current ignore list on test.com.xx (total: 0): []</font>");
|
||||
final String response1 = IgnoreList.ignore("test.com.xx", "");
|
||||
final String response2 = IgnoreList.ignore("test.com.xx", null);
|
||||
assertEquals(response1, response2);
|
||||
assertEquals(response2, "<font color=yellow>Current ignore list on test.com.xx (total: 0): []</font>");
|
||||
|
||||
assertEquals(IgnoreList.getIgnoreListInfo("test.com.xx"), "<font color=yellow>Current ignore list on test.com.xx (total: 0): []</font>");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -66,20 +91,22 @@ public class IgnoreListTest {
|
|||
for (int i = 0; i < 500; i++) {
|
||||
IgnoreList.ignore("test.com.xx", "" + i);
|
||||
}
|
||||
final String r = IgnoreList.ignore("test.com.xx", "lul");
|
||||
assertEquals(r, "Your ignore list is too big (max 500), remove a user to be able to add a new one.");
|
||||
assertThat(IgnoreList.getIgnoredUsers("test.com.xx").size(), is(500));
|
||||
final String response = IgnoreList.ignore("test.com.xx", "lul");
|
||||
assertEquals(response, "Your ignore list is too big (max 500), remove a user to be able to add a new one.");
|
||||
|
||||
assertEquals(IgnoreList.getIgnoredUsers("test.com.xx").size(), 500);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unignore() throws Exception {
|
||||
assertThat(IgnoreList.userIsIgnored("test.com.xx", "kranken"), is(false));
|
||||
assertFalse(IgnoreList.userIsIgnored("test.com.xx", "kranken"));
|
||||
|
||||
IgnoreList.ignore("test.com.xx", "kranken");
|
||||
assertThat(IgnoreList.userIsIgnored("test.com.xx", "kranken"), is(true));
|
||||
final String r = IgnoreList.unignore("test.com.xx", "kranken");
|
||||
assertThat(IgnoreList.userIsIgnored("test.com.xx", "kranken"), is(false));
|
||||
assertEquals(r, "Removed kranken from your ignore list on test.com.xx (total: 0)");
|
||||
assertTrue(IgnoreList.userIsIgnored("test.com.xx", "kranken"));
|
||||
|
||||
final String response = IgnoreList.unignore("test.com.xx", "kranken");
|
||||
assertEquals(response, "Removed kranken from your ignore list on test.com.xx (total: 0)");
|
||||
|
||||
assertFalse(IgnoreList.userIsIgnored("test.com.xx", "kranken"));
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue