GetGraphFrameOfElements implements
        Output<GraphFrame>,
        GraphFilters { @Override public ValidationResult validate() { final ValidationResult result = Output.super.validate(); if (result.isValid() && !view.hasEdges() && !view.hasEntities()) { result.addError("Cannot create a GraphFrame unless the View contains edges or entities."); } return result; } GetGraphFrameOfElements(); @Override TypeReference<GraphFrame> getOutputTypeReference(); @Override Map<String, String> getOptions(); @Override void setOptions(final Map<String, String> options); List<Converter> getConverters(); void setConverters(final List<Converter> converters); @Override View getView(); @Override void setView(final View view); @Override DirectedType getDirectedType(); @Override void setDirectedType(final DirectedType directedType); @Override ValidationResult validate(); @Override GetGraphFrameOfElements shallowClone();  }
@Test public void shouldValidateOperationIfViewDoesNotContainEdgesOrEntities() { final GetGraphFrameOfElements opWithEdgesOnly = new GetGraphFrameOfElements.Builder() .view(new View.Builder() .edge(TestGroups.EDGE) .build()) .build(); final GetGraphFrameOfElements opWithEntitiesOnly = new GetGraphFrameOfElements.Builder() .view(new View.Builder() .entity(TestGroups.ENTITY) .build()) .build(); final GetGraphFrameOfElements opWithEmptyView = new GetGraphFrameOfElements.Builder() .view(new View.Builder() .build()) .build(); assertTrue(opWithEdgesOnly.validate().isValid()); assertTrue(opWithEntitiesOnly.validate().isValid()); assertFalse(opWithEmptyView.validate().isValid()); }
@Test public void shouldValidateOperation() { final Operation op = new GetGraphFrameOfElements.Builder() .view(new View.Builder() .edge(TestGroups.EDGE) .entity(TestGroups.ENTITY) .build()) .build(); final ValidationResult validationResult = op.validate(); assertTrue(validationResult.isValid()); }
@Test public void shouldValidateOperationWhenViewContainsElementsWithReservedPropertyNames() { final Operation op = new GetGraphFrameOfElements.Builder() .view(new View.Builder() .entity(TestGroups.ENTITY, new ViewElementDefinition.Builder() .properties("vertex") .build()) .edge(TestGroups.EDGE) .build()) .build(); final ValidationResult validationResult = op.validate(); assertTrue(validationResult.isValid()); }