use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class ScoreOperationChainHandlerTest method shouldExecuteScoreChainOperation.
@Test
public void shouldExecuteScoreChainOperation() throws OperationException {
// Given
final ScoreOperationChainHandler operationHandler = new ScoreOperationChainHandler();
final Context context = mock(Context.class);
final Store store = mock(Store.class);
final User user = mock(User.class);
final ScoreOperationChain scoreOperationChain = mock(ScoreOperationChain.class);
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 Integer expectedResult = 2;
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 = operationHandler.doOperation(new ScoreOperationChain.Builder().operationChain(opChain).build(), context, store);
// Then
assertSame(expectedResult, result);
}
use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class ScoreOperationChainHandlerTest method shouldExecuteScoreChainOperationForNestedOperationChain.
@Test
public void shouldExecuteScoreChainOperationForNestedOperationChain() throws OperationException {
// Given
final ScoreOperationChainHandler operationHandler = new ScoreOperationChainHandler();
final Context context = mock(Context.class);
final Store store = mock(Store.class);
final User user = mock(User.class);
final ScoreOperationChain scoreOperationChain = mock(ScoreOperationChain.class);
StoreProperties storeProperties = new StoreProperties();
final GetAdjacentIds op1 = mock(GetAdjacentIds.class);
final GetElements op2 = mock(GetElements.class);
final Limit op3 = mock(Limit.class);
final OperationChain opChain1 = new OperationChain(Arrays.asList(op1, op2));
final OperationChain opChain = new OperationChain(Arrays.asList(opChain1, op3));
final Integer expectedResult = 3;
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 = operationHandler.doOperation(new ScoreOperationChain.Builder().operationChain(opChain).build(), context, store);
// Then
assertSame(expectedResult, result);
}
use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class AddSchemaToLibraryHandlerTest method shouldNotSupportAddToGraphLibraryII.
@Test
public void shouldNotSupportAddToGraphLibraryII() throws Exception {
// given
store.setGraphLibrary(new NoGraphLibrary());
// when
store.initialise(TEST_STORE_ID, new Schema(), new StoreProperties());
// then
assertFalse(store.isSupported(AddSchemaToLibrary.class));
}
use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class AddSchemaToLibraryHandlerTest method shouldAddSchemaWithGraphLibrary.
@Test
public void shouldAddSchemaWithGraphLibrary() throws Exception {
// given
HashMapGraphLibrary library = new HashMapGraphLibrary();
store.setGraphLibrary(library);
store.initialise(TEST_STORE_ID, new Schema(), new StoreProperties());
// when
store.execute(new Builder().schema(schema).id(TEST_SCHEMA_ID).build(), new Context(StoreUser.blankUser()));
// then
Schema actualSchema = library.getSchema(TEST_SCHEMA_ID);
assertEquals(schema, actualSchema);
}
use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class AddSchemaToLibraryHandlerTest method shouldThrowWithNoGraphLibrary.
@Test
public void shouldThrowWithNoGraphLibrary() throws Exception {
// given
store.initialise(TEST_STORE_ID, new Schema(), new StoreProperties());
try {
// when
store.execute(new Builder().schema(schema).id(TEST_SCHEMA_ID).build(), new Context(StoreUser.blankUser()));
fail("Exception expected");
} catch (final Exception e) {
// then
assertEquals(String.format("Operation class %s is not supported by the %s.", AddSchemaToLibrary.class.getName(), TestAddToGraphLibraryImpl.class.getSimpleName()), e.getMessage());
}
}
Aggregations