Schema extends ElementDefinitions<SchemaEntityDefinition, SchemaEdgeDefinition> implements Cloneable { public boolean hasValidation() { for (final SchemaElementDefinition elementDef : new ChainedIterable<SchemaElementDefinition>(getEntities().values(), getEdges().values())) { if (null != elementDef) { if (elementDef.hasValidation()) { return true; } } } return false; } Schema(); protected  Schema(final Map<String, TypeDefinition> types); static Schema fromJson(final InputStream... inputStreams); static Schema fromJson(final Path... filePaths); static Schema fromJson(final byte[]... jsonBytes); @Deprecated String getId(); @Deprecated void setId(final String id); @SuppressWarnings("CloneDoesntCallSuperClone") @SuppressFBWarnings(value = "CN_IDIOM_NO_SUPER_CALL", justification = "Uses toJson instead.") @Override Schema clone(); @JsonIgnore boolean isAggregationEnabled(); @JsonIgnore List<String> getAggregatedGroups(); ValidationResult validate(); boolean hasValidation(); Map<String, TypeDefinition> getTypes(); TypeDefinition getType(final String typeName); @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "class") Serialiser getVertexSerialiser(); @Deprecated @JsonIgnore String getVertexSerialiserClass(); @Override SchemaElementDefinition getElement(final String group); String getVisibilityProperty(); @Deprecated String getTimestampProperty(); Map<String, String> getConfig(); String getConfig(final String key); void addConfig(final String key, final String value); @Override String toString(); byte[] toCompactJson();  }
@Test public void shouldReturnTrueWhenSchemaHasValidatorEntityFilters() { final Schema schema = new Schema.Builder() .entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder() .validator(new ElementFilter.Builder().select(TestPropertyNames.PROP_1) .execute(new Exists()).build()) .build()) .edge(TestGroups.EDGE, new SchemaEdgeDefinition()).build(); final boolean result = schema.hasValidation(); assertTrue(result); }
@Test public void shouldReturnTrueWhenSchemaHasValidatorEntityPropertyFilters() { final Schema schema = new Schema.Builder() .entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder() .property(TestPropertyNames.PROP_1, "str").build()) .type("str", new TypeDefinition.Builder().validateFunctions(new Exists()).build()) .edge(TestGroups.EDGE, new SchemaEdgeDefinition()).build(); final boolean result = schema.hasValidation(); assertTrue(result); }
@Test public void shouldReturnTrueWhenSchemaHasValidatorEntityIdentifierFilters() { final Schema schema = new Schema.Builder() .entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().vertex("str").build()) .type("str", new TypeDefinition.Builder().validateFunctions(new Exists()).build()) .edge(TestGroups.EDGE, new SchemaEdgeDefinition()).build(); final boolean result = schema.hasValidation(); assertTrue(result); }
@Test public void shouldReturnTrueWhenSchemaHasValidatorEdgeFilters() { final Schema schema = new Schema.Builder() .edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().validator(new ElementFilter.Builder() .select(TestPropertyNames.PROP_1).execute(new Exists()) .build()).build()) .edge(TestGroups.ENTITY, new SchemaEdgeDefinition()).build(); final boolean result = schema.hasValidation(); assertTrue(result); }
@Test public void shouldReturnTrueWhenSchemaHasValidatorEdgePropertyFilters() { final Schema schema = new Schema.Builder() .edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder() .property(TestPropertyNames.PROP_1, "str").build()) .type("str", new TypeDefinition.Builder().validateFunctions(new Exists()).build()) .edge(TestGroups.ENTITY, new SchemaEdgeDefinition()).build(); final boolean result = schema.hasValidation(); assertTrue(result); }
@Test public void shouldReturnTrueWhenSchemaHasValidatorEdgeIdentifierFilters() { final Schema schema = new Schema.Builder() .edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source("str").destination("dest") .build()) .type("str", new TypeDefinition.Builder().validateFunctions(new Exists()).build()) .edge(TestGroups.EDGE_2, new SchemaEdgeDefinition.Builder().source("src") .destination("dest").build()) .build(); final boolean result = schema.hasValidation(); assertTrue(result); }
@Test public void shouldReturnFalseWhenSchemaHasNullValidatorEdgeFilters() { final Schema schema = new Schema.Builder() .edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().validator(null).build()) .build(); final boolean result = schema.hasValidation(); assertFalse(result); }
@Test public void shouldReturnFalseWhenSchemaHasEmptyValidatorEdgeFilters() { final Schema schema = new Schema.Builder() .edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder() .validator(new ElementFilter.Builder().build()).build()) .build(); final boolean result = schema.hasValidation(); assertFalse(result); }