Package org.openengsb.core.ekb.api

Examples of org.openengsb.core.ekb.api.EKBCommit


        model.setEdbId("reverttest/1");
        model.setName("before");
        TestModelDecorator model2 = getTestModelDecorator();
        model2.setEdbId("reverttest/2");
        model2.setName("test");
        EKBCommit commit = getTestEKBCommit().addInsert(model.getModel());
        persist.commit(commit);
        String revision = commit.getRevisionNumber().toString();

        model.setName("middle");
        commit = getTestEKBCommit().addUpdate(model.getModel());
        persist.commit(commit);
        String revision2 = commit.getRevisionNumber().toString();

        commit = getTestEKBCommit().addInsert(model2.getModel());
        persist.commit(commit);
        model.setName("after");
        commit = getTestEKBCommit().addUpdate(model.getModel());
View Full Code Here


    @Test
    public void testLoadingOfEKBCommits_shouldLoadAllInformation() throws Exception {
        TestModelDecorator model = getTestModelDecorator();
        model.setEdbId("ekbload/1");
        model.setName("test");
        EKBCommit commit = getTestEKBCommit().addInsert(model.getModel());
        commit.setComment("This is the first comment");
        persist.commit(commit);
        String revision = commit.getRevisionNumber().toString();
        model.setName("test2");
        commit = getTestEKBCommit().addUpdate(model.getModel());
        commit.setComment("This is the second comment");
        persist.commit(commit);
        String revision2 = commit.getRevisionNumber().toString();

        commit = query.loadCommit(revision);
        assertThat(commit, notNullValue());
        assertThat(commit.getInserts().size(), is(1));
        assertThat(commit.getRevisionNumber().toString(), is(revision));
        assertThat(commit.getDomainId(), is(getTestEKBCommit().getDomainId()));
        assertThat(commit.getConnectorId(), is(getTestEKBCommit().getConnectorId()));
        assertThat(commit.getInstanceId(), is(getTestEKBCommit().getInstanceId()));
        assertThat(commit.getComment(), is("This is the first comment"));

        commit = query.loadCommit(revision2);
        assertThat(commit, notNullValue());
        assertThat(commit.getUpdates().size(), is(1));
        assertThat(commit.getRevisionNumber().toString(), is(revision2));
        assertThat(commit.getParentRevisionNumber().toString(), is(revision));
        assertThat(commit.getDomainId(), is(getTestEKBCommit().getDomainId()));
        assertThat(commit.getConnectorId(), is(getTestEKBCommit().getConnectorId()));
        assertThat(commit.getInstanceId(), is(getTestEKBCommit().getInstanceId()));
        assertThat(commit.getComment(), is("This is the second comment"));
    }
View Full Code Here

    protected String getModelOid(String modelId) {
        return String.format("%s/%s", ContextHolder.get().getCurrentContextId(), modelId);
    }

    protected EKBCommit getTestEKBCommit() {
        EKBCommit commit = new EKBCommit().setDomainId("testdomain").setConnectorId("testconnector");
        commit.setInstanceId("testinstance");
        return commit;
    }
View Full Code Here

            ModelWrapper.isModel(model.getClass()), is(true));
    }

    @Test
    public void testIfRealModelsCanBeCommited_shouldWork() throws Exception {
        EKBCommit commit = new EKBCommit();
        commit.setDomainId("testdomain").setConnectorId("testconnector").setInstanceId("testinstance");
        commit.addInsert(new TestModel2());
        service.commit(commit);
    }
View Full Code Here

            transformationEngine, modelRegistry, mode.toString());
        ContextHolder.get().setCurrentContextId(CONTEXT_ID);
    }   

    protected EKBCommit getTestCommit() {
        return new EKBCommit().setDomainId("test").setConnectorId("test");
    }
View Full Code Here

   
    @Test(expected = EKBConcurrentException.class)
    public void testIfUnexpectedParentRevisionThrowsException_shouldThrowException() throws Exception {
        SourceModelA model = new SourceModelA();
        model.setEdbId("unexpectedParentRevision/1");
        EKBCommit commit = getTestEKBCommit().addInsert(model);
        persist.commit(commit, null);
       
        model = new SourceModelA();
        model.setEdbId("unexpectedParentRevision/2");
        commit = getTestEKBCommit().addInsert(model);
View Full Code Here

        persist.commit(commit, null);
    }
   
    @Test(expected = EKBConcurrentException.class)
    public void testIfConcurrentWritingInTheSameContextThrowsAnException_shouldThrowException() throws Exception {
        EKBCommit commit = getTestEKBCommit();
        for (int i = 0; i < 30; i++) {
            SourceModelA model = new SourceModelA();
            model.setEdbId("concurrentTest/1/" + i);
            commit.addInsert(model);
        }
        EKBCommit anotherCommit = getTestEKBCommit();
        SourceModelA model = new SourceModelA();
        model.setEdbId("concurrentTest/1/30");
        anotherCommit.addInsert(model);
       
        ModelCommitThread thread = new ModelCommitThread(persist, commit, CONTEXT);
        thread.start();
        Thread.sleep(20);
        // throws an exception since the other commit is still running in the context
View Full Code Here

   
    @Test
    public void testIfConcurrentWritingInDifferentContextsWorks_shouldWork() throws Exception {
        String otherContext = "a_different_context";
        String oid = "";
        EKBCommit commit = getTestEKBCommit();
        for (int i = 0; i < 15; i++) {
            SourceModelA model = new SourceModelA();
            model.setEdbId("concurrentTest/2/" + i);
            commit.addInsert(model);
            if (i == 14) {
                oid = ModelWrapper.wrap(model).retrieveInternalModelId().toString();
            }
        }
        ModelCommitThread thread = new ModelCommitThread(persist, commit, CONTEXT);
View Full Code Here

    }
   
    @Test
    public void testIfCheckForContextIsDoneCorrectly_shouldWork() throws Exception {
        ContextHolder.get().setCurrentContextId("A");
        EKBCommit commit = getTestEKBCommit();
        SourceModelA model = new SourceModelA();
        model.setEdbId("contextSwitchTest/1");
        String oid = ModelWrapper.wrap(model).retrieveInternalModelId().toString();
        model.setName("A");
        commit.addInsert(model);
        persist.commit(commit, query.getLastRevisionNumberOfContext("A"));
        ContextHolder.get().setCurrentContextId("B");
        persist.commit(commit, query.getLastRevisionNumberOfContext("B"));
        model.setName("B");
        commit = getTestEKBCommit();
        commit.addUpdate(model);
        ContextHolder.get().setCurrentContextId("A");
        persist.commit(commit, query.getLastRevisionNumberOfContext("A"));
        ContextHolder.get().setCurrentContextId("B");
        persist.commit(commit, query.getLastRevisionNumberOfContext("B"));
       
View Full Code Here

    @Test
    public void testIfNormalObjectUpdateTriggersEOUpdate_shouldTriggerNothing() throws Exception {
        SourceModelA model = new SourceModelA();
        model.setNameA("updatedFirstObject");
        model.setId("objectA/reference/1");
        EKBCommit commit = getTestCommit().addUpdate(model);
        int before = commit.getUpdates().size();
        enhancer.onPreCommit(commit);
        int after = commit.getUpdates().size();
        assertThat(before, is(after));
    }
View Full Code Here

TOP

Related Classes of org.openengsb.core.ekb.api.EKBCommit

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.