use of uk.gov.gchq.gaffer.rest.model.OperationDetail in project Gaffer by gchq.
the class OperationControllerTest method shouldReturnOptionsAndSummariesForEnumFields.
@Test
public void shouldReturnOptionsAndSummariesForEnumFields() throws Exception {
// Given
when(store.getSupportedOperations()).thenReturn(Sets.newHashSet(GetElements.class));
when(examplesFactory.generateExample(GetElements.class)).thenReturn(new GetElements());
// When
OperationDetail operationDetails = operationController.getOperationDetails(GetElements.class.getName());
List<OperationField> operationFields = operationDetails.getFields();
// Then
final List<OperationField> fields = Arrays.asList(new OperationField("input", null, "java.lang.Object[]", null, false), new OperationField("view", null, "uk.gov.gchq.gaffer.data.elementdefinition.view.View", null, false), new OperationField("includeIncomingOutGoing", "Should the edges point towards, or away from your seeds", "java.lang.String", Sets.newHashSet("INCOMING", "EITHER", "OUTGOING"), false), new OperationField("seedMatching", "How should the seeds be matched?", "java.lang.String", Sets.newHashSet("RELATED", "EQUAL"), false), new OperationField("options", null, "java.util.Map<java.lang.String,java.lang.String>", null, false), new OperationField("directedType", "Is the Edge directed?", "java.lang.String", Sets.newHashSet("DIRECTED", "UNDIRECTED", "EITHER"), false), new OperationField("views", null, "java.util.List<uk.gov.gchq.gaffer.data.elementdefinition.view.View>", null, false));
assertEquals(fields, operationFields);
}
use of uk.gov.gchq.gaffer.rest.model.OperationDetail in project Gaffer by gchq.
the class OperationControllerTest method shouldNotIncludeAnyOutputClassForOperationWithoutOutput.
@Test
public void shouldNotIncludeAnyOutputClassForOperationWithoutOutput() throws Exception {
// Given
when(store.getSupportedOperations()).thenReturn(Sets.newHashSet(DiscardOutput.class));
when(examplesFactory.generateExample(GetElements.class)).thenReturn(new DiscardOutput());
// When
OperationDetail operationDetail = operationController.getOperationDetails(DiscardOutput.class.getName());
byte[] serialised = JSONSerialiser.serialise(operationDetail);
// Then
assertFalse(new String(serialised).contains("outputClassName"));
}
use of uk.gov.gchq.gaffer.rest.model.OperationDetail in project Gaffer by gchq.
the class AbstractOperationService method getSupportedOperationDetails.
public Set<OperationDetail> getSupportedOperationDetails() {
Set<Class<? extends Operation>> supportedOperationClasses = getSupportedOperations();
Set<OperationDetail> operationDetails = new HashSet<>();
for (final Class<? extends Operation> clazz : supportedOperationClasses) {
try {
operationDetails.add(new OperationDetail(clazz, getNextOperations(clazz), generateExampleJson(clazz)));
} catch (final IllegalAccessException | InstantiationException e) {
throw new GafferRuntimeException("Could not get operation details for class: " + clazz, e, Status.BAD_REQUEST);
}
}
return operationDetails;
}
use of uk.gov.gchq.gaffer.rest.model.OperationDetail in project Gaffer by gchq.
the class OperationControllerTest method shouldReturnOperationDetailSummaryOfClass.
@Test
public void shouldReturnOperationDetailSummaryOfClass() {
// Given
when(store.getSupportedOperations()).thenReturn(Sets.newHashSet(GetElements.class));
// When
OperationDetail operationDetail = operationController.getOperationDetails(GetElements.class.getName());
// Then
final String expectedSummary = "Gets elements related to provided seeds";
assertEquals(expectedSummary, operationDetail.getSummary());
}
use of uk.gov.gchq.gaffer.rest.model.OperationDetail in project Gaffer by gchq.
the class OperationControllerTest method shouldReturnOutputClassForOperationWithOutput.
@Test
public void shouldReturnOutputClassForOperationWithOutput() throws Exception {
// Given
when(store.getSupportedOperations()).thenReturn(Sets.newHashSet(GetElements.class));
when(examplesFactory.generateExample(GetElements.class)).thenReturn(new GetElements());
// When
OperationDetail operationDetails = operationController.getOperationDetails(GetElements.class.getName());
// Then
final String expectedOutputString = "uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable<uk.gov.gchq.gaffer.data.element.Element>";
assertEquals(expectedOutputString, operationDetails.getOutputClassName());
}
Aggregations