Package org.openengsb.domain.example.model

Examples of org.openengsb.domain.example.model.SourceModelA


        ContextHolder.get().setCurrentContextId(CONTEXT);
    }
   
    @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);
        // second time throws an exception since the expected parent revision is no longer null
        persist.commit(commit, null);
    }
View Full Code Here


   
    @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);
View Full Code Here

    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();
            }
        }
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");
View Full Code Here

    }

    @Test
    public void testIfEngineeringObjectsAreInsertedCorrectly_shouldInsertObjectAndLoadReferencedValues()
        throws Exception {
        SourceModelA sourceA = new SourceModelA("sourceA/1", "sourceNameA", "shared");
        SourceModelB sourceB = new SourceModelB("sourceB/1", "sourceNameB", "shared");
        persist.commit(getTestEKBCommit().addInsert(sourceA).addInsert(sourceB));

        EOModel eo = new EOModel("eo/1", sourceA.getEdbId(), sourceB.getEdbId(), "shared");
        persist.commit(getTestEKBCommit().addInsert(eo));

        EOModel result = query.getModel(EOModel.class, getModelOid(eo.getEdbId()));
        String nameA = result.getNameA();
        String nameB = result.getNameB();

        assertThat(nameA, is(sourceA.getName()));
        assertThat(nameB, is(sourceB.getName()));
    }
View Full Code Here

        assertThat(nameB, is(sourceB.getName()));
    }

    @Test
    public void testIfEOUpdateWorksCorrectly_shouldUpdateSourceModel() throws Exception {
        SourceModelA sourceA = new SourceModelA("sourceA/2", "sourceNameA", "shared");
        SourceModelB sourceB = new SourceModelB("sourceB/2", "sourceNameB", "shared");
        persist.commit(getTestEKBCommit().addInsert(sourceA).addInsert(sourceB));

        EOModel eo = new EOModel("eo/2", sourceA.getEdbId(), sourceB.getEdbId(), "shared");
        persist.commit(getTestEKBCommit().addInsert(eo));

        eo = query.getModel(EOModel.class, getModelOid(eo.getEdbId()));
        eo.setNameA("updatedNameA");
        eo.setShared("updatedShared");
        persist.commit(getTestEKBCommit().addUpdate(eo));

        sourceA = query.getModel(SourceModelA.class, getModelOid(sourceA.getEdbId()));
        sourceB = query.getModel(SourceModelB.class, getModelOid(sourceB.getEdbId()));
        assertThat(sourceA.getName(), is("updatedNameA"));
        assertThat(sourceA.getShared(), is("updatedShared"));
        assertThat(sourceB.getShared(), is("updatedShared"));
    }
View Full Code Here

        assertThat(sourceB.getShared(), is("updatedShared"));
    }

    @Test
    public void testIfSourceUpdateWorksCorrectly_shouldUpdateEngineeringObject() throws Exception {
        SourceModelA sourceA = new SourceModelA("sourceA/3", "sourceNameA", "shared");
        SourceModelB sourceB = new SourceModelB("sourceB/3", "sourceNameB", "shared");
        persist.commit(getTestEKBCommit().addInsert(sourceA).addInsert(sourceB));

        EOModel eo = new EOModel("eo/3", sourceA.getEdbId(), sourceB.getEdbId(), "shared");
        persist.commit(getTestEKBCommit().addInsert(eo));

        sourceA = query.getModel(SourceModelA.class, getModelOid(sourceA.getEdbId()));
        sourceA.setName("updatedNameA");
        sourceA.setShared("updatedShared");
        persist.commit(getTestEKBCommit().addUpdate(sourceA));

        eo = query.getModel(EOModel.class, getModelOid(eo.getEdbId()));
        sourceB = query.getModel(SourceModelB.class, getModelOid(sourceB.getEdbId()));
        assertThat(eo.getNameA(), is("updatedNameA"));
View Full Code Here

        assertThat(sourceB.getShared(), is("updatedShared"));
    }

    @Test
    public void testIfEOUpdateWorksCorrectlyWithOnlyOneSource_shouldUpdateSourceModel() throws Exception {
        SourceModelA sourceA = new SourceModelA("sourceA/4", "sourceNameA", "shared");
        persist.commit(getTestEKBCommit().addInsert(sourceA));

        EOModel eo = new EOModel("eo/4", sourceA.getEdbId(), null, "shared");
        persist.commit(getTestEKBCommit().addInsert(eo));

        eo = query.getModel(EOModel.class, getModelOid(eo.getEdbId()));
        eo.setNameA("updatedNameA");
        eo.setShared("updatedShared");
        persist.commit(getTestEKBCommit().addUpdate(eo));

        SourceModelA result = query.getModel(SourceModelA.class, getModelOid(sourceA.getEdbId()));
        assertThat(result.getName(), is("updatedNameA"));
        assertThat(result.getShared(), is("updatedShared"));
    }
View Full Code Here

        assertThat(result.getShared(), is("updatedShared"));
    }

    @Test
    public void testDeleteSourceModel_doesNotDeleteLinkedModels() {
        SourceModelA sourceA = new SourceModelA("sourceA/5", "sourceNameA", "shared");
        SourceModelB sourceB = new SourceModelB("sourceB/5", "sourceNameB", "shared");
        persist.commit(getTestEKBCommit().addInsert(sourceA).addInsert(sourceB));

        EOModel eo = new EOModel("eo/5", sourceA.getEdbId(), sourceB.getEdbId(), "shared");
        persist.commit(getTestEKBCommit().addInsert(eo));

        SourceModelA source = query.getModel(SourceModelA.class, getModelOid(sourceA.getEdbId()));
        persist.commit(getTestEKBCommit().addDelete(source));

        eo = query.getModel(EOModel.class, getModelOid(eo.getEdbId()));
        sourceB = query.getModel(SourceModelB.class, getModelOid(sourceB.getEdbId()));
        assertThat(eo, notNullValue());
View Full Code Here

        assertThat(sourceB, notNullValue());
    }

    @Test
    public void testDeleteEOModel_doesNotDeleteLinkedModels() {
        SourceModelA sourceA = new SourceModelA("sourceA/6", "sourceNameA", "shared");
        SourceModelB sourceB = new SourceModelB("sourceB/6", "sourceNameB", "shared");
        persist.commit(getTestEKBCommit().addInsert(sourceA).addInsert(sourceB));

        EOModel eo = new EOModel("eo/6", sourceA.getEdbId(), sourceB.getEdbId(), "shared");
        persist.commit(getTestEKBCommit().addInsert(eo));

        eo = query.getModel(EOModel.class, getModelOid(eo.getEdbId()));
        persist.commit(getTestEKBCommit().addDelete(eo));

        sourceA = query.getModel(SourceModelA.class, getModelOid(sourceA.getEdbId()));
        sourceB = query.getModel(SourceModelB.class, getModelOid(sourceB.getEdbId()));
        assertThat(sourceA, notNullValue());
        assertThat(sourceB, notNullValue());
    }
View Full Code Here

TOP

Related Classes of org.openengsb.domain.example.model.SourceModelA

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.