Package org.jboss.dna.connector.store.jpa.model.common

Examples of org.jboss.dna.connector.store.jpa.model.common.NamespaceEntity


    @SuppressWarnings( "unchecked" )
    @Test
    public void shouldFindEntitiesInIndexRange() {
        Long workspaceId = 1L;
        UUID parentUuid = UUID.randomUUID();
        NamespaceEntity ns = NamespaceEntity.findByUri(manager, "http://www.example.com");
        ChildId[] ids = createMixtureOfChildren(workspaceId, parentUuid, ns);
        assertThat(ids.length, is(23));

        // Look up the objects ...
        manager.getTransaction().begin();
View Full Code Here


    @SuppressWarnings( "unchecked" )
    @Test
    public void shouldFindEntitiesAfterIndex() {
        Long workspaceId = 1L;
        UUID parentUuid = UUID.randomUUID();
        NamespaceEntity ns = NamespaceEntity.findByUri(manager, "http://www.example.com");
        ChildId[] ids = createMixtureOfChildren(workspaceId, parentUuid, ns);
        assertThat(ids.length, is(23));

        // Look up the objects ...
        manager.getTransaction().begin();
View Full Code Here

    @SuppressWarnings( "unchecked" )
    @Test
    public void shouldFindAdjustChildIndexesAfterRemovalOfFirstSibling() {
        Long workspaceId = 1L;
        UUID parentUuid = UUID.randomUUID();
        NamespaceEntity ns = NamespaceEntity.findByUri(manager, "http://www.example.com");
        ChildId[] ids = createMixtureOfChildren(workspaceId, parentUuid, ns);
        assertThat(ids.length, is(23));

        // Look up the objects ...
        manager.getTransaction().begin();
        try {
            Query query = manager.createNamedQuery("ChildEntity.findAllUnderParent");
            query.setParameter("parentUuidString", parentUuid.toString());
            query.setParameter("workspaceId", workspaceId);
            List<ChildEntity> children = query.getResultList();
            int index = 1;
            assertThat(children.size(), is(23));
            for (ChildEntity child : children) {
                assertThat(child.getIndexInParent(), is(index++));
            }

            // Remove the first child ...
            ChildEntity child = getChild(workspaceId, ids[0].getChildUuidString());
            assertThat(child, is(notNullValue()));
            String childName = child.getChildName();
            manager.remove(child);

            ChildEntity.adjustSnsIndexesAndIndexesAfterRemoving(manager,
                                                                workspaceId,
                                                                parentUuid.toString(),
                                                                childName,
                                                                ns.getId(),
                                                                0);

            assertChildren(workspaceId, parentUuid.toString(),
            // "child1",
                           "child2",
View Full Code Here

    @Test
    public void shouldPersistNamespaceEntity() {
        startEntityManager();
        String uri = "http://www.example.com";
        NamespaceEntity namespace = new NamespaceEntity(uri);
        manager.getTransaction().begin();
        try {
            // Save a namespace entity ...
            manager.persist(namespace);
            manager.getTransaction().commit();
        } catch (RuntimeException t) {
            manager.getTransaction().rollback();
            throw t;
        }
        // Look up the object ...
        manager.getTransaction().begin();
        try {
            NamespaceEntity ns2 = manager.find(NamespaceEntity.class, namespace.getId());
            assertThat(ns2.getUri(), is(namespace.getUri()));
            assertThat(ns2.getId(), is(namespace.getId()));
        } finally {
            manager.getTransaction().rollback();
        }
        // Look up by namespace ...
        manager.getTransaction().begin();
        try {
            NamespaceEntity ns2 = NamespaceEntity.findByUri(manager, uri);
            assertThat(ns2.getUri(), is(namespace.getUri()));
            assertThat(ns2.getId(), is(namespace.getId()));
        } finally {
            manager.getTransaction().rollback();
        }
    }
View Full Code Here

        assertThat(childId1, is(not(childId3)));
        assertThat(childId2, is(not(childId3)));

        manager.getTransaction().begin();
        try {
            NamespaceEntity ns = NamespaceEntity.findByUri(manager, "http://www.example.com");

            // Create the child entities ...
            ChildEntity child1 = new ChildEntity(childId1, 1, ns, "child1");
            ChildEntity child2 = new ChildEntity(childId2, 2, ns, "child2");
            ChildEntity child3 = new ChildEntity(childId3, 3, ns, "child3", 1);

            // Save a properties entities ...
            manager.persist(child1);
            manager.persist(child2);
            manager.persist(child3);
            manager.getTransaction().commit();
        } catch (RuntimeException t) {
            // manager.getTransaction().rollback();
            throw t;
        }
        // Look up the object ...
        manager.getTransaction().begin();
        try {
            NamespaceEntity ns = NamespaceEntity.findByUri(manager, "http://www.example.com");

            ChildEntity child1a = manager.find(ChildEntity.class, childId1);
            ChildEntity child2a = manager.find(ChildEntity.class, childId2);
            ChildEntity child3a = manager.find(ChildEntity.class, childId3);
View Full Code Here

        }

        // Create the child entity ...
        Name childName = path.getLastSegment().getName();
        int snsIndex = path.getLastSegment().getIndex();
        NamespaceEntity namespace = namespaces.get(childName.getNamespaceUri(), true);
        UUID childUuid = UUID.randomUUID();
        ChildId id = new ChildId(workspaceId, parentUuid.toString(), childUuid.toString());
        ChildEntity entity = new ChildEntity(id, ++numChildren, namespace, childName.getLocalName(), snsIndex);
        manager.persist(entity);
View Full Code Here

TOP

Related Classes of org.jboss.dna.connector.store.jpa.model.common.NamespaceEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.