@@ -0,0 +1,3031 @@
+package com.github.anno4j.querying.tests;%0A%0Aimport com.github.anno4j.Anno4j;%0Aimport com.github.anno4j.model.Annotation;%0Aimport com.github.anno4j.model.Body;%0Aimport com.github.anno4j.querying.QueryService;%0Aimport com.google.gson.Gson;%0Aimport org.apache.marmotta.ldpath.parser.ParseException;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.openrdf.annotations.Iri;%0Aimport org.openrdf.query.MalformedQueryException;%0Aimport org.openrdf.query.QueryEvaluationException;%0Aimport org.openrdf.repository.RepositoryException;%0A%0Aimport java.util.List;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0A/**%0A * Created by schlegel on 09/10/15.%0A */%0Apublic class UnionTest %7B%0A%0A    private QueryService%3CAnnotation%3E queryService = null;%0A%0A    @Before%0A    public void resetQueryService() throws RepositoryException %7B%0A        queryService = Anno4j.getInstance().createQueryService(Annotation.class);%0A        queryService.addPrefix(%22ex%22, %22http://www.example.com/schema#%22);%0A    %7D%0A%0A    @Test%0A    public void testUnionBody() throws RepositoryException, QueryEvaluationException, MalformedQueryException, ParseException %7B%0A        // Persisting some data%0A        Annotation annotation = new Annotation();%0A        annotation.setSerializedAt(%2207.05.2015%22);%0A        annotation.setBody(new UnionTestBody1(%22Value1%22));%0A        Anno4j.getInstance().createPersistenceService().persistAnnotation(annotation);%0A%0A        Annotation annotation1 = new Annotation();%0A        annotation1.setAnnotatedAt(%2201.01.2011%22);%0A        annotation1.setBody(new UnionTestBody2(%22Value2%22));%0A        Anno4j.getInstance().createPersistenceService().persistAnnotation(annotation1);%0A%0A        List%3CAnnotation%3E annotations = queryService%0A                .setBodyCriteria(%22ex:hasBody %7C ex:hasTarget%22)%0A                .execute();%0A        %0A        assertEquals(2, annotations.size());%0A    %7D%0A%0A    @Iri(%22http://www.example.com/schema#unionBody1%22)%0A    public static class UnionTestBody1 extends Body %7B%0A%0A        @Iri(%22http://www.example.com/schema#value%22)%0A        private String value;%0A%0A        public UnionTestBody1() %7B%0A        %7D%0A%0A        public UnionTestBody1(String value) %7B%0A            this.value = value;%0A        %7D%0A%0A        public String getValue() %7B%0A            return value;%0A        %7D%0A%0A        public void setValue(String value) %7B%0A            this.value = value;%0A        %7D%0A%0A        @Override%0A        public String toString() %7B%0A            return new Gson().toJson(this);%0A        %7D%0A    %7D%0A%0A    @Iri(%22http://www.example.com/schema#unionBody2%22)%0A    public static class UnionTestBody2 extends Body %7B%0A%0A        @Iri(%22http://www.example.com/schema#value%22)%0A        private String value;%0A%0A        public UnionTestBody2() %7B%0A        %7D%0A%0A        public UnionTestBody2(String value) %7B%0A            this.value = value;%0A        %7D%0A%0A        public String getValue() %7B%0A            return value;%0A        %7D%0A%0A        public void setValue(String value) %7B%0A            this.value = value;%0A        %7D%0A%0A        @Override%0A        public String toString() %7B%0A            return new Gson().toJson(this);%0A        %7D%0A    %7D%0A%7D%0A

add union test