use of uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclarations in project Gaffer by gchq.
the class ScoreOperationChainHandlerTest method shouldLoadFromScoreOperationChainDeclarationFile.
@Test
public void shouldLoadFromScoreOperationChainDeclarationFile() throws SerialisationException {
final InputStream s = StreamUtil.openStream(getClass(), "TestScoreOperationChainDeclaration.json");
final OperationDeclarations deserialised = JSONSerialiser.deserialise(s, OperationDeclarations.class);
assertEquals(1, deserialised.getOperations().size());
assert (deserialised.getOperations().get(0).getHandler() instanceof ScoreOperationChainHandler);
}
use of uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclarations in project Gaffer by gchq.
the class StoreTest method shouldCreateStoreWithValidSchemasAndRegisterOperations.
@Test
public void shouldCreateStoreWithValidSchemasAndRegisterOperations() throws StoreException {
// Given
final StoreProperties properties = mock(StoreProperties.class);
final OperationHandler<AddElements> addElementsHandlerOverridden = mock(OperationHandler.class);
final OperationDeclarations opDeclarations = new OperationDeclarations.Builder().declaration(new OperationDeclaration.Builder().operation(AddElements.class).handler(addElementsHandlerOverridden).build()).build();
given(properties.getOperationDeclarations()).willReturn(opDeclarations);
given(properties.getJobExecutorThreadCount()).willReturn(1);
// When
store.initialise("graphId", schema, properties);
// Then
assertNotNull(store.getOperationHandlerExposed(Validate.class));
assertSame(addElementsHandlerOverridden, store.getOperationHandlerExposed(AddElements.class));
assertSame(getAllElementsHandler, store.getOperationHandlerExposed(GetAllElements.class));
assertTrue(store.getOperationHandlerExposed(GenerateElements.class) instanceof GenerateElementsHandler);
assertTrue(store.getOperationHandlerExposed(GenerateObjects.class) instanceof GenerateObjectsHandler);
assertTrue(store.getOperationHandlerExposed(CountGroups.class) instanceof CountGroupsHandler);
assertTrue(store.getOperationHandlerExposed(ToSet.class) instanceof ToSetHandler);
assertTrue(store.getOperationHandlerExposed(ExportToSet.class) instanceof ExportToSetHandler);
assertTrue(store.getOperationHandlerExposed(GetSetExport.class) instanceof GetSetExportHandler);
assertEquals(1, store.getCreateOperationHandlersCallCount());
assertSame(schema, store.getSchema());
assertSame(properties, store.getProperties());
verify(schemaOptimiser).optimise(store.getSchema(), true);
}
use of uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclarations in project Gaffer by gchq.
the class ExportToOtherAuthorisedGraphHandlerTest method shouldGetHandlerFromJson.
@Test
public void shouldGetHandlerFromJson() throws OperationException {
// Given
OperationDeclarations opDeclarations = OperationDeclarations.fromPaths("src/test/resources/ExportToOtherAuthorisedGraphOperationDeclarations.json");
OperationDeclaration opDeclaration = opDeclarations.getOperations().get(0);
OperationHandler handler = opDeclaration.getHandler();
// When / Then
assertThat(handler.getClass().getName()).contains("AuthorisedGraph");
}
Aggregations