Search in sources :

Example 1 with TreeSetStringSerialiser

use of uk.gov.gchq.gaffer.serialisation.implementation.TreeSetStringSerialiser in project Gaffer by gchq.

the class CustomMapTest method shouldJSONSerialiseBigIntString.

@Test
public void shouldJSONSerialiseBigIntString() throws IOException {
    // given
    final CustomMap<TreeSet<String>, Double> expectedMap = new CustomMap<>(new TreeSetStringSerialiser(), new DoubleSerialiser());
    final TreeSet<String> key1 = new TreeSet<>();
    key1.add("k1");
    key1.add("k2");
    expectedMap.put(key1, 11.11);
    final TreeSet<String> key2 = new TreeSet<>();
    key2.add("k3");
    key2.add("k4");
    expectedMap.put(key2, 22.22);
    final String expectedJson = jsonFromFile("custom-map02.json");
    // when
    final byte[] serialise = JSONSerialiser.serialise(expectedMap, true);
    final CustomMap jsonMap = JSONSerialiser.deserialise(expectedJson, CustomMap.class);
    final CustomMap deserialiseMap = JSONSerialiser.deserialise(serialise, CustomMap.class);
    // then
    assertEquals(jsonMap, deserialiseMap, "The expected map from Json doesn't match");
    assertEquals(expectedMap, deserialiseMap, "The expected map doesn't match");
}
Also used : TreeSet(java.util.TreeSet) TreeSetStringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.TreeSetStringSerialiser) DoubleSerialiser(uk.gov.gchq.gaffer.serialisation.DoubleSerialiser) Test(org.junit.jupiter.api.Test)

Aggregations

TreeSet (java.util.TreeSet)1 Test (org.junit.jupiter.api.Test)1 DoubleSerialiser (uk.gov.gchq.gaffer.serialisation.DoubleSerialiser)1 TreeSetStringSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.TreeSetStringSerialiser)1