Package org.mongodb.morphia.entities.version

Examples of org.mongodb.morphia.entities.version.Versioned


public class TestVersionAnnotation extends TestBase {

    @Test
    public void testVersionNumbersIncrementWithEachSave() throws Exception {
        final Versioned version1 = new Versioned();
        getDs().save(version1);
        assertEquals(new Long(1), version1.getVersion());

        final Versioned version2 = getDs().get(Versioned.class, version1.getId());
        getDs().save(version2);
        assertEquals(new Long(2), version2.getVersion());
    }
View Full Code Here


    }

    @Test(expected = ConcurrentModificationException.class)
    public void testThrowsExceptionWhenTryingToSaveAnOldVersion() throws Exception {
        // given
        final Versioned version1 = new Versioned();
        getDs().save(version1);
        final Versioned version2 = getDs().get(Versioned.class, version1.getId());
        getDs().save(version2);

        // when
        getDs().save(version1);
    }
View Full Code Here

        getDs().save(version1);
    }

    @Test
    public void testVersionedInserts() {
        Versioned[] versioneds = {new Versioned(), new Versioned(), new Versioned(), new Versioned(), new Versioned()};
        getAds().insert(versioneds);
        for (Versioned versioned : versioneds) {
            assertNotNull(versioned.getVersion());
        }
    }
View Full Code Here

        assertEquals(mappedClasses.iterator().next().getClazz(), VersionedChildEntity.class);
    }

    @Test
    public void testUpdatesToVersionedFileAreReflectedInTheDatastore() {
        final Versioned version1 = new Versioned();
        version1.setName("foo");

        this.getDs().save(version1);

        final Versioned version1Updated = getDs().get(Versioned.class, version1.getId());
        version1Updated.setName("bar");

        this.getDs().merge(version1Updated);

        final Versioned versionedEntityFromDs = this.getDs().get(Versioned.class, version1.getId());
        assertEquals(version1Updated.getName(), versionedEntityFromDs.getName());
    }
View Full Code Here

TOP

Related Classes of org.mongodb.morphia.entities.version.Versioned

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.