mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +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.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.hamcrest.core.Is.is;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
|
|
||||||
public class MagePreferencesTest {
|
public class MagePreferencesTest {
|
||||||
@Before
|
@Before
|
||||||
|
@ -20,28 +19,28 @@ public class MagePreferencesTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIgnoreList() throws Exception {
|
public void testIgnoreList() throws Exception {
|
||||||
assertThat(MagePreferences.ignoreList("test.com.xx").size(), is(0));
|
assertEquals(0, MagePreferences.ignoreList("test.com.xx").size());
|
||||||
assertThat(MagePreferences.removeIgnoredUser("test.com.xx", "test"), is(false));
|
assertFalse(MagePreferences.removeIgnoredUser("test.com.xx", "test"));
|
||||||
|
|
||||||
MagePreferences.addIgnoredUser("test.com.xx", "test");
|
MagePreferences.addIgnoredUser("test.com.xx", "test");
|
||||||
assertThat(MagePreferences.ignoreList("test.com.xx").size(), is(1));
|
assertEquals(1, MagePreferences.ignoreList("test.com.xx").size());
|
||||||
assertThat(MagePreferences.ignoreList("other.com.xx").size(), is(0));
|
assertEquals(0, MagePreferences.ignoreList("other.com.xx").size());
|
||||||
|
|
||||||
MagePreferences.addIgnoredUser("test.com.xx", "lul");
|
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));
|
assertTrue(MagePreferences.ignoreList("test.com.xx").contains("test"));
|
||||||
assertThat(MagePreferences.ignoreList("test.com.xx").contains("lul"), is(true));
|
assertTrue(MagePreferences.ignoreList("test.com.xx").contains("lul"));
|
||||||
|
|
||||||
assertThat(MagePreferences.removeIgnoredUser("test.com.xx", "test"), is(true));
|
assertTrue(MagePreferences.removeIgnoredUser("test.com.xx", "test"));
|
||||||
assertThat(MagePreferences.removeIgnoredUser("test.com.xx", "test"), is(false));
|
assertFalse(MagePreferences.removeIgnoredUser("test.com.xx", "test"));
|
||||||
assertThat(MagePreferences.ignoreList("test.com.xx").size(), is(1));
|
assertEquals(1, MagePreferences.ignoreList("test.com.xx").size());
|
||||||
|
|
||||||
assertThat(MagePreferences.removeIgnoredUser("test.com.xx", "lul"), is(true));
|
assertTrue(MagePreferences.removeIgnoredUser("test.com.xx", "lul"));
|
||||||
assertThat(MagePreferences.removeIgnoredUser("test.com.xx", "lul"), is(false));
|
assertFalse(MagePreferences.removeIgnoredUser("test.com.xx", "lul"));
|
||||||
assertThat(MagePreferences.ignoreList("test.com.xx").size(), is(0));
|
assertEquals(0, MagePreferences.ignoreList("test.com.xx").size());
|
||||||
|
|
||||||
assertThat(MagePreferences.ignoreList("test.com.xx").contains("test"), is(false));
|
assertFalse(MagePreferences.ignoreList("test.com.xx").contains("test"));
|
||||||
assertThat(MagePreferences.ignoreList("test.com.xx").contains("lul"), is(false));
|
assertFalse(MagePreferences.ignoreList("test.com.xx").contains("lul"));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,9 +5,7 @@ import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static junit.framework.TestCase.*;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.core.Is.is;
|
|
||||||
|
|
||||||
public class IgnoreListTest {
|
public class IgnoreListTest {
|
||||||
|
|
||||||
|
@ -23,42 +21,69 @@ public class IgnoreListTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ignoreListEmpty() throws Exception {
|
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
|
@Test
|
||||||
public void ignoreList() throws Exception {
|
public void ignoreList() throws Exception {
|
||||||
final String test = IgnoreList.ignore("test.com.xx", "test");
|
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");
|
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>"));
|
assertEquals(kranken, "Added kranken to your ignore list on test.com.xx (total: 2)");
|
||||||
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(IgnoreList.getIgnoreListInfo("test.com.xx"), "<font color=yellow>Current ignore list on test.com.xx (total: 2): [kranken, test]</font>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ignore() throws Exception {
|
public void ignore() throws Exception {
|
||||||
assertThat(IgnoreList.userIsIgnored("test.com.xx", "kranken"), is(false));
|
ignore_a_user("kranken");
|
||||||
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)");
|
/**
|
||||||
|
* 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
|
@Test
|
||||||
public void ignoreAgain() throws Exception {
|
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");
|
IgnoreList.ignore("test.com.xx", "kranken");
|
||||||
final String r = IgnoreList.ignore("test.com.xx", "kranken");
|
|
||||||
assertThat(IgnoreList.userIsIgnored("test.com.xx", "kranken"), is(true));
|
final String response = IgnoreList.ignore("test.com.xx", "kranken");
|
||||||
assertEquals(r, "kranken is already on your ignore list on test.com.xx");
|
assertEquals(response, "kranken is already on your ignore list on test.com.xx");
|
||||||
|
|
||||||
|
assertTrue(IgnoreList.userIsIgnored("test.com.xx", "kranken"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ignoreDefaultResponse() throws Exception {
|
public void ignoreDefaultResponse() throws Exception {
|
||||||
final String r1 = IgnoreList.ignore("test.com.xx", "");
|
final String response1 = IgnoreList.ignore("test.com.xx", "");
|
||||||
final String r2 = IgnoreList.ignore("test.com.xx", null);
|
final String response2 = 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(response1, response2);
|
||||||
assertEquals(r1, r2);
|
assertEquals(response2, "<font color=yellow>Current ignore list on test.com.xx (total: 0): []</font>");
|
||||||
assertEquals(r2, "<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
|
@Test
|
||||||
|
@ -66,20 +91,22 @@ public class IgnoreListTest {
|
||||||
for (int i = 0; i < 500; i++) {
|
for (int i = 0; i < 500; i++) {
|
||||||
IgnoreList.ignore("test.com.xx", "" + i);
|
IgnoreList.ignore("test.com.xx", "" + i);
|
||||||
}
|
}
|
||||||
final String r = IgnoreList.ignore("test.com.xx", "lul");
|
final String response = 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.");
|
assertEquals(response, "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));
|
|
||||||
|
assertEquals(IgnoreList.getIgnoredUsers("test.com.xx").size(), 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void unignore() throws Exception {
|
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");
|
IgnoreList.ignore("test.com.xx", "kranken");
|
||||||
assertThat(IgnoreList.userIsIgnored("test.com.xx", "kranken"), is(true));
|
assertTrue(IgnoreList.userIsIgnored("test.com.xx", "kranken"));
|
||||||
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)");
|
|
||||||
|
|
||||||
|
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.junit.Assert;
|
||||||
import org.mage.test.clientside.base.Command;
|
import org.mage.test.clientside.base.Command;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static junit.framework.TestCase.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts expecting exception.
|
* Asserts expecting exception.
|
||||||
|
@ -15,7 +15,7 @@ public class Expect {
|
||||||
try {
|
try {
|
||||||
command.execute();
|
command.execute();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Assert.assertThat(t.getName(), is(e.getClass().getName()));
|
assertEquals(e.getClass().getName(), t.getName())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new AssertionError("Expected exception wasn't thrown: " + t.getName());
|
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.base.MageBase;
|
||||||
import org.mage.test.clientside.bdd.StepState;
|
import org.mage.test.clientside.bdd.StepState;
|
||||||
|
|
||||||
import static org.hamcrest.core.Is.is;
|
import static junit.framework.TestCase.*;
|
||||||
|
|
||||||
public class Graveyards {
|
public class Graveyards {
|
||||||
private StepState step;
|
private StepState step;
|
||||||
|
@ -16,7 +16,7 @@ public class Graveyards {
|
||||||
StepState current = MageAPI.defineStep(this.step);
|
StepState current = MageAPI.defineStep(this.step);
|
||||||
if (current.equals(StepState.THEN)) {
|
if (current.equals(StepState.THEN)) {
|
||||||
boolean empty = MageBase.getInstance().checkGraveyardsEmpty();
|
boolean empty = MageBase.getInstance().checkGraveyardsEmpty();
|
||||||
Assert.assertThat(empty, is(true));
|
assertTrue(empty);
|
||||||
return empty;
|
return empty;
|
||||||
} else {
|
} else {
|
||||||
throw new AssertionError("Not implemented for step="+current);
|
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.PhaseStep.*;
|
||||||
import static mage.constants.Zone.BATTLEFIELD;
|
import static mage.constants.Zone.BATTLEFIELD;
|
||||||
import static mage.constants.Zone.HAND;
|
import static mage.constants.Zone.HAND;
|
||||||
import static org.hamcrest.core.Is.is;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
|
|
||||||
public class BroodOfCockroachesTest extends CardTestPlayerBase {
|
public class BroodOfCockroachesTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
|
@ -27,7 +26,7 @@ public class BroodOfCockroachesTest extends CardTestPlayerBase {
|
||||||
execute();
|
execute();
|
||||||
|
|
||||||
Permanent permanent = getPermanent(BROOD_OF_COCKROACHES, playerA);
|
Permanent permanent = getPermanent(BROOD_OF_COCKROACHES, playerA);
|
||||||
assertThat(permanent.getAbilities().get(1).toString(), is(expectedText));
|
assertEquals(expectedText, permanent.getAbilities().get(1).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -10,8 +10,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by IGOUDT on 25-2-2017.
|
* Created by IGOUDT on 25-2-2017.
|
||||||
*/
|
*/
|
||||||
|
@ -22,6 +20,6 @@ public class ContinuousEffectImplTest {
|
||||||
BoostTargetEffect ghe = new BoostTargetEffect(0,0, Duration.Custom);
|
BoostTargetEffect ghe = new BoostTargetEffect(0,0, Duration.Custom);
|
||||||
ghe.setDependedToType(DependencyType.AuraAddingRemoving);
|
ghe.setDependedToType(DependencyType.AuraAddingRemoving);
|
||||||
Set<UUID> x = ghe.isDependentTo(new ArrayList<>());
|
Set<UUID> x = ghe.isDependentTo(new ArrayList<>());
|
||||||
Assert.assertThat(x.size(), is(0));
|
Assert.assertEquals(0, x.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue