@Override public Repository createRepository() { return new MiniRepository(); } };
public static Session openSession(Class<?>... classes) { return openSession(new MiniRepository(), classes); }
@Before public void setUp() { MiniRepository repository = new MiniRepository(); RDFConnection connection = new MiniConnection(repository); identityService = new SessionIdentityService(connection); }
@Test public void Update_with_nulls() { RDFConnection conn = new MiniRepository().openConnection(); conn.update(Collections.<STMT> emptySet(), null); conn.update(null, Collections.<STMT> emptySet()); conn.update(null, null); }
@Test public void ToString() { MiniConnection connection = new MiniRepository().openConnection(); RDFQuery query = new RDFQueryImpl(connection); query.where(QNODE.s.a(RDFS.Resource)); assertEquals( "SELECT * WHERE { ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Resource> } ", query.toString().replaceAll("\\s+", " ")); }
@Test public void getId() { MiniRepository repository = new MiniRepository(); Session session = SessionUtil.openSession(repository, EnumType.class, EnumRef.class); assertEquals(new UID(TEST.NS, "PRIMARY"), session.getId(EnumType.PRIMARY)); assertEquals(new UID(TEST.NS, "SECONDARY"), session.getId(EnumType.SECONDARY)); } }
@Test public void Enum() { MiniRepository repository = new MiniRepository(); Session session = SessionUtil.openSession(repository, EnumType.class, EnumRef.class); session.save(new EnumRef(EnumType.SECONDARY)); session = SessionUtil.openSession(repository, EnumType.class, EnumRef.class); EnumRef eref = session.findInstances(EnumRef.class).get(0); assertEquals(EnumType.SECONDARY, eref.etype); }
@Test public void Save() throws IOException { Session session = SessionUtil.openSession(new MiniRepository(), Collections.<Locale> emptySet(), configuration); Category category = new Category(); category.label = "X"; category.children = Collections.singleton(new Category()); session.save(category); session.flush(); session.close(); }
@Test public void test() { Repository repository = new MiniRepository(); Session session = SessionUtil.openSession(repository, Identifiable.class, Elements.class, Element.class, LinkElement.class, TextElement.class); Elements elements = new Elements(); elements.elements = Arrays.<Element> asList(new LinkElement(), new TextElement()); session.save(elements); session.clear(); Elements other = session.getById(elements.id, Elements.class); assertEquals(elements.elements.size(), other.elements.size()); assertNotNull(other.elements.get(0)); assertNotNull(other.elements.get(1)); }
@Test public void ToString_After_Invocation() { MiniConnection connection = new MiniRepository().openConnection(); RDFQuery query = new RDFQueryImpl(connection); query.where(QNODE.s.a(RDFS.Resource)); query.createBooleanQuery(); assertEquals( "SELECT * WHERE { ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Resource> } ", query.toString().replaceAll("\\s+", " ")); }
@Test public void Remove_With_Context() { MiniConnection conn = new MiniRepository().openConnection(); STMT stmt1 = new STMT(RDF.type, RDF.type, RDF.type); STMT stmt2 = new STMT(RDF.type, RDF.type, RDF.type, RDF.type); conn.update(null, Arrays.asList(stmt1, stmt2)); conn.update(Collections.singleton(stmt2), null); assertFalse(conn.exists(null, null, null, RDF.type, false)); assertTrue(conn.exists(RDF.type, RDF.type, RDF.type, null, false)); }
@Before public void setUp() { MiniRepository repository = new MiniRepository(); MultiConnection connection = new MultiConnection(repository.openConnection(), repository.openConnection()); RDFBeanTransaction innerTx = EasyMock.createNiceMock(RDFBeanTransaction.class); tx = new MultiTransaction(connection, new RDFBeanTransaction[] { innerTx }); }
@Before public void setUp() { repository = new MiniRepository(); session = SessionUtil.openSession(repository, Entity.class); Entity entity = new Entity(); entity.property1 = "X"; entity.property2 = "Y"; entity.property3 = "Z"; session.save(entity); session.flush(); session.clear(); }
@Before public void setUp() { sessionFactory = new SessionFactoryImpl(); sessionFactory.setConfiguration(new DefaultConfiguration()); sessionFactory.setRepository(new MiniRepository()); sessionFactory.initialize(); sessionContext = new SimpleSessionContext(sessionFactory); }
@Test(expected = IllegalArgumentException.class) public void Error() { MiniRepository repository = new MiniRepository(); UID id = new UID("http://example2.com/abc"); UID type = new UID(TEST.NS, "IdMappingTest"); repository.add(new STMT(id, RDF.type, type)); Session session = SessionUtil.openSession(repository, IdMappingTest.class); session.get(IdMappingTest.class, id); }
@Test public void Persistence() { MiniRepository repository = new MiniRepository(); Session session = SessionUtil.openSession(repository, Entity.class); Entity entity = new Entity(); entity.name = "John Doe"; session.save(entity); session.flush(); assertFalse(repository.findStatements(null, CORE.localId, null, null, false).hasNext()); } }
@Test public void Success() { MiniRepository repository = new MiniRepository(); Session session = SessionUtil.openSession(repository, IdMappingTest.class); IdMappingTest instance = new IdMappingTest(); instance.id = "abc"; session.save(instance); session.clear(); UID id = new UID("http://example.com/abc"); assertTrue(repository.exists(id, null, null, null)); IdMappingTest instance2 = session.get(IdMappingTest.class, id); assertEquals(instance.id, instance2.id); }
@Before public void setUp() { Configuration configuration = new DefaultConfiguration(TEST.NS, Entity.class); Repository repository = new MiniRepository(); sessionFactory = new SessionFactoryImpl(); sessionFactory.setConfiguration(configuration); sessionFactory.setRepository(repository); sessionFactory.initialize(); Session session = sessionFactory.openSession(); for (int i = 0; i < 10; i++) { session.save(new Entity()); } session.close(); }
@Before public void setUp() { metadata = new DefaultQueryMetadata(); RDFConnection connection = new MiniRepository().openConnection(); Configuration configuration = new DefaultConfiguration(User.class); Ontology ontology = new ConfigurationOntology(configuration); Session session = new SessionImpl(configuration, new ConfigurationOntology(configuration), connection); builder = new RDFQueryBuilder(connection, session, configuration, ontology, metadata); query = new QueryMixin(metadata); }
@Test public void Remove() { MiniConnection conn = new MiniRepository().openConnection(); conn.addStatements(new STMT(new BID(), RDF.type, RDFS.Resource)); assertTrue(conn.exists(null, null, null, null, false)); conn.remove(null, null, null, null); assertFalse(conn.exists(null, null, null, null, false)); }