Search in sources :

Example 6 with OperationDeclarations

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);
}
Also used : InputStream(java.io.InputStream) OperationDeclarations(uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclarations) Test(org.junit.jupiter.api.Test)

Example 7 with OperationDeclarations

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);
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) CountGroupsHandler(uk.gov.gchq.gaffer.store.operation.handler.CountGroupsHandler) ToSetHandler(uk.gov.gchq.gaffer.store.operation.handler.output.ToSetHandler) ExportToSetHandler(uk.gov.gchq.gaffer.store.operation.handler.export.set.ExportToSetHandler) GenerateObjectsHandler(uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateObjectsHandler) OperationDeclaration(uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclaration) ExportToSetHandler(uk.gov.gchq.gaffer.store.operation.handler.export.set.ExportToSetHandler) GetSetExportHandler(uk.gov.gchq.gaffer.store.operation.handler.export.set.GetSetExportHandler) Validate(uk.gov.gchq.gaffer.operation.impl.Validate) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) GenerateElementsHandler(uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateElementsHandler) OperationDeclarations(uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclarations) Test(org.junit.jupiter.api.Test)

Example 8 with OperationDeclarations

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");
}
Also used : OperationDeclarations(uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclarations) OperationDeclaration(uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclaration) OperationHandler(uk.gov.gchq.gaffer.store.operation.handler.OperationHandler) Test(org.junit.jupiter.api.Test)

Aggregations

OperationDeclarations (uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclarations)8 Test (org.junit.jupiter.api.Test)7 OperationDeclaration (uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclaration)5 GenerateElementsHandler (uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateElementsHandler)3 InputStream (java.io.InputStream)2 GenerateObjectsHandler (uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateObjectsHandler)2 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 EqualsBuilder (org.apache.commons.lang3.builder.EqualsBuilder)1 HashCodeBuilder (org.apache.commons.lang3.builder.HashCodeBuilder)1 ToStringBuilder (uk.gov.gchq.gaffer.commonutil.ToStringBuilder)1 Validate (uk.gov.gchq.gaffer.operation.impl.Validate)1 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)1 GenerateElements (uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements)1 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)1 GetDataFrameOfElements (uk.gov.gchq.gaffer.spark.operation.dataframe.GetDataFrameOfElements)1 GetGraphFrameOfElements (uk.gov.gchq.gaffer.spark.operation.graphframe.GetGraphFrameOfElements)1 GetGraphFrameOfElementsHandler (uk.gov.gchq.gaffer.spark.operation.handler.graphframe.GetGraphFrameOfElementsHandler)1 GetJavaRDDOfAllElements (uk.gov.gchq.gaffer.spark.operation.javardd.GetJavaRDDOfAllElements)1 GetJavaRDDOfElements (uk.gov.gchq.gaffer.spark.operation.javardd.GetJavaRDDOfElements)1 ImportJavaRDDOfElements (uk.gov.gchq.gaffer.spark.operation.javardd.ImportJavaRDDOfElements)1