Skip to content

Commit

Permalink
test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kenhuuu committed Aug 14, 2024
1 parent 42070ae commit 17525d6
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -878,4 +878,63 @@ public void shouldReadWriteOutDirection() throws Exception {
assertEquals(resource, recycled);
}

@Test
public void shouldReadWriteZeroDate() throws Exception {
final String resourceName = "zero-date";

final Date resource = findModelEntryObject(resourceName);
final Date fromStatic = read(readFromResource(resourceName), Date.class);
final Date recycled = read(write(fromStatic, Date.class, resourceName), Date.class);
assertEquals(fromStatic, recycled);
assertEquals(resource, fromStatic);
assertEquals(resource, recycled);
}

@Test
public void shouldReadWriteMaxDate() throws Exception {
final String resourceName = "max-date";

final Date resource = findModelEntryObject(resourceName);
final Date fromStatic = read(readFromResource(resourceName), Date.class);
final Date recycled = read(write(fromStatic, Date.class, resourceName), Date.class);
assertEquals(fromStatic, recycled);
assertEquals(resource, fromStatic);
assertEquals(resource, recycled);
}

@Test
public void shouldReadWriteMinDate() throws Exception {
final String resourceName = "min-date";

final Date resource = findModelEntryObject(resourceName);
final Date fromStatic = read(readFromResource(resourceName), Date.class);
final Date recycled = read(write(fromStatic, Date.class, resourceName), Date.class);
assertEquals(fromStatic, recycled);
assertEquals(resource, fromStatic);
assertEquals(resource, recycled);
}

@Test
public void shouldReadWriteVarBulkSet() throws Exception {
final String resourceName = "var-bulkset";

final Date resource = findModelEntryObject(resourceName);
final Date fromStatic = read(readFromResource(resourceName), Date.class);
final Date recycled = read(write(fromStatic, Date.class, resourceName), Date.class);
assertEquals(fromStatic, recycled);
assertEquals(resource, fromStatic);
assertEquals(resource, recycled);
}

@Test
public void shouldReadWriteEmptyBulkSet() throws Exception {
final String resourceName = "empty-bulkset";

final Date resource = findModelEntryObject(resourceName);
final Date fromStatic = read(readFromResource(resourceName), Date.class);
final Date recycled = read(write(fromStatic, Date.class, resourceName), Date.class);
assertEquals(fromStatic, recycled);
assertEquals(resource, fromStatic);
assertEquals(resource, recycled);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import java.math.BigInteger;
import java.net.InetAddress;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
Expand Down Expand Up @@ -109,6 +110,7 @@ private Model() {
// IMPORTANT - the "title" or name of the Entry needs to be unique

addCoreEntry(new Date(0L), "zero-date");
addCoreEntry(new Date(11111111L), "precision-date");
addCoreEntry(new Date(Long.MAX_VALUE), "max-date");
addCoreEntry(new Date(Long.MIN_VALUE), "min-date");

Expand Down Expand Up @@ -141,13 +143,13 @@ private Model() {

final Map<Object,Object> map = new HashMap<>();
map.put("test", 123);
map.put(new Date(1481750076295L), "red");
map.put(Arrays.asList(1,2,3), new Date(1481750076295L));
map.put(new Date(1481295L), "red");
map.put(Arrays.asList(1,2,3), new Date(1481295L));
map.put(null, null);
addCoreEntry(map, "var-type-map", "Map is redefined so that to provide the ability to allow for non-String keys, which is not possible in JSON.");
addCoreEntry(Collections.EMPTY_MAP, "empty-map");

addCoreEntry(new HashSet<>(Arrays.asList(1,"person", true, null)), "var-type-set", "Allows a JSON collection to behave as a Set.");
addCoreEntry(new HashSet<>(Arrays.asList(2, "person", true, null)), "var-type-set", "Allows a JSON collection to behave as a Set.");
addCoreEntry(Collections.EMPTY_SET, "empty-set");

addCoreEntry(UUID.fromString("41d2e28a-20a4-4ab0-b379-d810dede3786"), "specified-uuid");
Expand All @@ -156,7 +158,7 @@ private Model() {
addGraphStructureEntry(graph.edges().next(), "traversal-edge", "");
addGraphStructureEntry(DetachedFactory.detach(graph.edges().next(), false), "no-prop-edge", "");

addGraphStructureEntry(g.V().out().out().path().next(), "traversal-path", "");
addGraphStructureEntry(detach(g.V().out().out().path().next(), false), "traversal-path", "");
addGraphStructureEntry(EmptyPath.instance(), "empty-path", "");
addGraphStructureEntry(detach(g.V().out().out().path().next(), true), "prop-path", "");

Expand Down Expand Up @@ -197,7 +199,7 @@ private Model() {
addExtendedEntry(Byte.MIN_VALUE, "min-byte", "");

addExtendedEntry(ByteBuffer.wrap(new byte[0]), "empty-binary", "");
addEntry("Extended", () -> java.nio.ByteBuffer.wrap("some bytes for you".getBytes()), "str-binary", "");
addEntry("Extended", () -> java.nio.ByteBuffer.wrap("some bytes for you".getBytes(StandardCharsets.UTF_8)), "str-binary", "");

addExtendedEntry(Duration.ZERO, "zero-duration","The following example is a zero `Duration`");
addExtendedEntry(ChronoUnit.FOREVER.getDuration(), "forever-duration","");
Expand Down

0 comments on commit 17525d6

Please sign in to comment.