mirror of
https://github.com/correl/mage.git
synced 2024-11-28 11:09:54 +00: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"));
|
||||
}
|
||||
|
||||
}
|
|
@ -3,7 +3,7 @@ package org.mage.test.clientside.bdd;
|
|||
import org.junit.Assert;
|
||||
import org.mage.test.clientside.base.Command;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static junit.framework.TestCase.*;
|
||||
|
||||
/**
|
||||
* Asserts expecting exception.
|
||||
|
@ -15,7 +15,7 @@ public class Expect {
|
|||
try {
|
||||
command.execute();
|
||||
} catch (Throwable e) {
|
||||
Assert.assertThat(t.getName(), is(e.getClass().getName()));
|
||||
assertEquals(e.getClass().getName(), t.getName())
|
||||
return;
|
||||
}
|
||||
throw new AssertionError("Expected exception wasn't thrown: " + t.getName());
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.mage.test.clientside.base.MageAPI;
|
|||
import org.mage.test.clientside.base.MageBase;
|
||||
import org.mage.test.clientside.bdd.StepState;
|
||||
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static junit.framework.TestCase.*;
|
||||
|
||||
public class Graveyards {
|
||||
private StepState step;
|
||||
|
@ -16,7 +16,7 @@ public class Graveyards {
|
|||
StepState current = MageAPI.defineStep(this.step);
|
||||
if (current.equals(StepState.THEN)) {
|
||||
boolean empty = MageBase.getInstance().checkGraveyardsEmpty();
|
||||
Assert.assertThat(empty, is(true));
|
||||
assertTrue(empty);
|
||||
return empty;
|
||||
} else {
|
||||
throw new AssertionError("Not implemented for step="+current);
|
||||
|
|
|
@ -7,8 +7,7 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
|
|||
import static mage.constants.PhaseStep.*;
|
||||
import static mage.constants.Zone.BATTLEFIELD;
|
||||
import static mage.constants.Zone.HAND;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class BroodOfCockroachesTest extends CardTestPlayerBase {
|
||||
|
||||
|
@ -27,7 +26,7 @@ public class BroodOfCockroachesTest extends CardTestPlayerBase {
|
|||
execute();
|
||||
|
||||
Permanent permanent = getPermanent(BROOD_OF_COCKROACHES, playerA);
|
||||
assertThat(permanent.getAbilities().get(1).toString(), is(expectedText));
|
||||
assertEquals(expectedText, permanent.getAbilities().get(1).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -10,8 +10,6 @@ import java.util.ArrayList;
|
|||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
|
||||
/**
|
||||
* Created by IGOUDT on 25-2-2017.
|
||||
*/
|
||||
|
@ -22,6 +20,6 @@ public class ContinuousEffectImplTest {
|
|||
BoostTargetEffect ghe = new BoostTargetEffect(0,0, Duration.Custom);
|
||||
ghe.setDependedToType(DependencyType.AuraAddingRemoving);
|
||||
Set<UUID> x = ghe.isDependentTo(new ArrayList<>());
|
||||
Assert.assertThat(x.size(), is(0));
|
||||
Assert.assertEquals(0, x.size());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue