Fixed tests

This commit is contained in:
Oleg Agafonov 2020-02-27 03:31:51 +04:00
parent 67cf4bc535
commit 32d61f6a69
2 changed files with 13 additions and 13 deletions

View file

@ -34,8 +34,8 @@ public final class IgnoreList {
public static String getIgnoreListInfo(String serverAddress) {
List<String> list = new ArrayList<>(getIgnoredUsers(serverAddress));
Collections.sort(list);
return "<font color=yellow>Current ignore list on " + serverAddress + " (" + list.size() + "): "
+ String.join(", ", list)
return "<font color=yellow>Current ignore list on " + serverAddress + " (total: " + list.size() + "): "
+ "[" + String.join(", ", list) + "]"
+ "</font>";
}

View file

@ -23,16 +23,16 @@ 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: []</font>"));
assertThat(IgnoreList.getIgnoreListInfo("test.com.xx"), is("<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");
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: [kranken, test]</font>"));
assertThat(test, is("Added test to your ignore list on test.com.xx"));
assertThat(kranken, is("Added kranken to your ignore list on test.com.xx"));
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)"));
}
@Test
@ -40,7 +40,7 @@ public class IgnoreListTest {
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");
assertEquals(r, "Added kranken to your ignore list on test.com.xx (total: 1)");
}
@Test
@ -56,19 +56,19 @@ public class IgnoreListTest {
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: []</font>"));
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: []</font>");
assertEquals(r2, "<font color=yellow>Current ignore list on test.com.xx (total: 0): []</font>");
}
@Test
public void ignoreMaxSize() throws Exception {
for (int i = 0; i < 50; i++) {
for (int i = 0; i < 100; i++) {
IgnoreList.ignore("test.com.xx", "" + i);
}
final String r = IgnoreList.ignore("test.com.xx", "lul");
assertEquals(r, "Your ignore list is too big, remove a user to be able to add a new one.");
assertThat(IgnoreList.getIgnoreListInfo("test.com.xx"), is("<font color=yellow>Current ignore list on test.com.xx: [0, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 3, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 4, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 5, 6, 7, 8, 9]</font>"));
assertEquals(r, "Your ignore list is too big (max 100), remove a user to be able to add a new one.");
assertThat(IgnoreList.getIgnoredUsers("test.com.xx").size(), is(100));
}
@Test
@ -78,7 +78,7 @@ public class IgnoreListTest {
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");
assertEquals(r, "Removed kranken from your ignore list on test.com.xx (total: 0)");
}