use of uk.gov.gchq.gaffer.data.element.Properties in project Gaffer by gchq.
the class AbstractAccumuloElementConverterTest method shouldTruncatePropertyBytes.
@Test
public void shouldTruncatePropertyBytes() throws AccumuloElementConversionException {
// Given
final Properties properties = new Properties() {
{
put(AccumuloPropertyNames.COLUMN_QUALIFIER, 1);
put(AccumuloPropertyNames.COLUMN_QUALIFIER_2, 2);
put(AccumuloPropertyNames.COLUMN_QUALIFIER_3, 3);
put(AccumuloPropertyNames.COLUMN_QUALIFIER_4, 4);
}
};
final byte[] bytes = converter.buildColumnQualifier(TestGroups.EDGE, properties);
// When
final byte[] truncatedBytes = converter.getPropertiesAsBytesFromColumnQualifier(TestGroups.EDGE, bytes, 2);
// Then
final Properties truncatedProperties = new Properties() {
{
put(AccumuloPropertyNames.COLUMN_QUALIFIER, 1);
put(AccumuloPropertyNames.COLUMN_QUALIFIER_2, 2);
}
};
assertEquals(truncatedProperties, converter.getPropertiesFromColumnQualifier(TestGroups.EDGE, truncatedBytes));
}
use of uk.gov.gchq.gaffer.data.element.Properties in project Gaffer by gchq.
the class AbstractAccumuloElementConverterTest method shouldBuildTimestampFromDefaultTimeWhenPropertyIsNull.
@Test
public void shouldBuildTimestampFromDefaultTimeWhenPropertyIsNull() throws AccumuloElementConversionException {
// Given
// add extra timestamp property to schema
final Schema schema = new Schema.Builder().json(StreamUtil.schemas(getClass())).build();
converter = createConverter(new Schema.Builder(schema).type("timestamp", Long.class).edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().property(AccumuloPropertyNames.TIMESTAMP, "timestamp").build()).timestampProperty(AccumuloPropertyNames.TIMESTAMP).build());
final Long propertyTimestamp = null;
final Properties properties = new Properties() {
{
put(AccumuloPropertyNames.COLUMN_QUALIFIER, 1);
put(AccumuloPropertyNames.PROP_1, 2);
put(AccumuloPropertyNames.TIMESTAMP, propertyTimestamp);
}
};
// When
final long timestamp = converter.buildTimestamp(properties);
// Then
assertNotNull(timestamp);
}
use of uk.gov.gchq.gaffer.data.element.Properties in project Gaffer by gchq.
the class AbstractAccumuloElementConverterTest method shouldGetEmptyPropertiesFromTimestampWhenNoTimestampPropertyInGroup.
@Test
public void shouldGetEmptyPropertiesFromTimestampWhenNoTimestampPropertyInGroup() throws AccumuloElementConversionException {
// Given
// add timestamp property name but don't add the property to the edge group
final Schema schema = new Schema.Builder().json(StreamUtil.schemas(getClass())).build();
converter = createConverter(new Schema.Builder(schema).timestampProperty(AccumuloPropertyNames.TIMESTAMP).build());
final long timestamp = System.currentTimeMillis();
final String group = TestGroups.EDGE;
// When
final Properties properties = converter.getPropertiesFromTimestamp(group, timestamp);
// Then
assertEquals(0, properties.size());
}
use of uk.gov.gchq.gaffer.data.element.Properties in project Gaffer by gchq.
the class AbstractAccumuloElementConverterTest method shouldGetEmptyPropertiesFromTimestampWhenNoTimestampProperty.
@Test
public void shouldGetEmptyPropertiesFromTimestampWhenNoTimestampProperty() throws AccumuloElementConversionException {
// Given
final long timestamp = System.currentTimeMillis();
final String group = TestGroups.EDGE;
// When
final Properties properties = converter.getPropertiesFromTimestamp(group, timestamp);
// Then
assertEquals(0, properties.size());
}
use of uk.gov.gchq.gaffer.data.element.Properties in project Gaffer by gchq.
the class AbstractAccumuloElementConverterTest method shouldSerialiseAndDeSerialiseBetweenPropertyAndValueWithNullProperty.
@Test
public void shouldSerialiseAndDeSerialiseBetweenPropertyAndValueWithNullProperty() throws AccumuloElementConversionException {
Properties properties = new Properties();
properties.put(AccumuloPropertyNames.PROP_1, 5);
properties.put(AccumuloPropertyNames.PROP_2, null);
properties.put(AccumuloPropertyNames.PROP_3, 299);
properties.put(AccumuloPropertyNames.PROP_4, 10);
properties.put(AccumuloPropertyNames.COUNT, 8);
final Value value = converter.getValueFromProperties(TestGroups.EDGE, properties);
final Properties deSerialisedProperties = converter.getPropertiesFromValue(TestGroups.EDGE, value);
assertEquals(5, deSerialisedProperties.get(AccumuloPropertyNames.PROP_1));
assertNull(deSerialisedProperties.get(AccumuloPropertyNames.PROP_2));
assertEquals(299, deSerialisedProperties.get(AccumuloPropertyNames.PROP_3));
assertEquals(10, deSerialisedProperties.get(AccumuloPropertyNames.PROP_4));
assertEquals(8, deSerialisedProperties.get(AccumuloPropertyNames.COUNT));
}
Aggregations