Package org.openengsb.core.edb.api

Examples of org.openengsb.core.edb.api.EDBCommit


        Map<String, EDBObjectEntry> data1 = new HashMap<String, EDBObjectEntry>();
        putValue("Burger", "Salad", data1);
        putValue("Bla", "Blub", data1);
        putValue("Cheese", "Butter", data1);
        EDBObject v1 = new EDBObject("/history/test/object", data1);
        EDBCommit ci = getEDBCommit();
        ci.insert(createRandomTestObject("/useless/test/1"));
        ci.insert(createRandomTestObject("/deletion/test/1"));
        ci.insert(v1);

        time1 = db.commit(ci);

        Map<String, EDBObjectEntry> data2 = Maps.newHashMap(data1);
        putValue("Burger", "Meat", data2);
        EDBObject v2 = new EDBObject("/history/test/object", data2);
        ci = getEDBCommit();
        ci.insert(createRandomTestObject("/useless/test/2"));
        ci.delete("/deletion/test/1");
        ci.update(v2);
        time2 = db.commit(ci);

        Map<String, EDBObjectEntry> data3 = Maps.newHashMap(data2);
        ci = getEDBCommit();
        ci.insert(createRandomTestObject("/useless/test/3"));
        ci.insert(createRandomTestObject("/useless/test/4"));
        time3 = db.commit(ci);
        putValue("Cheese", "Milk", data3);

        EDBObject v3 = new EDBObject("/history/test/object", data3);
        ci = getEDBCommit();
        ci.update(v3);
        ci.insert(createRandomTestObject("/useless/test/5"));

        time4 = db.commit(ci);

        List<EDBLogEntry> log = db.getLog("/history/test/object", time1, time4);
        assertThat(log.size(), is(3));
View Full Code Here


        Map<String, EDBObjectEntry> data1 = new HashMap<String, EDBObjectEntry>();
        putValue("KeyA", "Value A 1", data1);
        putValue("KeyB", "Value B 1", data1);
        putValue("KeyC", "Value C 1", data1);
        EDBObject v1 = new EDBObject("/diff/object", data1);
        EDBCommit ci = getEDBCommit();
        ci.insert(v1);
        time1 = db.commit(ci);

        Map<String, EDBObjectEntry> data2 = Maps.newHashMap(data1);

        putValue("KeyD", "Value D 1", data2);
        putValue("KeyA", "Value A 2", data2);
        EDBObject v2 = new EDBObject("/diff/object", data2);
        ci = getEDBCommit();
        ci.update(v2);
        time2 = db.commit(ci);

        Map<String, EDBObjectEntry> data3 = Maps.newHashMap(data2);

        data3.remove("KeyB");
        putValue("KeyC", "Value C 3", data3);
        EDBObject v3 = new EDBObject("/diff/object", data3);
        ci = getEDBCommit();
        ci.update(v3);
        time3 = db.commit(ci);

        checkTimeStamps(Arrays.asList(time1, time2, time3));

        Diff diffAb = db.getDiff(time1, time2);
View Full Code Here

    @Test
    public void testGetResurrectedOIDs_shouldWork() throws Exception {
        Map<String, EDBObjectEntry> data1 = new HashMap<String, EDBObjectEntry>();
        putValue("KeyA", "Value A 1", data1);
        EDBObject v1 = new EDBObject("/ress/object", data1);
        EDBCommit ci = getEDBCommit();
        ci.insert(v1);
        long time1 = db.commit(ci);

        v1 = new EDBObject("/ress/object2", data1);
        ci = getEDBCommit();
        ci.insert(v1);
        ci.delete("/ress/object");
        long time2 = db.commit(ci);

        v1 = new EDBObject("/ress/object", data1);
        ci = getEDBCommit();
        ci.delete("/ress/object2");
        ci.update(v1);
        long time3 = db.commit(ci);

        List<String> oids = db.getResurrectedOIDs();

        assertThat(oids.contains("/ress/object"), is(true));
View Full Code Here

    @Test(expected = EDBException.class)
    public void testCommitTwiceSameCommit_shouldThrowError() throws Exception {
        Map<String, EDBObjectEntry> data1 = new HashMap<String, EDBObjectEntry>();
        putValue("KeyA", "Value A 1", data1);
        EDBObject v1 = new EDBObject("/fail/object", data1);
        EDBCommit ci = getEDBCommit();
        ci.insert(v1);
        db.commit(ci);
        db.commit(ci);
    }
View Full Code Here

        assertThat((Date) value, is(date));
    }

    @Test
    public void testIfCreatedCommitContainsRevisionNumber_shouldReturnNotNull() throws Exception {
        EDBCommit ci = getEDBCommit();
        assertThat(ci.getRevisionNumber(), notNullValue());
    }
View Full Code Here

    }

    @Test(expected = EDBException.class)
    public void testIfWrongParentCausesCommitError_shouldThrowException() throws Exception {
        db.commit(getEDBCommit()); // add one entry so that there is actually a head
        EDBCommit ci = getEDBCommit();
        ci.insert(createRandomTestObject("/wrongparent/1"));
        EDBCommit ci2 = getEDBCommit();
        ci2.insert(createRandomTestObject("/wrongparent/2"));
        db.commit(ci2);
        db.commit(ci);
    }
View Full Code Here

    @Test
    public void testIfQueryingWithLikeWorks_shouldWork() throws Exception {
        Map<String, EDBObjectEntry> data1 = new HashMap<String, EDBObjectEntry>();
        putValue("bla", "teststring", data1);
        EDBObject v1 = new EDBObject("/test/query/8", data1);
        EDBCommit ci = getEDBCommit();
        ci.insert(v1);
        db.commit(ci);
        List<EDBObject> result = db.query(QueryRequest.query("bla", "test%").wildcardAware());
        assertThat(result.size(), is(1));
        assertThat(result.get(0).getOID(), is("/test/query/8"));
        result = db.query(QueryRequest.query("bla", "test_tring").wildcardAware());
View Full Code Here

    @Test
    public void testIfRetrievingCommitByRevisionWorks_shouldWork() throws Exception {
        Map<String, EDBObjectEntry> entries = new HashMap<String, EDBObjectEntry>();
        entries.put("test", new EDBObjectEntry("test", "test", String.class));
        EDBObject obj = new EDBObject("/test/query/9", entries);
        EDBCommit ci = getEDBCommit();
        ci.insert(obj);
        db.commit(ci);
        EDBCommit test = db.getCommitByRevision(ci.getRevisionNumber().toString());
        assertThat(test, notNullValue());
        assertThat(test, is(ci));
        assertThat(test.getInserts().get(0).getString("test"), is("test"));
    }
View Full Code Here

    @Test
    public void testIfRetrievingCommitByRevisionWithIntermediateCommitsWorks_shouldWork() throws Exception {
        Map<String, EDBObjectEntry> entries = new HashMap<String, EDBObjectEntry>();
        entries.put("test", new EDBObjectEntry("test", "test", String.class));
        EDBObject obj = new EDBObject("/test/query/10", entries);
        EDBCommit ci = getEDBCommit();
        ci.insert(obj);
        db.commit(ci);
        String revision = ci.getRevisionNumber().toString();
        obj.putEDBObjectEntry("test", "test2", String.class);
        EDBCommit ci2 = getEDBCommit();
        ci2.update(obj);
        db.commit(ci2);
        EDBCommit test = db.getCommitByRevision(revision);
        assertThat(test, notNullValue());
        assertThat(test, is(ci));
        assertThat(test.getInserts().get(0).getString("test"), is("test"));
    }
View Full Code Here

    @Test
    public void testIfRetrievingCommitRevisionsByRequestGivesCorrectRevisions_shouldWork() throws Exception {
        Map<String, EDBObjectEntry> entries = new HashMap<String, EDBObjectEntry>();
        entries.put("test", new EDBObjectEntry("test", "test", String.class));
        EDBObject obj = new EDBObject("/test/query/11", entries);
        EDBCommit ci = getEDBCommit();
        ci.insert(obj);
        Long timestamp1 = db.commit(ci);
        String revision1 = ci.getRevisionNumber().toString();
        obj.putEDBObjectEntry("test2", "test2", String.class);
        ci = getEDBCommit();
        ci.setComment("this is a comment");
        ci.update(obj);
        Long timestamp2 = db.commit(ci);
        String revision2 = ci.getRevisionNumber().toString();
        CommitQueryRequest request = new CommitQueryRequest();
        request.setCommitter("wrongName");
        assertThat(db.getRevisionsOfMatchingCommits(request).size(), is(0));
        request = new CommitQueryRequest();
        request.setCommitter("wrongContext");
View Full Code Here

TOP

Related Classes of org.openengsb.core.edb.api.EDBCommit

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.