use of uk.gov.gchq.gaffer.hbasestore.HBaseStore in project Gaffer by gchq.
the class AddElementsHandlerTest method shouldThrowNoExceptionsWhenValidateFlagSetToFalse.
@Test
public void shouldThrowNoExceptionsWhenValidateFlagSetToFalse() throws OperationException, StoreException {
final AddElements addElements = new AddElements.Builder().input(new Edge("Unknown group", "source", "dest", true)).validate(false).build();
final AddElementsHandler handler = new AddElementsHandler();
final Context context = mock(Context.class);
final HBaseStore store = mock(HBaseStore.class);
final Table table = mock(Table.class);
given(store.getTable()).willReturn(table);
final HBaseProperties properties = HBaseProperties.loadStoreProperties(StreamUtil.storeProps(getClass()));
given(store.getProperties()).willReturn(properties);
given(store.getSchema()).willReturn(SCHEMA);
// When / Then - no exceptions
handler.doOperation(addElements, context, store);
}
use of uk.gov.gchq.gaffer.hbasestore.HBaseStore in project Gaffer by gchq.
the class AddElementsHandlerTest method shouldDoNothingIfNoElementsProvided.
@Test
public void shouldDoNothingIfNoElementsProvided() throws OperationException, StoreException, IOException {
// Given
final AddElementsHandler handler = new AddElementsHandler();
final AddElements addElements = new AddElements();
final Context context = mock(Context.class);
final HBaseStore store = mock(HBaseStore.class);
final Table table = mock(Table.class);
given(store.getTable()).willReturn(table);
final HBaseProperties properties = HBaseProperties.loadStoreProperties(StreamUtil.storeProps(getClass()));
given(store.getProperties()).willReturn(properties);
given(store.getSchema()).willReturn(SCHEMA);
// When
handler.doOperation(addElements, context, store);
// Then
verify(table, never()).put(any(Put.class));
}
use of uk.gov.gchq.gaffer.hbasestore.HBaseStore in project Gaffer by gchq.
the class GetAdjacentIdsHandlerTest method shouldDoNothingIfNoSeedsProvided.
@Test
public void shouldDoNothingIfNoSeedsProvided() throws OperationException {
// Given
final GetAdjacentIdsHandler handler = new GetAdjacentIdsHandler();
final GetAdjacentIds getAdjacentIds = new GetAdjacentIds();
final Context context = mock(Context.class);
final HBaseStore store = mock(HBaseStore.class);
// When
final CloseableIterable<? extends EntityId> result = handler.doOperation(getAdjacentIds, context, store);
// Then
assertEquals(0, Iterables.size(result));
}
use of uk.gov.gchq.gaffer.hbasestore.HBaseStore in project Gaffer by gchq.
the class GetElementsHandlerTest method shouldDoNothingIfNoSeedsProvided.
@Test
public void shouldDoNothingIfNoSeedsProvided() throws OperationException {
// Given
final GetElementsHandler handler = new GetElementsHandler();
final GetElements getElements = new GetElements();
final Context context = mock(Context.class);
final HBaseStore store = mock(HBaseStore.class);
// When
final CloseableIterable<? extends Element> result = handler.doOperation(getElements, context, store);
// Then
assertEquals(0, Iterables.size(result));
}
use of uk.gov.gchq.gaffer.hbasestore.HBaseStore in project Gaffer by gchq.
the class GetElementsHandlerTest method shouldReturnHBaseRetrieverWithIncludeMatchedVertexWhenSeedMatchingIsNull.
@Test
public void shouldReturnHBaseRetrieverWithIncludeMatchedVertexWhenSeedMatchingIsNull() throws OperationException, StoreException {
// Given
final Iterable<EntityId> ids = mock(Iterable.class);
final Context context = mock(Context.class);
final User user = mock(User.class);
final HBaseStore store = mock(HBaseStore.class);
final HBaseRetriever<GetElements> hbaseRetriever = mock(HBaseRetriever.class);
final GetElementsHandler handler = new GetElementsHandler();
final GetElements getElements = new GetElements.Builder().inputIds(ids).seedMatching(null).build();
given(context.getUser()).willReturn(user);
given(store.createRetriever(getElements, user, ids, true)).willReturn(hbaseRetriever);
// When
final HBaseRetriever<GetElements> result = (HBaseRetriever<GetElements>) handler.doOperation(getElements, context, store);
// Then
assertSame(hbaseRetriever, result);
}
Aggregations