use of uk.gov.gchq.gaffer.types.FreqMap in project Gaffer by gchq.
the class ToFreqMapTest method shouldConvertObjectToFreqMap.
@Test
public void shouldConvertObjectToFreqMap() {
// Given
final ToFreqMap function = new ToFreqMap();
final Object value = 1L;
// When
final FreqMap result = function.apply(value);
// Then
assertEquals(new FreqMap(value.toString()), result);
}
use of uk.gov.gchq.gaffer.types.FreqMap in project Gaffer by gchq.
the class ToFreqMapTest method shouldConvertStringToFreqMap.
@Test
public void shouldConvertStringToFreqMap() {
// Given
final ToFreqMap function = new ToFreqMap();
final String value = "value1";
// When
final FreqMap result = function.apply(value);
// Then
assertEquals(new FreqMap(value), result);
}
use of uk.gov.gchq.gaffer.types.FreqMap in project Gaffer by gchq.
the class FreqMapSerialiserTest method shouldSkipEntryWithNullKey.
@Test
public void shouldSkipEntryWithNullKey() throws SerialisationException {
// Given
final FreqMap freqMap = new FreqMap();
freqMap.put(null, 10L);
freqMap.put("y", 5L);
freqMap.put("z", 20L);
// When
final byte[] serialised = serialiser.serialise(freqMap);
final FreqMap deserialised = serialiser.deserialise(serialised);
assertFalse(deserialised.containsKey("x"));
assertEquals((Long) 5L, deserialised.get("y"));
assertEquals((Long) 20L, deserialised.get("z"));
}
use of uk.gov.gchq.gaffer.types.FreqMap in project Gaffer by gchq.
the class FreqMapSerialiserTest method shouldSkipEntryWithNullValues.
@Test
public void shouldSkipEntryWithNullValues() throws SerialisationException {
// Given
final FreqMap freqMap = new FreqMap();
freqMap.put("v", null);
freqMap.put("w", 5L);
freqMap.put("x", null);
freqMap.put("y", 20L);
freqMap.put("z", null);
// When
final byte[] serialised = serialiser.serialise(freqMap);
final FreqMap deserialised = serialiser.deserialise(serialised);
assertFalse(deserialised.containsKey("v"));
assertEquals((Long) 5L, deserialised.get("w"));
assertFalse(deserialised.containsKey("x"));
assertEquals((Long) 20L, deserialised.get("y"));
assertFalse(deserialised.containsKey("z"));
}
use of uk.gov.gchq.gaffer.types.FreqMap in project Gaffer by gchq.
the class FreqMapSerialiserTest method shouldSerialiseDeserialiseFreqMapWithAnEmptyKey.
@Test
public void shouldSerialiseDeserialiseFreqMapWithAnEmptyKey() throws SerialisationException {
// Given
final FreqMap freqMap = new FreqMap();
freqMap.put("", 10L);
freqMap.put("y", 5L);
freqMap.put("z", 20L);
// When
final byte[] serialised = serialiser.serialise(freqMap);
final FreqMap deserialised = serialiser.deserialise(serialised);
assertEquals((Long) 10L, deserialised.get(""));
assertEquals((Long) 5L, deserialised.get("y"));
assertEquals((Long) 20L, deserialised.get("z"));
}
Aggregations