public void testEmptyGraph() { Graph m = new MultiUnion(); Graph g0 = graphWith( "x p y"); assertEquals( "Empty model should have size zero", 0, m.size() ); assertFalse( "Empty model should not contain another graph", m.dependsOn( g0 ) ); }
public void testEmptyGraph() { Graph m = new MultiUnion(); Graph g0 = graphWith( "x p y"); assertEquals( "Empty model should have size zero", 0, m.size() ); assertFalse( "Empty model should not contain another graph", m.dependsOn( g0 ) ); }
public void testModel() { Graph g0 = graphWith( "x p y" ); MultiUnion u = new MultiUnion( new Graph[] {g0} ); Model m = ModelFactory.createModelForGraph( u ); assertEquals( "Model size not correct", 1, m.size() ); Graph g1 = graphWith( "x p z; z p zz" ); // disjoint with g0 u.addGraph( g1 ); assertEquals( "Model size not correct", 3, m.size() ); // adds one more statement to the model m.read( getFileName("ontology/list0.rdf") ); assertEquals( "Model size not correct", 4, m.size() ); // debug m.write( System.out ); }
public void testModel() { Graph g0 = graphWith( "x p y" ); MultiUnion u = new MultiUnion( new Graph[] {g0} ); Model m = ModelFactory.createModelForGraph( u ); assertEquals( "Model size not correct", 1, m.size() ); Graph g1 = graphWith( "x p z; z p zz" ); // disjoint with g0 u.addGraph( g1 ); assertEquals( "Model size not correct", 3, m.size() ); // adds one more statement to the model m.read( getFileName("ontology/list0.rdf") ); assertEquals( "Model size not correct", 4, m.size() ); // debug m.write( System.out ); }
public void testContains() { Graph g0 = graphWith( "x p y" ); Graph g1 = graphWith( "x p z; z p zz" ); // disjoint with g0 MultiUnion m = new MultiUnion( new Graph[] {g0, g1} ); assertTrue( "m should contain triple", m.contains( triple( "x p y "))); assertTrue( "m should contain triple", m.contains( triple( "x p z "))); assertTrue( "m should contain triple", m.contains( triple( "z p zz "))); assertFalse( "m should not contain triple", m.contains( triple( "zz p z "))); }
public void testContains() { Graph g0 = graphWith( "x p y" ); Graph g1 = graphWith( "x p z; z p zz" ); // disjoint with g0 MultiUnion m = new MultiUnion( new Graph[] {g0, g1} ); assertTrue( "m should contain triple", m.contains( triple( "x p y "))); assertTrue( "m should contain triple", m.contains( triple( "x p z "))); assertTrue( "m should contain triple", m.contains( triple( "z p zz "))); assertFalse( "m should not contain triple", m.contains( triple( "zz p z "))); }
public void testDelete() { Graph g0 = graphWith( "x p y" ); Graph g1 = graphWith( "x p z; z p zz" ); // disjoint with g0 MultiUnion m = new MultiUnion( new Graph[] {g0, g1} ); checkDeleteSizes( 1, 2, 3, g0, g1, m ); m.delete( triple( "x p y") ); checkDeleteSizes( 0, 2, 2, g0, g1, m ); m.delete( triple( "x p y") ); checkDeleteSizes( 0, 2, 2, g0, g1, m ); m.setBaseGraph( g1 ); m.delete( triple( "x p z") ); checkDeleteSizes( 0, 1, 1, g0, g1, m ); m.delete( triple( "z p zz") ); checkDeleteSizes( 0, 0, 0, g0, g1, m ); }
public void testDelete() { Graph g0 = graphWith( "x p y" ); Graph g1 = graphWith( "x p z; z p zz" ); // disjoint with g0 MultiUnion m = new MultiUnion( new Graph[] {g0, g1} ); checkDeleteSizes( 1, 2, 3, g0, g1, m ); m.delete( triple( "x p y") ); checkDeleteSizes( 0, 2, 2, g0, g1, m ); m.delete( triple( "x p y") ); checkDeleteSizes( 0, 2, 2, g0, g1, m ); m.setBaseGraph( g1 ); m.delete( triple( "x p z") ); checkDeleteSizes( 0, 1, 1, g0, g1, m ); m.delete( triple( "z p zz") ); checkDeleteSizes( 0, 0, 0, g0, g1, m ); }
public void testGraphSize1() { Graph g0 = graphWith( "x p y" ); Graph g1 = graphWith( "x p z; z p zz" ); // disjoint with g0 Graph g2 = graphWith( "x p y; z p a" ); // intersects with g1 Graph m01 = new MultiUnion( new Graph[] {g0, g1} ); Graph m10 = new MultiUnion( new Graph[] {g1, g0} ); Graph m12 = new MultiUnion( new Graph[] {g1, g2} ); Graph m21 = new MultiUnion( new Graph[] {g2, g1} ); Graph m02 = new MultiUnion( new Graph[] {g0, g2} ); Graph m20 = new MultiUnion( new Graph[] {g2, g0} ); Graph m00 = new MultiUnion( new Graph[] {g0, g0} ); int s0 = g0.size(); int s1 = g1.size(); int s2 = g2.size(); assertEquals( "Size of union of g0 and g1 not correct", s0+s1, m01.size() ); assertEquals( "Size of union of g1 and g0 not correct", s0+s1, m10.size() ); assertEquals( "Size of union of g1 and g2 not correct", s1+s2, m12.size() ); assertEquals( "Size of union of g2 and g1 not correct", s1+s2, m21.size() ); assertEquals( "Size of union of g0 and g2 not correct", s0+s2 - 1, m02.size() ); assertEquals( "Size of union of g2 and g0 not correct", s0+s2 - 1, m20.size() ); assertEquals( "Size of union of g0 with itself not correct", s0, m00.size() ); }
public void testGraphSize1() { Graph g0 = graphWith( "x p y" ); Graph g1 = graphWith( "x p z; z p zz" ); // disjoint with g0 Graph g2 = graphWith( "x p y; z p a" ); // intersects with g1 Graph m01 = new MultiUnion( new Graph[] {g0, g1} ); Graph m10 = new MultiUnion( new Graph[] {g1, g0} ); Graph m12 = new MultiUnion( new Graph[] {g1, g2} ); Graph m21 = new MultiUnion( new Graph[] {g2, g1} ); Graph m02 = new MultiUnion( new Graph[] {g0, g2} ); Graph m20 = new MultiUnion( new Graph[] {g2, g0} ); Graph m00 = new MultiUnion( new Graph[] {g0, g0} ); int s0 = g0.size(); int s1 = g1.size(); int s2 = g2.size(); assertEquals( "Size of union of g0 and g1 not correct", s0+s1, m01.size() ); assertEquals( "Size of union of g1 and g0 not correct", s0+s1, m10.size() ); assertEquals( "Size of union of g1 and g2 not correct", s1+s2, m12.size() ); assertEquals( "Size of union of g2 and g1 not correct", s1+s2, m21.size() ); assertEquals( "Size of union of g0 and g2 not correct", s0+s2 - 1, m02.size() ); assertEquals( "Size of union of g2 and g0 not correct", s0+s2 - 1, m20.size() ); assertEquals( "Size of union of g0 with itself not correct", s0, m00.size() ); }
public void testGraphSize2() { Graph g0 = graphWith( "x p y" ); Graph g1 = graphWith( "x p z; z p zz" ); // disjoint with g0 Graph g2 = graphWith( "x p y; z p a" ); // intersects with g1 Graph m01 = new MultiUnion( iterateOver( g0, g1 ) ); Graph m10 = new MultiUnion( iterateOver( g1, g0 ) ); Graph m12 = new MultiUnion( iterateOver( g1, g2 ) ); Graph m21 = new MultiUnion( iterateOver( g2, g1 ) ); Graph m02 = new MultiUnion( iterateOver( g0, g2 ) ); Graph m20 = new MultiUnion( iterateOver( g2, g0 ) ); Graph m00 = new MultiUnion( iterateOver( g0, g0 ) ); int s0 = g0.size(); int s1 = g1.size(); int s2 = g2.size(); assertEquals( "Size of union of g0 and g1 not correct", s0+s1, m01.size() ); assertEquals( "Size of union of g1 and g0 not correct", s0+s1, m10.size() ); assertEquals( "Size of union of g1 and g2 not correct", s1+s2, m12.size() ); assertEquals( "Size of union of g2 and g1 not correct", s1+s2, m21.size() ); assertEquals( "Size of union of g0 and g2 not correct", s0+s2 - 1, m02.size() ); assertEquals( "Size of union of g2 and g0 not correct", s0+s2 - 1, m20.size() ); assertEquals( "Size of union of g0 with itself not correct", s0, m00.size() ); }
public void testGraphSize2() { Graph g0 = graphWith( "x p y" ); Graph g1 = graphWith( "x p z; z p zz" ); // disjoint with g0 Graph g2 = graphWith( "x p y; z p a" ); // intersects with g1 Graph m01 = new MultiUnion( iterateOver( g0, g1 ) ); Graph m10 = new MultiUnion( iterateOver( g1, g0 ) ); Graph m12 = new MultiUnion( iterateOver( g1, g2 ) ); Graph m21 = new MultiUnion( iterateOver( g2, g1 ) ); Graph m02 = new MultiUnion( iterateOver( g0, g2 ) ); Graph m20 = new MultiUnion( iterateOver( g2, g0 ) ); Graph m00 = new MultiUnion( iterateOver( g0, g0 ) ); int s0 = g0.size(); int s1 = g1.size(); int s2 = g2.size(); assertEquals( "Size of union of g0 and g1 not correct", s0+s1, m01.size() ); assertEquals( "Size of union of g1 and g0 not correct", s0+s1, m10.size() ); assertEquals( "Size of union of g1 and g2 not correct", s1+s2, m12.size() ); assertEquals( "Size of union of g2 and g1 not correct", s1+s2, m21.size() ); assertEquals( "Size of union of g0 and g2 not correct", s0+s2 - 1, m02.size() ); assertEquals( "Size of union of g2 and g0 not correct", s0+s2 - 1, m20.size() ); assertEquals( "Size of union of g0 with itself not correct", s0, m00.size() ); }