GraphPattern gp = (GraphPattern) ggp.getGraphPatterns().toArray()[0];
Assert.assertTrue(OptionalGraphPattern.class.isAssignableFrom(gp.getClass()));
OptionalGraphPattern ogp = (OptionalGraphPattern) gp;
Assert.assertTrue(BasicGraphPattern.class.isAssignableFrom(
ogp.getMainGraphPattern().getClass()));
BasicGraphPattern bgp = (BasicGraphPattern) ogp.getMainGraphPattern();
Set<TriplePattern> triplePatterns = bgp.getTriplePatterns();
Assert.assertTrue(triplePatterns.size() == 1);
Assert.assertTrue(triplePatterns.contains(
new SimpleTriplePattern(var1, new UriRef(prefix1Uri + predicate1),
var2)));
GraphPattern gp2 = (GraphPattern) ogp.getOptionalGraphPattern()
.getGraphPatterns().toArray()[0];
Assert.assertTrue(BasicGraphPattern.class.isAssignableFrom(gp2.getClass()));
bgp = (BasicGraphPattern) gp2;
triplePatterns = bgp.getTriplePatterns();
Assert.assertTrue(triplePatterns.size() == 1);
Assert.assertTrue(triplePatterns.contains(
new SimpleTriplePattern(var1, new UriRef(prefix2Uri + predicate2),
var3)));
}