@Test public void shouldTestElementOnPredicate2WithValidationResult() { // Given final KoryphePredicate2<String, String> predicate2 = new KoryphePredicate2<String, String>() { @Override public boolean test(final String o, final String o2) { return "value".equals(o) && "value2".equals(o2); } }; final ElementFilter filter = new ElementFilter.Builder() .select("prop1", "prop2") .execute(predicate2) .build(); final Entity element1 = new Entity.Builder() .property("prop1", "value") .property("prop2", "value2") .build(); final Entity element2 = new Entity.Builder() .property("prop1", "unknown") .property("prop2", "value2") .build(); // When final ValidationResult result1 = filter.testWithValidationResult(element1); final ValidationResult result2 = filter.testWithValidationResult(element2); // Then assertTrue(result1.isValid()); assertFalse(result2.isValid()); assertTrue("Result was: " + result2.getErrorString(), result2.getErrorString().contains("{prop1: <java.lang.String>unknown, prop2: <java.lang.String>value2}")); }
public void validateGraph(final Store store, final String graphId, final Schema schema, final StoreProperties storeProperties, final List<String> parentSchemaIds, final String parentStorePropertiesId, final Pair<Schema, StoreProperties> existingGraphPair) { ValidationResult result = validate(store, graphId, schema, storeProperties, parentSchemaIds, parentStorePropertiesId, existingGraphPair, new ValidationResult()); if (!result.isValid()) { throw new IllegalArgumentException(result.getErrorString()); } }
public static void validate(final Store store, final String graphId, final Schema schema, final StoreProperties storeProperties, final List<String> parentSchemaIds, final String parentStorePropertiesId, final Pair<Schema, StoreProperties> existingGraphPair) { ValidationResult result = validate(store, graphId, schema, storeProperties, parentSchemaIds, parentStorePropertiesId, existingGraphPair, new ValidationResult()); if (!result.isValid()) { throw new IllegalArgumentException(result.getErrorString()); } }
@Override public void validateGraph(final Store store, final String graphId, final Schema schema, final StoreProperties storeProperties, final List<String> parentSchemaIds, final String parentStorePropertiesId, final Pair<Schema, StoreProperties> existingGraphPair) { ValidationResult result = super.validate(store, graphId, schema, storeProperties, parentSchemaIds, parentStorePropertiesId, existingGraphPair, new ValidationResult()); Set<String> errors = result.getErrors(); result.getErrors().removeIf(s -> s.equals(String.format(CANT_BOTH_BE_NULL, SCHEMA_STRING, PARENT_SCHEMA_IDS)) || s.equals(String.format(CANT_BOTH_BE_NULL, STORE_PROPERTIES_STRING, PARENT_STORE_PROPERTIES_ID))); result = new ValidationResult(); for (final String error : errors) { result.addError(error); } if (graphId.equals(store.getGraphId())) { result.addError(String.format(CANNOT_EXPORT_TO_THE_SAME_GRAPH_S, graphId)); } if (!result.isValid()) { throw new IllegalArgumentException(result.getErrorString()); } }
throw new IllegalArgumentException(result.getErrorString());
+ validationResult.getErrorString() + "\nEither delete the table and let Gaffer create it for you or fix it manually using the Accumulo shell or the Gaffer AddUpdateTableIterator utility.");