use of uk.gov.gchq.gaffer.hbasestore.HBaseStore in project Gaffer by gchq.
the class GetAdjacentIdsHandlerTest method shouldReturnHBaseRetriever.
@Test
public void shouldReturnHBaseRetriever() 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 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);
// When
final GetAdjacentIdsHandler.ExtractDestinationEntityId result = (GetAdjacentIdsHandler.ExtractDestinationEntityId) handler.doOperation(getAdjacentIds, context, store);
// Then
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"));
}
use of uk.gov.gchq.gaffer.hbasestore.HBaseStore in project Gaffer by gchq.
the class HBaseAddElementsFromHdfsJobFactoryTest method getStoreConfiguredWith.
@Override
protected Store getStoreConfiguredWith(final Class<JSONSerialiser> jsonSerialiserClass, final String jsonSerialiserModules, final Boolean strictJson) throws IOException, StoreException {
final HBaseStore store = new SingleUseMiniHBaseStore();
final Schema schema = Schema.fromJson(StreamUtil.schemas(getClass()));
final HBaseProperties properties = HBaseProperties.loadStoreProperties(StreamUtil.storeProps(getClass()));
super.configureStoreProperties(properties, jsonSerialiserClass, jsonSerialiserModules, strictJson);
store.initialise("graphId", schema, properties);
final JobConf localConf = createLocalConf();
final FileSystem fs = FileSystem.getLocal(localConf);
fs.mkdirs(new Path(outputDir));
return store;
}
use of uk.gov.gchq.gaffer.hbasestore.HBaseStore in project Gaffer by gchq.
the class GetAllElementsHandlerTest method shouldReturnHBaseRetriever.
@Test
public void shouldReturnHBaseRetriever() throws OperationException, StoreException {
// Given
final Context context = mock(Context.class);
final User user = mock(User.class);
final HBaseStore store = mock(HBaseStore.class);
final HBaseRetriever<GetAllElements> hbaseRetriever = mock(HBaseRetriever.class);
final GetAllElementsHandler handler = new GetAllElementsHandler();
final GetAllElements getElements = new GetAllElements();
given(context.getUser()).willReturn(user);
given(store.createRetriever(getElements, user, null, false, ElementDedupeFilterProcessor.class)).willReturn(hbaseRetriever);
// When
final HBaseRetriever<GetAllElements> result = (HBaseRetriever<GetAllElements>) handler.doOperation(getElements, context, store);
// Then
assertSame(hbaseRetriever, result);
}
use of uk.gov.gchq.gaffer.hbasestore.HBaseStore in project Gaffer by gchq.
the class SampleElementsForSplitPointsHandlerTest method shouldUseTheNumberOfRegionsToCalculateNumSplits.
@Test
public void shouldUseTheNumberOfRegionsToCalculateNumSplits() throws OperationException {
// Given
final Integer numSplits = null;
final List<Element> elements = IntStream.range(0, 30).mapToObj(i -> new Edge(TestGroups.EDGE, "source_" + i, "dest_" + i, true)).collect(Collectors.toList());
final AbstractSampleElementsForSplitPointsHandler<String, HBaseStore> handler = createHandler();
final SampleElementsForSplitPoints<String> operation = new SampleElementsForSplitPoints.Builder<String>().input(elements).numSplits(numSplits).build();
// When
createHandler().doOperation(operation, new Context(), store);
// Then
final ArgumentCaptor<GenerateSplitPointsFromSample> generateSplitPointsFromSampleCaptor = ArgumentCaptor.forClass(GenerateSplitPointsFromSample.class);
verify(store).execute(generateSplitPointsFromSampleCaptor.capture(), any(Context.class));
final int expectedNumOfSplits = NUM_TABLE_REGIONS - 1;
final int expectedElementCount = elements.size() * 2;
assertExpectedNumberOfSplitPointsAndSampleSize(generateSplitPointsFromSampleCaptor, expectedNumOfSplits, expectedElementCount);
}
use of uk.gov.gchq.gaffer.hbasestore.HBaseStore in project Gaffer by gchq.
the class SampleElementsForSplitPointsHandlerTest method shouldCalculateRequiredNumberOfSplitsFromEdges.
@Test
public void shouldCalculateRequiredNumberOfSplitsFromEdges() throws OperationException {
// Given
final int numSplits = 3;
final List<Element> elements = IntStream.range(0, numSplits * 10).mapToObj(i -> new Edge(TestGroups.EDGE, "source_" + i, "dest_" + i, true)).collect(Collectors.toList());
final AbstractSampleElementsForSplitPointsHandler<String, HBaseStore> handler = createHandler();
final SampleElementsForSplitPoints<String> operation = new SampleElementsForSplitPoints.Builder<String>().input(elements).numSplits(numSplits).build();
// When
createHandler().doOperation(operation, new Context(), createStore());
// Then
final ArgumentCaptor<GenerateSplitPointsFromSample> generateSplitPointsFromSampleCaptor = ArgumentCaptor.forClass(GenerateSplitPointsFromSample.class);
verify(store).execute(generateSplitPointsFromSampleCaptor.capture(), any(Context.class));
final int expectedElementCount = elements.size() * 2;
assertExpectedNumberOfSplitPointsAndSampleSize(generateSplitPointsFromSampleCaptor, numSplits, expectedElementCount);
}
Aggregations