Search in sources :

Example 1 with LazyProperties

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

the class AccumuloEntityValueLoaderTest method shouldLoadAllVisibilityPropertiesWhenGetVisProperty.

@Test
public void shouldLoadAllVisibilityPropertiesWhenGetVisProperty() 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 ByteSequence cvData = mock(ByteSequence.class);
    given(key.getColumnVisibilityData()).willReturn(cvData);
    final byte[] cvBytes = { 0, 1, 2, 3, 4 };
    given(cvData.getBackingArray()).willReturn(cvBytes);
    given(converter.getPropertiesFromColumnVisibility(group, cvBytes)).willReturn(properties);
    given(properties.get(TestPropertyNames.VISIBILITY)).willReturn("vis1");
    // When
    final Object property = loader.getProperty(TestPropertyNames.VISIBILITY, lazyProperties);
    // Then
    assertEquals("vis1", 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()).getPropertiesFromTimestamp(Mockito.eq(group), Mockito.anyLong());
    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) ByteSequence(org.apache.accumulo.core.data.ByteSequence) Test(org.junit.jupiter.api.Test)

Example 2 with LazyProperties

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

the class AccumuloEntityValueLoaderTest method shouldLoadAllColumnQualifierPropertiesWhenGetGroupByProperty.

@Test
public void shouldLoadAllColumnQualifierPropertiesWhenGetGroupByProperty() 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 ByteSequence cqData = mock(ByteSequence.class);
    given(key.getColumnQualifierData()).willReturn(cqData);
    final byte[] cqBytes = { 0, 1, 2, 3, 4 };
    given(cqData.getBackingArray()).willReturn(cqBytes);
    given(converter.getPropertiesFromColumnQualifier(group, cqBytes)).willReturn(properties);
    given(properties.get(TestPropertyNames.PROP_1)).willReturn("propValue1");
    // When
    final Object property = loader.getProperty(TestPropertyNames.PROP_1, lazyProperties);
    // Then
    assertEquals("propValue1", 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()).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) ByteSequence(org.apache.accumulo.core.data.ByteSequence) Test(org.junit.jupiter.api.Test)

Example 3 with LazyProperties

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

the class AccumuloEntityValueLoaderTest method shouldLoadAllValuePropertiesWhenGetProperty.

@Test
public void shouldLoadAllValuePropertiesWhenGetProperty() 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);
    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 4 with LazyProperties

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

the class AccumuloEdgeValueLoaderTest method shouldLoadAllColumnQualifierPropertiesWhenGetGroupByProperty.

@Test
public void shouldLoadAllColumnQualifierPropertiesWhenGetGroupByProperty() 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 ByteSequence cqData = mock(ByteSequence.class);
    given(key.getColumnQualifierData()).willReturn(cqData);
    final byte[] cqBytes = { 0, 1, 2, 3, 4 };
    given(cqData.getBackingArray()).willReturn(cqBytes);
    given(converter.getPropertiesFromColumnQualifier(group, cqBytes)).willReturn(properties);
    given(properties.get(TestPropertyNames.PROP_1)).willReturn("propValue1");
    // When
    final Object property = loader.getProperty(TestPropertyNames.PROP_1, lazyProperties);
    // Then
    assertEquals("propValue1", 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()).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) ByteSequence(org.apache.accumulo.core.data.ByteSequence) Test(org.junit.jupiter.api.Test)

Example 5 with LazyProperties

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

the class AccumuloEdgeValueLoaderTest method shouldLoadAllVisibilityPropertiesWhenGetVisProperty.

@Test
public void shouldLoadAllVisibilityPropertiesWhenGetVisProperty() 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 ByteSequence cvData = mock(ByteSequence.class);
    given(key.getColumnVisibilityData()).willReturn(cvData);
    final byte[] cvBytes = { 0, 1, 2, 3, 4 };
    given(cvData.getBackingArray()).willReturn(cvBytes);
    given(converter.getPropertiesFromColumnVisibility(group, cvBytes)).willReturn(properties);
    given(properties.get(TestPropertyNames.VISIBILITY)).willReturn("vis1");
    // When
    final Object property = loader.getProperty(TestPropertyNames.VISIBILITY, lazyProperties);
    // Then
    assertEquals("vis1", 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()).getPropertiesFromTimestamp(Mockito.eq(group), Mockito.anyLong());
    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) ByteSequence(org.apache.accumulo.core.data.ByteSequence) 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