use of uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclaration in project Gaffer by gchq.
the class OperationDeclarationsTest method testDeserialiseFile.
@Test
public void testDeserialiseFile() throws SerialisationException {
// Given
final String paths = "operationDeclarations1.json,operationDeclarations2.json";
// When
final OperationDeclarations deserialised = OperationDeclarations.fromPaths(paths);
// Then
assertEquals(2, deserialised.getOperations().size());
final OperationDeclaration od0 = deserialised.getOperations().get(0);
final OperationDeclaration od1 = deserialised.getOperations().get(1);
assertEquals(GenerateElements.class, od0.getOperation());
assertTrue(od0.getHandler() instanceof GenerateElementsHandler);
assertEquals(GenerateObjects.class, od1.getOperation());
assertTrue(od1.getHandler() instanceof GenerateObjectsHandler);
}
use of uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclaration in project Gaffer by gchq.
the class OperationDeclarationsTest method testSerialiseDeserialise.
@Test
public void testSerialiseDeserialise() throws SerialisationException {
// Given
final OperationDeclarations declarations = new OperationDeclarations.Builder().declaration(new OperationDeclaration.Builder().handler(new GenerateElementsHandler()).operation(GenerateElements.class).build()).build();
// When
final byte[] definitionJson = JSONSerialiser.serialise(declarations);
final OperationDeclarations deserialised = OperationDeclarations.fromJson(definitionJson);
assertEquals(1, deserialised.getOperations().size());
final OperationDeclaration deserialisedDeclaration = deserialised.getOperations().get(0);
assertEquals(GenerateElements.class, deserialisedDeclaration.getOperation());
assertTrue(deserialisedDeclaration.getHandler() instanceof GenerateElementsHandler);
}
use of uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclaration in project Gaffer by gchq.
the class SparkOperationDeclarationsTest method shouldContainAllSparkOperationsAndHandlers.
@Test
public void shouldContainAllSparkOperationsAndHandlers() throws SerialisationException {
// When
final OperationDeclarations deserialised = JSONSerialiser.deserialise(StreamUtil.openStream(getClass(), ACCUMULO_OP_DECLARATIONS_JSON_PATH), OperationDeclarations.class);
// Then
final List<OperationDeclaration> deserialisedOps = deserialised.getOperations();
final List<OperationDeclaration> expectedOps = Arrays.asList(new Builder().operation(GetJavaRDDOfElements.class).handler(new GetJavaRDDOfElementsHandler()).build(), new Builder().operation(GetRDDOfElements.class).handler(new GetRDDOfElementsHandler()).build(), new Builder().operation(GetRDDOfAllElements.class).handler(new GetRDDOfAllElementsHandler()).build(), new Builder().operation(GetJavaRDDOfAllElements.class).handler(new GetJavaRDDOfAllElementsHandler()).build(), new Builder().operation(GetDataFrameOfElements.class).handler(new GetDataFrameOfElementsHandler()).build(), new Builder().operation(ImportKeyValueJavaPairRDDToAccumulo.class).handler(new ImportKeyValueJavaPairRDDToAccumuloHandler()).build(), new Builder().operation(ImportJavaRDDOfElements.class).handler(new ImportJavaRDDOfElementsHandler()).build(), new Builder().operation(ImportKeyValuePairRDDToAccumulo.class).handler(new ImportKeyValuePairRDDToAccumuloHandler()).build(), new Builder().operation(ImportRDDOfElements.class).handler(new ImportRDDOfElementsHandler()).build(), new Builder().operation(GetGraphFrameOfElements.class).handler(new GetGraphFrameOfElementsHandler()).build(), new Builder().operation(GetJavaRDDOfElementsInRanges.class).handler(new GetJavaRDDOfElementsInRangesHandler()).build(), new Builder().operation(GetRDDOfElementsInRanges.class).handler(new GetRDDOfElementsInRangesHandler()).build(), new Builder().operation(SplitStoreFromJavaRDDOfElements.class).handler(new SplitStoreFromJavaRDDOfElementsHandler()).build(), new Builder().operation(SplitStoreFromRDDOfElements.class).handler(new SplitStoreFromRDDOfElementsHandler()).build());
assertEquals(expectedOps.size(), deserialisedOps.size());
for (int i = 0; i < expectedOps.size(); i++) {
assertEquals(expectedOps.get(i).getOperation(), deserialisedOps.get(i).getOperation());
assertEquals(expectedOps.get(i).getHandler().getClass(), deserialisedOps.get(i).getHandler().getClass());
}
}
use of uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclaration 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