use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class JcsJobTrackerIT method setup.
@Before
public void setup() throws Exception {
final StoreProperties storeProps = StoreProperties.loadStoreProperties(StreamUtil.storeProps(getClass()));
store = Class.forName(storeProps.getStoreClass()).asSubclass(Store.class).newInstance();
store.initialise(new Schema(), storeProps);
graph = new Graph.Builder().store(store).build();
clearJobTracker();
}
use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class SingleUseMockAccumuloProxyStore method startMockAccumuloRestApi.
protected void startMockAccumuloRestApi(final Schema accumuloSchema) throws StoreException {
try {
testFolder.delete();
testFolder.create();
} catch (final IOException e) {
throw new StoreException("Unable to create temporary folder", e);
}
final StoreProperties accumuloStoreProperties = StoreProperties.loadStoreProperties(StreamUtil.openStream(getClass(), "accumulo-store.properties"));
try {
RestApiTestUtil.reinitialiseGraph(testFolder, accumuloSchema, accumuloStoreProperties);
} catch (final IOException e) {
throw new StoreException("Unable to reinitialise delegate graph", e);
}
}
use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class OperationChainHandlerTest method shouldHandleOperationChain.
@Test
public void shouldHandleOperationChain() throws OperationException {
// Given
final OperationChainValidator opChainValidator = mock(OperationChainValidator.class);
final List<OperationChainOptimiser> opChainOptimisers = Collections.emptyList();
final OperationChainHandler opChainHandler = new OperationChainHandler(opChainValidator, opChainOptimisers);
final Context context = mock(Context.class);
final Store store = mock(Store.class);
final User user = mock(User.class);
final StoreProperties storeProperties = new StoreProperties();
final GetAdjacentIds op1 = mock(GetAdjacentIds.class);
final GetElements op2 = mock(GetElements.class);
final OperationChain opChain = new OperationChain(Arrays.asList(op1, op2));
final Entity expectedResult = new Entity(TestGroups.ENTITY);
given(context.getUser()).willReturn(user);
given(store.getProperties()).willReturn(storeProperties);
given(opChainValidator.validate(any(), any(), any())).willReturn(new ValidationResult());
given(store.handleOperation(op1, context)).willReturn(new WrappedCloseableIterable<>(Collections.singletonList(new EntitySeed())));
given(store.handleOperation(op2, context)).willReturn(expectedResult);
// When
final Object result = opChainHandler.doOperation(opChain, context, store);
// Then
assertSame(expectedResult, result);
}
use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class OperationChainHandlerTest method shouldHandleNonInputOperation.
@Test
public void shouldHandleNonInputOperation() throws OperationException {
// Given
final OperationChainValidator opChainValidator = mock(OperationChainValidator.class);
final List<OperationChainOptimiser> opChainOptimisers = Collections.emptyList();
final OperationChainHandler opChainHandler = new OperationChainHandler(opChainValidator, opChainOptimisers);
final Context context = mock(Context.class);
final Store store = mock(Store.class);
final User user = mock(User.class);
final StoreProperties storeProperties = new StoreProperties();
final GetAllElements op = mock(GetAllElements.class);
final OperationChain opChain = new OperationChain(Collections.singletonList(op));
final Entity expectedResult = new Entity(TestGroups.ENTITY);
given(context.getUser()).willReturn(user);
given(store.getProperties()).willReturn(storeProperties);
given(opChainValidator.validate(any(), any(), any())).willReturn(new ValidationResult());
given(store.handleOperation(op, context)).willReturn(expectedResult);
// When
final Object result = opChainHandler.doOperation(opChain, context, store);
// Then
assertSame(expectedResult, result);
}
use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class ScoreOperationChainHandlerTest method shouldResolveScoreOperationChainWithMultipleScoreResolvers.
@Test
public void shouldResolveScoreOperationChainWithMultipleScoreResolvers() throws OperationException {
// Given
final ScoreOperationChainHandler handler = new ScoreOperationChainHandler();
final Map<Class<? extends Operation>, ScoreResolver> resolvers = new HashMap<>();
final ScoreResolver scoreResolver = mock(NamedOperationScoreResolver.class);
final ScoreResolver scoreResolver1 = mock(DefaultScoreResolver.class);
final Context context = mock(Context.class);
final Store store = mock(Store.class);
final User user = mock(User.class);
final ScoreOperationChain scoreOperationChain = mock(ScoreOperationChain.class);
final StoreProperties storeProperties = mock(StoreProperties.class);
final GetAdjacentIds op1 = new GetAdjacentIds();
final AddElements op2 = new AddElements();
final Map<Class<? extends Operation>, Integer> opScores = new LinkedHashMap<>();
opScores.put(GetAdjacentIds.class, 2);
handler.setOpScores(opScores);
final String opName = "namedOp";
final NamedOperation<Iterable<? extends Element>, Iterable<? extends Element>> namedOp = mock(NamedOperation.class);
namedOp.setOperationName(opName);
resolvers.put(namedOp.getClass(), scoreResolver);
resolvers.put(op2.getClass(), scoreResolver1);
handler.setScoreResolvers(resolvers);
given(scoreResolver.getScore(eq(namedOp), any())).willReturn(3);
given(scoreResolver1.getScore(eq(op2), any())).willReturn(5);
final OperationChain opChain = new OperationChain(Arrays.asList(op1, op2, namedOp));
given(context.getUser()).willReturn(user);
Set<String> opAuths = new HashSet<>();
opAuths.add("TEST_USER");
given(user.getOpAuths()).willReturn(opAuths);
given(scoreOperationChain.getOperationChain()).willReturn(opChain);
given(store.getProperties()).willReturn(storeProperties);
// When
final Object result = handler.doOperation(new ScoreOperationChain.Builder().operationChain(opChain).build(), context, store);
// Then
assertEquals(10, result);
}
Aggregations