use of uk.gov.gchq.gaffer.time.BoundedTimestampSet in project Gaffer by gchq.
the class BoundedTimestampSetSerialiserTest method testSerialiserWhenSampling.
@Test
public void testSerialiserWhenSampling() throws SerialisationException {
// Given
final Set<Instant> instants = new HashSet<>();
IntStream.range(0, 1000).forEach(i -> instants.add(Instant.ofEpochMilli(i * 1000L)));
final BoundedTimestampSet boundedTimestampSet = new BoundedTimestampSet(TimeBucket.SECOND, 10);
instants.forEach(boundedTimestampSet::add);
// When
final byte[] serialised = serialiser.serialise(boundedTimestampSet);
final BoundedTimestampSet deserialised = serialiser.deserialise(serialised);
// Then
assertEquals(boundedTimestampSet.getState(), deserialised.getState());
assertEquals(boundedTimestampSet.getTimeBucket(), deserialised.getTimeBucket());
assertEquals(boundedTimestampSet.getMaxSize(), deserialised.getMaxSize());
assertEquals(boundedTimestampSet.getNumberOfTimestamps(), deserialised.getNumberOfTimestamps());
assertEquals(boundedTimestampSet.getTimestamps(), deserialised.getTimestamps());
}
Aggregations