/** * Test Count, VertexCount and EdgeCount with a single graph. * * @throws Exception if the execution fails. */ @Test public void testSingleGraphCount() throws Exception { LogicalGraph graph = getLoaderFromString("[()-->()<--()]").getLogicalGraph(); VertexCount vertexCount = new VertexCount(); EdgeCount edgeCount = new EdgeCount(); Count count = new Count(); graph = graph .aggregate(vertexCount) .aggregate(edgeCount) .aggregate(count); EPGMGraphHead graphHead = graph.getGraphHead().collect().get(0); assertTrue("vertex count not set", graphHead.hasProperty(vertexCount.getAggregatePropertyKey())); assertTrue("edge count not set", graphHead.hasProperty(edgeCount.getAggregatePropertyKey())); assertTrue("element count not set", graphHead.hasProperty(count.getAggregatePropertyKey())); assertCounts(graphHead, 3L, 2L); }
/** * Test HasVertexLabel with a single graph and result false. * * @throws Exception if the execution or IO fails. */ @Test public void testSingleGraphHasVertexLabelTrue() throws Exception { LogicalGraph graph = getSocialNetworkLoader().getLogicalGraphByVariable("g2"); HasVertexLabel hasPerson = new HasVertexLabel("Person"); graph = graph.aggregate(hasPerson); EPGMGraphHead graphHead = graph.getGraphHead().collect().get(0); assertTrue("Property hasVertexLabel_Person not set", graphHead.hasProperty(hasPerson.getAggregatePropertyKey())); assertTrue("Property hasVertexLabel_Person is false, should be true", graphHead.getPropertyValue(hasPerson.getAggregatePropertyKey()).getBoolean()); }
/** * Test HasLabel with a single graph and result true. * * @throws Exception if the execution or IO fails. */ @Test public void testSingleGraphHasElementLabelTrue() throws Exception { LogicalGraph graph = getSocialNetworkLoader().getLogicalGraphByVariable("g2"); HasLabel hasPerson = new HasLabel("Person"); graph = graph.aggregate(hasPerson); EPGMGraphHead graphHead = graph.getGraphHead().collect().get(0); assertTrue("Property hasLabel_Person not set", graphHead.hasProperty(hasPerson.getAggregatePropertyKey())); assertTrue("Property hasLabel_Person is false, should be true", graphHead.getPropertyValue(hasPerson.getAggregatePropertyKey()).getBoolean()); }
/** * Test HasEdgeLabel with a single graph and result true. * * @throws Exception if the execution or IO fails. */ @Test public void testSingleGraphHasEdgeLabelTrue() throws Exception { LogicalGraph graph = getSocialNetworkLoader().getLogicalGraphByVariable("g2"); HasEdgeLabel hasKnows = new HasEdgeLabel("knows"); graph = graph.aggregate(hasKnows); EPGMGraphHead graphHead = graph.getGraphHead().collect().get(0); assertTrue("Property hasEdgeLabel_knows not set", graphHead.hasProperty(hasKnows.getAggregatePropertyKey())); assertTrue("Property hasEdgeLabel_knows is false, should be true", graphHead.getPropertyValue(hasKnows.getAggregatePropertyKey()).getBoolean()); }
/** * Test HasLabel with a single graph and result false. * * @throws Exception if the execution or IO fails. */ @Test public void testSingleGraphHasElementLabelFalse() throws Exception { LogicalGraph graph = getSocialNetworkLoader().getLogicalGraphByVariable("g2"); HasLabel hasNotExistent = new HasLabel("LabelDoesNotExist"); graph = graph.aggregate(hasNotExistent); EPGMGraphHead graphHead = graph.getGraphHead().collect().get(0); assertTrue("Property hasLabel_LabelDoesNotExist not set", graphHead.hasProperty(hasNotExistent.getAggregatePropertyKey())); assertFalse("Property hasLabel_LabelDoesNotExist is true, should be false", graphHead.getPropertyValue(hasNotExistent.getAggregatePropertyKey()).getBoolean()); }
/** * Test HasVertexLabel with a single graph and result false. * * @throws Exception if the execution or IO fails. */ @Test public void testSingleGraphHasVertexLabelFalse() throws Exception { LogicalGraph graph = getSocialNetworkLoader().getLogicalGraphByVariable("g2"); HasVertexLabel hasNotExistent = new HasVertexLabel("LabelDoesNotExist"); graph = graph.aggregate(hasNotExistent); EPGMGraphHead graphHead = graph.getGraphHead().collect().get(0); assertTrue("Property hasVertexLabel_LabelDoesNotExist not set", graphHead.hasProperty(hasNotExistent.getAggregatePropertyKey())); assertFalse("Property hasVertexLabel_LabelDoesNotExist is true, should be false", graphHead.getPropertyValue(hasNotExistent.getAggregatePropertyKey()).getBoolean()); }
/** * Test HasEdgeLabel with a single graph and result false. * * @throws Exception if the execution or IO fails. */ @Test public void testSingleGraphHasEdgeLabelFalse() throws Exception { LogicalGraph graph = getSocialNetworkLoader().getLogicalGraphByVariable("g2"); HasEdgeLabel hasNotExistent = new HasEdgeLabel("LabelDoesNotExist"); graph = graph.aggregate(hasNotExistent); EPGMGraphHead graphHead = graph.getGraphHead().collect().get(0); assertTrue("Property hasEdgeLabel_LabelDoesNotExist not set", graphHead.hasProperty(hasNotExistent.getAggregatePropertyKey())); assertFalse("Property hasEdgeLabel_LabelDoesNotExist is true, should be false", graphHead.getPropertyValue(hasNotExistent.getAggregatePropertyKey()).getBoolean()); }
/** * Test HasLabel with a single graph and empty label string. * * @throws Exception if the execution fails. */ @Test public void testSingleGraphHasElementLabelEmptyString() throws Exception { LogicalGraph graph = getLoaderFromString("g0[(v0)-[e0]->(v1)]") .getLogicalGraphByVariable("g0"); HasLabel hasLabel = new HasLabel(""); graph = graph.aggregate(hasLabel); EPGMGraphHead graphHead = graph.getGraphHead().collect().get(0); assertTrue("Property hasLabel_ not set", graphHead.hasProperty(hasLabel.getAggregatePropertyKey())); assertTrue("Property hasLabel_ is false, should be true", graphHead.getPropertyValue(hasLabel.getAggregatePropertyKey()).getBoolean()); }
/** * Test HasEdgeLabel with a single edgeless graph. * * @throws Exception if the execution fails. */ @Test public void testEdgelessGraphHasEdgeLabel() throws Exception { LogicalGraph graph = getLoaderFromString("g0[(v0)(v1)]") .getLogicalGraphByVariable("g0"); HasEdgeLabel hasLabel = new HasEdgeLabel("anyLabel"); graph = graph.aggregate(hasLabel); EPGMGraphHead graphHead = graph.getGraphHead().collect().get(0); assertTrue("Property hasEdgeLabel_anyLabel not set", graphHead.hasProperty(hasLabel.getAggregatePropertyKey())); assertNull("Property hasEdgeLabel_anyLabel is not NULL", graphHead.getPropertyValue(hasLabel.getAggregatePropertyKey()).getObject()); }
/** * Test HasVertexLabel with a single graph and empty label string. * * @throws Exception if the execution fails. */ @Test public void testSingleGraphHasVertexLabelEmptyString() throws Exception { LogicalGraph graph = getLoaderFromString("g0[(v0)-[e0]->(v1)]") .getLogicalGraphByVariable("g0"); HasVertexLabel hasLabel = new HasVertexLabel(""); graph = graph.aggregate(hasLabel); EPGMGraphHead graphHead = graph.getGraphHead().collect().get(0); assertTrue("Property hasVertexLabel_ not set", graphHead.hasProperty(hasLabel.getAggregatePropertyKey())); assertTrue("Property hasVertexLabel_ is false, should be true", graphHead.getPropertyValue(hasLabel.getAggregatePropertyKey()).getBoolean()); }
/** * Test HasLabel with a single empty graph. * * @throws Exception if the execution fails. */ @Test public void testEmptyGraphHasElementLabel() throws Exception { LogicalGraph graph = getLoaderFromString("g0[]") .getLogicalGraphByVariable("g0"); HasLabel hasLabel = new HasLabel("anyLabel"); graph = graph.aggregate(hasLabel); EPGMGraphHead graphHead = graph.getGraphHead().collect().get(0); assertTrue("Property hasLabel_anyLabel not set", graphHead.hasProperty(hasLabel.getAggregatePropertyKey())); assertNull("Property hasLabel_anyLabel is not NULL", graphHead.getPropertyValue(hasLabel.getAggregatePropertyKey()).getObject()); }
assertTrue("edge sum not set", graphHead.hasProperty( sumEdgeProperty.getAggregatePropertyKey())); assertTrue("vertex sum not set", graphHead.hasProperty( sumVertexProperty.getAggregatePropertyKey())); assertTrue("element sum not set", graphHead.hasProperty( sumProperty.getAggregatePropertyKey()));
graphHead.hasProperty(minEdgeProperty.getAggregatePropertyKey())); assertTrue("vertex minimum not set", graphHead.hasProperty(minVertexProperty.getAggregatePropertyKey())); assertTrue("element minimum not set", graphHead.hasProperty(minProperty.getAggregatePropertyKey())); assertEquals( 2,
graphHead.hasProperty(maxEdgeProperty.getAggregatePropertyKey())); assertEquals( 3.1f, maxVertexProperty.getAggregatePropertyKey()).getFloat(), 0.00001f); assertTrue("edge maximum not set", graphHead.hasProperty(maxVertexProperty.getAggregatePropertyKey())); assertEquals( 2, maxEdgeProperty.getAggregatePropertyKey()).getInt()); assertTrue("element maximum not set", graphHead.hasProperty(maxProperty.getAggregatePropertyKey())); assertEquals( 3.1f,
graphHead.hasProperty(sumEdgeProperty.getAggregatePropertyKey())); assertTrue("vertex sum not set", graphHead.hasProperty(sumVertexProperty.getAggregatePropertyKey())); assertTrue("element sum not set", graphHead.hasProperty(sumProperty.getAggregatePropertyKey())); assertEquals( 2,
graphHead.hasProperty(hasOtherLabel.getAggregatePropertyKey())); assertFalse("Property hasEdgeLabel_otherLabel is true, should be false", graphHead.getPropertyValue(hasOtherLabel.getAggregatePropertyKey()).getBoolean()); graphHead.hasProperty(hasSomeLabel.getAggregatePropertyKey())); assertFalse("Property hasVertexLabel_someLabel is true, should be false", graphHead.getPropertyValue(hasSomeLabel.getAggregatePropertyKey()).getBoolean()); graphHead.hasProperty(hasThirdLabel.getAggregatePropertyKey())); assertFalse("Property hasLabel_thirdLabel is true, should be false", graphHead.getPropertyValue(hasThirdLabel.getAggregatePropertyKey()).getBoolean());
graphHead.hasProperty(hasPerson.getAggregatePropertyKey())); assertTrue("Property hasVertexLabel_Person is false, should be true", graphHead.getPropertyValue(hasPerson.getAggregatePropertyKey()).getBoolean()); graphHead.hasProperty(hasKnows.getAggregatePropertyKey())); assertTrue("Property hasEdgeLabel_knows is false, should be true", graphHead.getPropertyValue(hasKnows.getAggregatePropertyKey()).getBoolean()); graphHead.hasProperty(hasKnowsElement.getAggregatePropertyKey())); assertTrue("Property hasLabel_knows is false, should be true", graphHead.getPropertyValue(hasKnowsElement.getAggregatePropertyKey()).getBoolean());
assertTrue("vertex count not set", graphHead.hasProperty( vertexCount.getAggregatePropertyKey())); assertTrue("edge count not set", graphHead.hasProperty( edgeCount.getAggregatePropertyKey())); assertTrue("element count not set", graphHead.hasProperty( count.getAggregatePropertyKey()));
assertTrue("edge minimum not set", graphHead.hasProperty (minEdgeProperty.getAggregatePropertyKey())); assertTrue("vertex minimum not set", graphHead.hasProperty (minVertexProperty.getAggregatePropertyKey())); assertTrue("element minimum not set", graphHead.hasProperty (minProperty.getAggregatePropertyKey()));
graphHead.hasProperty(maxEdgeProperty.getAggregatePropertyKey())); assertTrue("vertex maximum not set", graphHead.hasProperty(maxVertexProperty.getAggregatePropertyKey())); assertTrue("element maximum not set", graphHead.hasProperty(maxVertexProperty.getAggregatePropertyKey()));