GetAdjacentIdsHandler implements OutputOperationHandler<GetAdjacentIds, CloseableIterable<? extends EntityId>> { @Override public CloseableIterable<? extends EntityId> doOperation(final GetAdjacentIds operation, final Context context, final Store store) throws OperationException { return doOperation(operation, context.getUser(), (HBaseStore) store); }  @Override CloseableIterable<? extends EntityId> doOperation(final GetAdjacentIds operation,
                                                             final Context context, final Store store);  }
@Test public void shouldReturnHBaseRetriever() throws OperationException, StoreException { 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 GetAdjacentIdsHandler handler = new GetAdjacentIdsHandler(); final GetAdjacentIds getAdjacentIds = new GetAdjacentIds.Builder() .inputIds(ids) .option("option1", "optionValue") .inOutType(SeededGraphFilters.IncludeIncomingOutgoingType.INCOMING) .directedType(DirectedType.DIRECTED) .view(new View()) .build(); given(context.getUser()).willReturn(user); final ArgumentCaptor<GetElements> getElementsCaptor = ArgumentCaptor.forClass(GetElements.class); given(store.createRetriever(getElementsCaptor.capture(), eq(user), eq(ids), eq(true))).willReturn(hbaseRetriever); final GetAdjacentIdsHandler.ExtractDestinationEntityId result = (GetAdjacentIdsHandler.ExtractDestinationEntityId) handler.doOperation(getAdjacentIds, context, store); assertSame(hbaseRetriever, result.getInput()); final GetElements getElements = getElementsCaptor.getValue(); assertSame(ids, getElements.getInput()); assertTrue(getElements.getView().getEntities().isEmpty()); assertEquals(getAdjacentIds.getDirectedType(), getElements.getDirectedType()); assertEquals(getAdjacentIds.getIncludeIncomingOutGoing(), getElements.getIncludeIncomingOutGoing()); assertEquals("optionValue", getElements.getOption("option1")); }
@Test public void shouldDoNothingIfNoSeedsProvided() throws OperationException { final GetAdjacentIdsHandler handler = new GetAdjacentIdsHandler(); final GetAdjacentIds getAdjacentIds = new GetAdjacentIds(); final Context context = mock(Context.class); final HBaseStore store = mock(HBaseStore.class); final CloseableIterable<? extends EntityId> result = handler.doOperation(getAdjacentIds, context, store); assertEquals(0, Iterables.size(result)); }