Search in sources :

Example 1 with HBaseStore

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);
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Context(uk.gov.gchq.gaffer.store.Context) HTable(org.apache.hadoop.hbase.client.HTable) Table(org.apache.hadoop.hbase.client.Table) HBaseStore(uk.gov.gchq.gaffer.hbasestore.HBaseStore) HBaseProperties(uk.gov.gchq.gaffer.hbasestore.HBaseProperties) Edge(uk.gov.gchq.gaffer.data.element.Edge) Test(org.junit.jupiter.api.Test)

Example 2 with HBaseStore

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));
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Context(uk.gov.gchq.gaffer.store.Context) HTable(org.apache.hadoop.hbase.client.HTable) Table(org.apache.hadoop.hbase.client.Table) HBaseStore(uk.gov.gchq.gaffer.hbasestore.HBaseStore) HBaseProperties(uk.gov.gchq.gaffer.hbasestore.HBaseProperties) Put(org.apache.hadoop.hbase.client.Put) Test(org.junit.jupiter.api.Test)

Example 3 with HBaseStore

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));
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) GetAdjacentIds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds) HBaseStore(uk.gov.gchq.gaffer.hbasestore.HBaseStore) Test(org.junit.jupiter.api.Test)

Example 4 with HBaseStore

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));
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) HBaseStore(uk.gov.gchq.gaffer.hbasestore.HBaseStore) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) Test(org.junit.jupiter.api.Test)

Example 5 with HBaseStore

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);
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) Context(uk.gov.gchq.gaffer.store.Context) User(uk.gov.gchq.gaffer.user.User) HBaseStore(uk.gov.gchq.gaffer.hbasestore.HBaseStore) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) HBaseRetriever(uk.gov.gchq.gaffer.hbasestore.retriever.HBaseRetriever) Test(org.junit.jupiter.api.Test)

Aggregations

HBaseStore (uk.gov.gchq.gaffer.hbasestore.HBaseStore)15 Test (org.junit.jupiter.api.Test)13 Context (uk.gov.gchq.gaffer.store.Context)12 HBaseProperties (uk.gov.gchq.gaffer.hbasestore.HBaseProperties)6 User (uk.gov.gchq.gaffer.user.User)5 Edge (uk.gov.gchq.gaffer.data.element.Edge)4 EntityId (uk.gov.gchq.gaffer.data.element.id.EntityId)4 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)4 List (java.util.List)3 TableName (org.apache.hadoop.hbase.TableName)3 Admin (org.apache.hadoop.hbase.client.Admin)3 HTable (org.apache.hadoop.hbase.client.HTable)3 ArgumentCaptor (org.mockito.ArgumentCaptor)3 Element (uk.gov.gchq.gaffer.data.element.Element)3 HBaseRetriever (uk.gov.gchq.gaffer.hbasestore.retriever.HBaseRetriever)3 Schema (uk.gov.gchq.gaffer.store.schema.Schema)3 IOException (java.io.IOException)2 Collections (java.util.Collections)2 Collectors (java.util.stream.Collectors)2 IntStream (java.util.stream.IntStream)2