Search in sources :

Example 6 with LazyProperties

use of uk.gov.gchq.gaffer.data.element.LazyProperties in project Gaffer by gchq.

the class AccumuloEdgeValueLoaderTest method shouldLoadAllValuePropertiesWhenGetProperty.

@Test
public void shouldLoadAllValuePropertiesWhenGetProperty() throws SerialisationException {
    // Given
    final String group = TestGroups.EDGE;
    final Key key = mock(Key.class);
    final Value value = mock(Value.class);
    final AccumuloElementConverter converter = mock(AccumuloElementConverter.class);
    final Schema schema = createSchema();
    final AccumuloEdgeValueLoader loader = new AccumuloEdgeValueLoader(group, key, value, converter, schema, false);
    final LazyProperties lazyProperties = mock(LazyProperties.class);
    final Properties properties = mock(Properties.class);
    given(converter.getPropertiesFromValue(group, value)).willReturn(properties);
    given(properties.get(TestPropertyNames.PROP_3)).willReturn("propValue3");
    // When
    final Object property = loader.getProperty(TestPropertyNames.PROP_3, lazyProperties);
    // Then
    assertEquals("propValue3", property);
    verify(lazyProperties).putAll(properties);
    verify(converter, never()).getElementId(key, false);
    verify(converter, never()).getPropertiesFromColumnVisibility(Mockito.eq(group), Mockito.any(byte[].class));
    verify(converter, never()).getPropertiesFromTimestamp(Mockito.eq(group), Mockito.anyLong());
    verify(converter, never()).getPropertiesFromColumnQualifier(Mockito.eq(group), Mockito.any(byte[].class));
}
Also used : AccumuloElementConverter(uk.gov.gchq.gaffer.accumulostore.key.AccumuloElementConverter) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Value(org.apache.accumulo.core.data.Value) LazyProperties(uk.gov.gchq.gaffer.data.element.LazyProperties) LazyProperties(uk.gov.gchq.gaffer.data.element.LazyProperties) Properties(uk.gov.gchq.gaffer.data.element.Properties) Key(org.apache.accumulo.core.data.Key) Test(org.junit.jupiter.api.Test)

Example 7 with LazyProperties

use of uk.gov.gchq.gaffer.data.element.LazyProperties in project Gaffer by gchq.

the class AccumuloEdgeValueLoaderTest method shouldLoadAllTimestampPropertiesWhenGetTimestampProperty.

@Test
public void shouldLoadAllTimestampPropertiesWhenGetTimestampProperty() throws SerialisationException {
    // Given
    final String group = TestGroups.EDGE;
    final Key key = mock(Key.class);
    final Value value = mock(Value.class);
    final AccumuloElementConverter converter = mock(AccumuloElementConverter.class);
    final Schema schema = createSchema();
    final AccumuloEdgeValueLoader loader = new AccumuloEdgeValueLoader(group, key, value, converter, schema, false);
    final LazyProperties lazyProperties = mock(LazyProperties.class);
    final Properties properties = mock(Properties.class);
    final Long timestamp = 10L;
    given(key.getTimestamp()).willReturn(timestamp);
    given(converter.getPropertiesFromTimestamp(group, timestamp)).willReturn(properties);
    given(properties.get(TestPropertyNames.TIMESTAMP)).willReturn(timestamp);
    // When
    final Object property = loader.getProperty(TestPropertyNames.TIMESTAMP, lazyProperties);
    // Then
    assertEquals(timestamp, property);
    verify(lazyProperties).putAll(properties);
    verify(converter, never()).getElementId(key, false);
    verify(converter, never()).getPropertiesFromColumnQualifier(Mockito.eq(group), Mockito.any(byte[].class));
    verify(converter, never()).getPropertiesFromColumnVisibility(Mockito.eq(group), Mockito.any(byte[].class));
    verify(converter, never()).getPropertiesFromValue(Mockito.eq(group), Mockito.any(Value.class));
}
Also used : AccumuloElementConverter(uk.gov.gchq.gaffer.accumulostore.key.AccumuloElementConverter) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Value(org.apache.accumulo.core.data.Value) LazyProperties(uk.gov.gchq.gaffer.data.element.LazyProperties) LazyProperties(uk.gov.gchq.gaffer.data.element.LazyProperties) Properties(uk.gov.gchq.gaffer.data.element.Properties) Key(org.apache.accumulo.core.data.Key) Test(org.junit.jupiter.api.Test)

Example 8 with LazyProperties

use of uk.gov.gchq.gaffer.data.element.LazyProperties in project Gaffer by gchq.

the class AccumuloEntityValueLoaderTest method shouldLoadAllTimestampPropertiesWhenGetTimestampProperty.

@Test
public void shouldLoadAllTimestampPropertiesWhenGetTimestampProperty() throws SerialisationException {
    // Given
    final String group = TestGroups.ENTITY;
    final Key key = mock(Key.class);
    final Value value = mock(Value.class);
    final AccumuloElementConverter converter = mock(AccumuloElementConverter.class);
    final Schema schema = createSchema();
    final AccumuloEntityValueLoader loader = new AccumuloEntityValueLoader(group, key, value, converter, schema);
    final LazyProperties lazyProperties = mock(LazyProperties.class);
    final Properties properties = mock(Properties.class);
    final Long timestamp = 10L;
    given(key.getTimestamp()).willReturn(timestamp);
    given(converter.getPropertiesFromTimestamp(group, timestamp)).willReturn(properties);
    given(properties.get(TestPropertyNames.TIMESTAMP)).willReturn(timestamp);
    // When
    final Object property = loader.getProperty(TestPropertyNames.TIMESTAMP, lazyProperties);
    // Then
    assertEquals(timestamp, property);
    verify(lazyProperties).putAll(properties);
    verify(converter, never()).getElementId(key, false);
    verify(converter, never()).getPropertiesFromColumnQualifier(Mockito.eq(group), Mockito.any(byte[].class));
    verify(converter, never()).getPropertiesFromColumnVisibility(Mockito.eq(group), Mockito.any(byte[].class));
    verify(converter, never()).getPropertiesFromValue(Mockito.eq(group), Mockito.any(Value.class));
}
Also used : AccumuloElementConverter(uk.gov.gchq.gaffer.accumulostore.key.AccumuloElementConverter) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Value(org.apache.accumulo.core.data.Value) LazyProperties(uk.gov.gchq.gaffer.data.element.LazyProperties) LazyProperties(uk.gov.gchq.gaffer.data.element.LazyProperties) Properties(uk.gov.gchq.gaffer.data.element.Properties) Key(org.apache.accumulo.core.data.Key) Test(org.junit.jupiter.api.Test)

Aggregations

Key (org.apache.accumulo.core.data.Key)8 Value (org.apache.accumulo.core.data.Value)8 Test (org.junit.jupiter.api.Test)8 AccumuloElementConverter (uk.gov.gchq.gaffer.accumulostore.key.AccumuloElementConverter)8 LazyProperties (uk.gov.gchq.gaffer.data.element.LazyProperties)8 Properties (uk.gov.gchq.gaffer.data.element.Properties)8 Schema (uk.gov.gchq.gaffer.store.schema.Schema)8 ByteSequence (org.apache.accumulo.core.data.ByteSequence)4