Skip to content

Commit

Permalink
Address deprecation warnings in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PseudoKnight committed Dec 16, 2020
1 parent af47c7d commit cce9d74
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 19 deletions.
Expand Up @@ -17,10 +17,10 @@
import org.junit.BeforeClass;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;

/**
*
Expand Down
Expand Up @@ -6,8 +6,8 @@
package com.laytonsmith.PureUtilities.Common;

import org.junit.Test;
import static org.junit.Assert.*;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.MatcherAssert.assertThat;

/**
*
Expand Down
Expand Up @@ -8,10 +8,10 @@
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import org.junit.Before;

/**
Expand Down
15 changes: 8 additions & 7 deletions src/test/java/com/laytonsmith/PureUtilities/JSONUtilTest.java
Expand Up @@ -9,6 +9,7 @@
import java.util.HashMap;
import java.util.Map;
import org.hamcrest.core.Is;
import org.hamcrest.MatcherAssert;
import org.junit.Assert;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertArrayEquals;
Expand Down Expand Up @@ -197,7 +198,7 @@ public void testSerialize() throws Exception {
d.s.b = true;
d.s.i = 5;
String s = jd.serialize(d);
Assert.assertThat(s, Is.is("{\"s\":{\"b\":true,\"i\":5},\"m\":\"string\"}"));
MatcherAssert.assertThat(s, Is.is("{\"s\":{\"b\":true,\"i\":5},\"m\":\"string\"}"));
}

@Test
Expand All @@ -207,7 +208,7 @@ public void testSerializeArray() throws Exception {
a.I = new Integer[]{};
a.s = new String[]{"s", "t", "r"};
String s = jd.serialize(a);
Assert.assertThat(s, Is.is("{\"s\":[\"s\",\"t\",\"r\"],\"i\":[1,2,3],\"I\":[]}"));
MatcherAssert.assertThat(s, Is.is("{\"s\":[\"s\",\"t\",\"r\"],\"i\":[1,2,3],\"I\":[]}"));
}

static enum EnumTest {
Expand All @@ -232,7 +233,7 @@ public void testEnumSerialization() throws Exception {
c.id = 45;
c.enumValue = EnumTest.ONE;
String s = jd.serialize(c);
Assert.assertThat(s, Is.is("{\"enumValue\":1,\"id\":45}"));
MatcherAssert.assertThat(s, Is.is("{\"enumValue\":1,\"id\":45}"));
}

static enum EnumTest2 implements JSONUtil.CustomLongEnum<EnumTest2> {
Expand Down Expand Up @@ -280,7 +281,7 @@ public void testEnumSerializationCustom() throws Exception {
c.id = 45;
c.et = EnumTest2.FIRST;
String s = jd.serialize(c);
Assert.assertThat(s, Is.is("{\"id\":45,\"et\":100}"));
MatcherAssert.assertThat(s, Is.is("{\"id\":45,\"et\":100}"));
}

static class MapContainer {
Expand All @@ -295,14 +296,14 @@ public void testMapSerialization() throws Exception {
mc.map.put("one", "one");
mc.map.put("two", "two");
String s = jd.serialize(mc);
Assert.assertThat(s, Is.is("{\"map\":{\"two\":\"two\",\"one\":\"one\"}}"));
MatcherAssert.assertThat(s, Is.is("{\"map\":{\"two\":\"two\",\"one\":\"one\"}}"));
}

@Test
public void testMapDeserialization() throws Exception {
MapContainer mc = jd.deserialize("{\"map\":{\"two\":\"two\",\"one\":\"one\"}}", MapContainer.class);
Assert.assertNotNull(mc.map);
Assert.assertThat(mc.map.get("one"), Is.is("one"));
Assert.assertThat(mc.map.get("two"), Is.is("two"));
MatcherAssert.assertThat(mc.map.get("one"), Is.is("one"));
MatcherAssert.assertThat(mc.map.get("two"), Is.is("two"));
}
}
10 changes: 5 additions & 5 deletions src/test/java/com/laytonsmith/core/TestStatic.java
Expand Up @@ -72,11 +72,11 @@ public void testGetInt() {

@Test
public void testGetBoolean() {
assertEquals(true, ArgumentValidation.getBoolean(C.Boolean(true), Target.UNKNOWN));
assertEquals(true, ArgumentValidation.getBoolean(C.String("non-empty string"), Target.UNKNOWN));
assertEquals(false, ArgumentValidation.getBoolean(C.String(""), Target.UNKNOWN));
assertEquals(true, ArgumentValidation.getBoolean(C.Int(1), Target.UNKNOWN));
assertEquals(false, ArgumentValidation.getBoolean(C.Int(0), Target.UNKNOWN));
assertTrue(ArgumentValidation.getBooleanish(C.Boolean(true), Target.UNKNOWN));
assertTrue(ArgumentValidation.getBooleanish(C.String("non-empty string"), Target.UNKNOWN));
assertFalse(ArgumentValidation.getBooleanish(C.String(""), Target.UNKNOWN));
assertTrue(ArgumentValidation.getBooleanish(C.Int(1), Target.UNKNOWN));
assertFalse(ArgumentValidation.getBooleanish(C.Int(0), Target.UNKNOWN));
}

@Test
Expand Down
Expand Up @@ -19,6 +19,7 @@
import static com.laytonsmith.testing.StaticTest.TestClassDocs;
import static com.laytonsmith.testing.StaticTest.assertCEquals;
import static com.laytonsmith.testing.StaticTest.assertReturn;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -27,7 +28,6 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.hamcrest.core.Is.*;
import static org.junit.Assert.*;

/**
*
Expand Down
Expand Up @@ -10,9 +10,9 @@
import com.laytonsmith.testing.StaticTest;
import static com.laytonsmith.testing.StaticTest.SRun;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.After;
import org.junit.AfterClass;
import static org.junit.Assert.assertThat;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/laytonsmith/testing/StaticTest.java
Expand Up @@ -386,7 +386,7 @@ public static void assertCNotEquals(Mixed expected, Mixed actual) throws CancelC
* @param actual
*/
public static void assertCTrue(Mixed actual) {
if(!ArgumentValidation.getBoolean(actual, Target.UNKNOWN)) {
if(!ArgumentValidation.getBooleanish(actual, Target.UNKNOWN)) {
fail("Expected '" + actual.val() + "' to resolve to true, but it did not");
}
}
Expand All @@ -398,7 +398,7 @@ public static void assertCTrue(Mixed actual) {
* @param actual
*/
public static void assertCFalse(Mixed actual) {
if(ArgumentValidation.getBoolean(actual, Target.UNKNOWN)) {
if(ArgumentValidation.getBooleanish(actual, Target.UNKNOWN)) {
fail("Expected '" + actual.val() + "' to resolve to false, but it did not");
}
}
Expand Down

0 comments on commit cce9d74

Please sign in to comment.