#1152 - Refactor EJson internals extracting io.ebean.service.SpiJsonService

This commit is contained in:
rob bygrave committed 2017-10-05 00:29:43 +13:00
1 parent 90cf3fddc9
commit 7524903aea
29 files changed
+406 -91

No files matched your search

@@ -1,5 +1,8 @@
package io.ebeaninternal.server.type;
package io.ebeaninternal.json;
import org.assertj.core.api.Assertions;
import org.junit.Assert;
import org.junit.Test;
import java.io.ByteArrayInputStream;
@@ -13,9 +16,6 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.*;
public class ModifyAwareMapTest {
private ModifyAwareMap<String, String> createMap() {
@@ -37,56 +37,56 @@ public class ModifyAwareMapTest {
public void testToString() throws Exception {
ModifyAwareMap<String, String> map = createMap();
assertEquals(map.map.toString(), map.toString());
Assert.assertEquals(map.map.toString(), map.toString());
}
@Test
public void testIsMarkedDirty() throws Exception {
ModifyAwareMap<String, String> map = createMap();
assertFalse(map.isMarkedDirty());
Assert.assertFalse(map.isMarkedDirty());
map.put("A", "change");
assertTrue(map.isMarkedDirty());
Assert.assertTrue(map.isMarkedDirty());
}
@Test
public void testMarkAsModified() throws Exception {
ModifyAwareMap<String, String> map = createMap();
assertFalse(map.isMarkedDirty());
Assert.assertFalse(map.isMarkedDirty());
map.markAsModified();
assertTrue(map.isMarkedDirty());
Assert.assertTrue(map.isMarkedDirty());
}
@Test
public void testSize() throws Exception {
ModifyAwareMap<String, String> map = createMap();
assertEquals(5, map.size());
Assert.assertEquals(5, map.size());
}
@Test
public void testIsEmpty() throws Exception {
assertFalse(createMap().isEmpty());
assertTrue(createEmptyMap().isEmpty());
Assert.assertFalse(createMap().isEmpty());
Assert.assertTrue(createEmptyMap().isEmpty());
}
@Test
public void testContainsKey() throws Exception {
ModifyAwareMap<String, String> map = createMap();
assertTrue(map.containsKey("A"));
assertFalse(map.containsKey("Z"));
Assert.assertTrue(map.containsKey("A"));
Assert.assertFalse(map.containsKey("Z"));
}
@Test
public void testContainsValue() throws Exception {
ModifyAwareMap<String, String> map = createMap();
assertTrue(map.containsValue("one"));
assertFalse(map.containsValue("junk"));
Assert.assertTrue(map.containsValue("one"));
Assert.assertFalse(map.containsValue("junk"));
}
@Test
@@ -94,86 +94,86 @@ public class ModifyAwareMapTest {
ModifyAwareMap<String, String> map = createMap();
assertEquals("two", map.get("B"));
assertNull(map.get("Z"));
assertFalse(map.isMarkedDirty());
Assert.assertEquals("two", map.get("B"));
Assert.assertNull(map.get("Z"));
Assert.assertFalse(map.isMarkedDirty());
}
@Test
public void testPut() throws Exception {
ModifyAwareMap<String, String> map = createMap();
assertFalse(map.isMarkedDirty());
Assert.assertFalse(map.isMarkedDirty());
map.put("A", "mod");
assertTrue(map.isMarkedDirty());
Assert.assertTrue(map.isMarkedDirty());
}
@Test
public void testRemove() throws Exception {
ModifyAwareMap<String, String> map = createMap();
assertFalse(map.isMarkedDirty());
Assert.assertFalse(map.isMarkedDirty());
map.remove("A");
assertTrue(map.isMarkedDirty());
Assert.assertTrue(map.isMarkedDirty());
}
@Test
public void testPutAllWithEmpty() throws Exception {
ModifyAwareMap<String, String> map = createMap();
assertFalse(map.isMarkedDirty());
Assert.assertFalse(map.isMarkedDirty());
Map<String, String> other = new HashMap<>();
map.putAll(other);
assertTrue(map.isMarkedDirty());
Assert.assertTrue(map.isMarkedDirty());
}
@Test
public void testPutAll() throws Exception {
ModifyAwareMap<String, String> map = createMap();
assertFalse(map.isMarkedDirty());
Assert.assertFalse(map.isMarkedDirty());
Map<String, String> other = new HashMap<>();
other.put("A", "one");
map.putAll(other);
assertTrue(map.isMarkedDirty());
Assert.assertTrue(map.isMarkedDirty());
}
@Test
public void testClear() throws Exception {
ModifyAwareMap<String, String> map = createMap();
assertFalse(map.isMarkedDirty());
Assert.assertFalse(map.isMarkedDirty());
map.clear();
assertTrue(map.isMarkedDirty());
Assert.assertTrue(map.isMarkedDirty());
}
@Test
public void testKeySet() throws Exception {
ModifyAwareMap<String, String> map = createMap();
assertFalse(map.isMarkedDirty());
Assert.assertFalse(map.isMarkedDirty());
Set<String> keys = map.keySet();
assertEquals(map.size(), keys.size());
assertTrue(keys.contains("A"));
assertFalse(map.isMarkedDirty());
Assert.assertEquals(map.size(), keys.size());
Assert.assertTrue(keys.contains("A"));
Assert.assertFalse(map.isMarkedDirty());
}
@Test
public void testValues() throws Exception {
ModifyAwareMap<String, String> map = createMap();
assertFalse(map.isMarkedDirty());
Assert.assertFalse(map.isMarkedDirty());
Collection<String> values = map.values();
assertEquals(map.size(), values.size());
assertTrue(values.contains("one"));
assertFalse(map.isMarkedDirty());
Assert.assertEquals(map.size(), values.size());
Assert.assertTrue(values.contains("one"));
Assert.assertFalse(map.isMarkedDirty());
}
@Test
@@ -182,10 +182,10 @@ public class ModifyAwareMapTest {
ModifyAwareMap<String, String> map = createMap();
Set<Map.Entry<String, String>> entries = map.entrySet();
assertFalse(map.isMarkedDirty());
Assert.assertFalse(map.isMarkedDirty());
assertEquals(map.size(), entries.size());
assertFalse(map.isMarkedDirty());
Assert.assertEquals(map.size(), entries.size());
Assert.assertFalse(map.isMarkedDirty());
}
@Test
@@ -204,6 +204,6 @@ public class ModifyAwareMapTest {
@SuppressWarnings("unchecked")
ModifyAwareMap<String, String> read = (ModifyAwareMap<String, String>)ois.readObject();
assertThat(read).hasSize(orig.size());
Assertions.assertThat(read).hasSize(orig.size());
}
}
@@ -1,5 +1,6 @@
package io.ebeaninternal.server.type;
import io.ebeaninternal.json.ModifyAwareFlag;
import org.junit.Test;
import java.io.ByteArrayInputStream;
@@ -1,5 +1,7 @@
package io.ebeaninternal.server.type;
import io.ebeaninternal.json.ModifyAwareList;
import io.ebeaninternal.json.ModifyAwareSet;
import org.junit.Test;
import java.io.ByteArrayInputStream;
@@ -1,5 +1,6 @@
package io.ebeaninternal.server.type;
import io.ebeaninternal.json.ModifyAwareSet;
import org.junit.Test;
import java.io.ByteArrayInputStream;
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import io.ebeaninternal.json.ModifyAwareMap;
import org.junit.Test;
import java.io.IOException;