use of uk.gov.gchq.gaffer.time.RBMBackedTimestampSet in project Gaffer by gchq.
the class RBMBackedTimestampSetSerialiserTest method getExampleValue.
private RBMBackedTimestampSet getExampleValue() {
final RBMBackedTimestampSet rbmBackedTimestampSet = new RBMBackedTimestampSet(TimeBucket.SECOND);
rbmBackedTimestampSet.add(Instant.ofEpochMilli(1000L));
rbmBackedTimestampSet.add(Instant.ofEpochMilli(1000000L));
return rbmBackedTimestampSet;
}
use of uk.gov.gchq.gaffer.time.RBMBackedTimestampSet in project Gaffer by gchq.
the class RBMBackedTimestampSetSerialiserTest method shouldJSONSerialiseFloatRDM.
@Test
public void shouldJSONSerialiseFloatRDM() throws IOException {
// given
System.setProperty(JSONSerialiser.JSON_SERIALISER_MODULES, BitmapJsonModules.class.getCanonicalName());
final RBMBackedTimestampSet timestampSet1 = new RBMBackedTimestampSet.Builder().timeBucket(TimeBucket.MINUTE).timestamps(Lists.newArrayList(Instant.ofEpochSecond(11))).build();
final RBMBackedTimestampSet timestampSet2 = new RBMBackedTimestampSet.Builder().timeBucket(TimeBucket.HOUR).timestamps(Lists.newArrayList(Instant.ofEpochSecond(222222))).build();
final CustomMap<Float, RBMBackedTimestampSet> expectedMap = new CustomMap<>(new RawFloatSerialiser(), new RBMBackedTimestampSetSerialiser());
expectedMap.put(123.3f, timestampSet1);
expectedMap.put(345.6f, timestampSet2);
final String expectedJson = jsonFromFile("custom-map04.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");
}
use of uk.gov.gchq.gaffer.time.RBMBackedTimestampSet in project Gaffer by gchq.
the class MaskTimestampSetByTimeRangeTest method shouldFilterInclusively.
@Test
public void shouldFilterInclusively() {
// Given
final RBMBackedTimestampSet timestampSet = createTimestampSet();
// When
maskTimestampSetByTimeRange.setStartTime(instant.plus(Duration.ofDays(100)).toEpochMilli());
maskTimestampSetByTimeRange.setEndTime(instant.plus(Duration.ofDays(200)).toEpochMilli());
final RBMBackedTimestampSet actualTimestampSet = maskTimestampSetByTimeRange.apply(timestampSet);
// Then
RBMBackedTimestampSet expectedTimestampSet = new RBMBackedTimestampSet.Builder().timeBucket(TimeBucket.MINUTE).timestamps(Sets.newHashSet(instant.plus(Duration.ofDays(100L)), instant.plus(Duration.ofDays(200L)))).build();
assertEquals(expectedTimestampSet, actualTimestampSet);
}
use of uk.gov.gchq.gaffer.time.RBMBackedTimestampSet in project Gaffer by gchq.
the class MaskTimestampSetByTimeRangeTest method shouldNotMutateOriginalValue.
@Test
public void shouldNotMutateOriginalValue() {
final RBMBackedTimestampSet timestampSet = createTimestampSet();
maskTimestampSetByTimeRange.setStartTime(instant.plus(Duration.ofDays(100)).toEpochMilli());
maskTimestampSetByTimeRange.setEndTime(instant.plus(Duration.ofDays(250)).toEpochMilli());
final RBMBackedTimestampSet actualTimestampSet = maskTimestampSetByTimeRange.apply(timestampSet);
assertNotEquals(actualTimestampSet, timestampSet);
assertEquals(4, timestampSet.getTimestamps().size());
}
use of uk.gov.gchq.gaffer.time.RBMBackedTimestampSet in project Gaffer by gchq.
the class RBMBackedTimestampSetInRangeTest method shouldThrowExceptionIfTimestampSetIsEmpty.
@Test
public void shouldThrowExceptionIfTimestampSetIsEmpty() {
// Given
predicate.startTime(-5L).endTime(5L);
// When / Then
RBMBackedTimestampSet emptySet = new RBMBackedTimestampSet.Builder().timeBucket(TimeBucket.SECOND).build();
assertThatIllegalArgumentException().isThrownBy(() -> predicate.test(emptySet)).withMessage("TimestampSet must contain at least one value");
}
Aggregations