private static void assumeRequirementsAreMetForTest(final Set<FeatureRequirement> featureRequirementSet, final Graph.Features features, final boolean staticCheck) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { for (FeatureRequirement fr : featureRequirementSet) { try { assumeThat(String.format("Features of the graph do not support all of the features required by this test so it will be ignored: %s.%s=%s", fr.featureClass().getSimpleName(), fr.feature(), fr.supported()), features.supports(fr.featureClass(), fr.feature()), is(fr.supported())); } catch (NoSuchMethodException nsme) { throw new NoSuchMethodException(String.format("[supports%s] is not a valid feature on %s", fr.feature(), fr.featureClass())); } catch (UnsupportedOperationException uoe) { // no worries if this is a check of static features - it just means that we can't use the cache to // support this check and will have to incur the cost of instantiating a graph instance directly. but, // if this is not a static check then something else is amiss and we should throw. if (staticCheck) throw uoe; } } }
@Test @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY) public void shouldEnableFeatureOnVertexIfNotEnabled() throws Exception { assumeThat(graph.features().supports(VertexPropertyFeatures.class, featureName), is(false)); try { graph.addVertex("aKey", value); fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), featureName)); } catch (Exception e) { validateException(Property.Exceptions.dataTypeOfPropertyValueNotSupported(value), e); } }
/** * In this case, the feature requirement for sideEffects is checked, because it means that at least one aspect of * sideEffects is supported so we need to test other features to make sure they work properly. */ @Test @FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_VARIABLES) public void shouldEnableFeatureOnGraphIfNotEnabled() throws Exception { assumeThat(graph.features().supports(Graph.Features.VariableFeatures.class, featureName), is(false)); try { final Graph.Variables variables = graph.variables(); variables.set("aKey", value); fail(String.format(INVALID_FEATURE_SPECIFICATION, Graph.Features.VariableFeatures.class.getSimpleName(), featureName)); } catch (Exception e) { validateException(Graph.Variables.Exceptions.dataTypeOfVariableValueNotSupported(value), e); } } }
@Test @FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = FEATURE_VARIABLES) public void shouldSetValueOnGraph() throws Exception { assumeThat(graph.features().supports(Graph.Features.VariableFeatures.class, featureName), is(true)); final Graph.Variables variables = graph.variables(); variables.set("aKey", value);
private static void assumeRequirementsAreMetForTest(final Set<FeatureRequirement> featureRequirementSet, final Graph.Features features, final boolean staticCheck) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { for (FeatureRequirement fr : featureRequirementSet) { try { assumeThat(String.format("Features of the graph do not support all of the features required by this test so it will be ignored: %s.%s=%s", fr.featureClass().getSimpleName(), fr.feature(), fr.supported()), features.supports(fr.featureClass(), fr.feature()), is(fr.supported())); } catch (NoSuchMethodException nsme) { throw new NoSuchMethodException(String.format("[supports%s] is not a valid feature on %s", fr.feature(), fr.featureClass())); } catch (UnsupportedOperationException uoe) { // no worries if this is a check of static features - it just means that we can't use the cache to // support this check and will have to incur the cost of instantiating a graph instance directly. but, // if this is not a static check then something else is amiss and we should throw. if (staticCheck) throw uoe; } } }
/** * In this case, the feature requirement for sideEffects is checked, because it means that at least one aspect of * sideEffects is supported so we need to test other features to make sure they work properly. */ @Test @FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_VARIABLES) public void shouldEnableFeatureOnGraphIfNotEnabled() throws Exception { assumeThat(graph.features().supports(Graph.Features.VariableFeatures.class, featureName), is(false)); try { final Graph.Variables variables = graph.variables(); variables.set("aKey", value); fail(String.format(INVALID_FEATURE_SPECIFICATION, Graph.Features.VariableFeatures.class.getSimpleName(), featureName)); } catch (Exception e) { validateException(Graph.Variables.Exceptions.dataTypeOfVariableValueNotSupported(value), e); } } }
@Test @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = EdgeFeatures.FEATURE_ADD_PROPERTY) public void shouldEnableFeatureOnEdgeIfNotEnabled() throws Exception { assumeThat(graph.features().supports(EdgePropertyFeatures.class, featureName), is(false)); try { final Edge edge = createEdgeForPropertyFeatureTests(); edge.property("aKey", value); fail(String.format(INVALID_FEATURE_SPECIFICATION, EdgePropertyFeatures.class.getSimpleName(), featureName)); } catch (Exception e) { validateException(Property.Exceptions.dataTypeOfPropertyValueNotSupported(value), e); } }
@Test @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY) public void shouldSetValueOnVertex() throws Exception { assumeThat(graph.features().supports(VertexPropertyFeatures.class, featureName), is(true)); final Vertex vertex = graph.addVertex(); vertex.property(VertexProperty.Cardinality.single, "aKey", value); assertPropertyValue(vertex); }
@Test @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_PROPERTY) public void shouldSetValueOnEdge() throws Exception { assumeThat(graph.features().supports(EdgePropertyFeatures.class, featureName), is(true)); final Edge edge = createEdgeForPropertyFeatureTests(); edge.property("aKey", value); assertPropertyValue(edge); }
@Test @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY) public void shouldEnableFeatureOnVertexIfNotEnabled() throws Exception { assumeThat(graph.features().supports(VertexPropertyFeatures.class, featureName), is(false)); try { graph.addVertex("aKey", value); fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), featureName)); } catch (Exception e) { validateException(Property.Exceptions.dataTypeOfPropertyValueNotSupported(value), e); } }
@Test @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) public void shouldSetValueOnEdgeOnAdd() throws Exception { assumeThat(graph.features().supports(EdgePropertyFeatures.class, featureName), is(true)); final Edge edge = createEdgeForPropertyFeatureTests("aKey", value); assertPropertyValue(edge); }
@Test @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) public void shouldSetValueOnVertexOnAdd() throws Exception { assumeThat(graph.features().supports(VertexPropertyFeatures.class, featureName), is(true)); final Vertex vertex = graph.addVertex("aKey", value); assertPropertyValue(vertex); }
@Test @FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = FEATURE_VARIABLES) public void shouldSetValueOnGraph() throws Exception { assumeThat(graph.features().supports(Graph.Features.VariableFeatures.class, featureName), is(true)); final Graph.Variables variables = graph.variables(); variables.set("aKey", value);
@Test @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = EdgeFeatures.FEATURE_ADD_PROPERTY) public void shouldEnableFeatureOnEdgeIfNotEnabled() throws Exception { assumeThat(graph.features().supports(EdgePropertyFeatures.class, featureName), is(false)); try { final Edge edge = createEdgeForPropertyFeatureTests(); edge.property("aKey", value); fail(String.format(INVALID_FEATURE_SPECIFICATION, EdgePropertyFeatures.class.getSimpleName(), featureName)); } catch (Exception e) { validateException(Property.Exceptions.dataTypeOfPropertyValueNotSupported(value), e); } }
@Test @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) public void shouldSetValueOnEdgeOnAdd() throws Exception { assumeThat(graph.features().supports(EdgePropertyFeatures.class, featureName), is(true)); final Edge edge = createEdgeForPropertyFeatureTests("aKey", value); assertPropertyValue(edge); }
@Test @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY) public void shouldSetValueOnVertex() throws Exception { assumeThat(graph.features().supports(VertexPropertyFeatures.class, featureName), is(true)); final Vertex vertex = graph.addVertex(); vertex.property(VertexProperty.Cardinality.single, "aKey", value); assertPropertyValue(vertex); }
@Test @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) public void shouldSetValueOnVertexOnAdd() throws Exception { assumeThat(graph.features().supports(VertexPropertyFeatures.class, featureName), is(true)); final Vertex vertex = graph.addVertex("aKey", value); assertPropertyValue(vertex); }
@Test @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_PROPERTY) public void shouldSetValueOnEdge() throws Exception { assumeThat(graph.features().supports(EdgePropertyFeatures.class, featureName), is(true)); final Edge edge = createEdgeForPropertyFeatureTests(); edge.property("aKey", value); assertPropertyValue(edge); }