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));
}
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));
}
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));
}
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));
}
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));
}
Aggregations