Package org.openengsb.itests.exam.models

Examples of org.openengsb.itests.exam.models.SubModelDecorator


    public void testSupportOfSimpleSubModels_shouldWork() throws Exception {
        TestModelDecorator model = getTestModelDecorator();
        model.setName("test");
        model.setEdbId("testSub/1");

        SubModelDecorator sub = getSubModelDecorator();
        sub.setName("sub");
        sub.setEdbId("testSub/2");
        model.setSubModel(sub.getModel());

        EKBCommit commit = getTestEKBCommit().addInsert(model.getModel());
        persist.commit(commit);

        EDBObject mainObject = edbService.getObject(getModelOid("testSub/1"));
View Full Code Here


    public void testSupportOfListOfSubModels_shouldWork() throws Exception {
        TestModelDecorator model = getTestModelDecorator();
        model.setName("test");
        model.setEdbId("testSub/3");

        SubModelDecorator sub1 = getSubModelDecorator();
        sub1.setName("sub1");
        sub1.setEdbId("testSub/4");
        SubModelDecorator sub2 = getSubModelDecorator();
        sub2.setName("sub2");
        sub2.setEdbId("testSub/5");

        List<Object> subs = new ArrayList<Object>();
        subs.add(sub1.getModel());
        subs.add(sub2.getModel());
        model.setSubs(subs);

        EKBCommit commit = getTestEKBCommit().addInsert(model.getModel());
        persist.commit(commit);
View Full Code Here

        TestModelDecorator rRoot;
        TestModelDecorator rChild1;
        TestModelDecorator rChild2;
        TestModelDecorator rChild11;
        TestModelDecorator rChild12;
        SubModelDecorator leaf;
        SubModelDecorator rLeaf;

        root = getTestModelDecorator();
        child1 = getTestModelDecorator();
        child2 = getTestModelDecorator();
        child11 = getTestModelDecorator();
        child12 = getTestModelDecorator();
        leaf = getSubModelDecorator();

        List<Object> rootChildren = new ArrayList<>();
        rootChildren.add(child1.getModel());
        rootChildren.add(child2.getModel());

        List<Object> child1Children = new ArrayList<>();
        child1Children.add(child11.getModel());
        child1Children.add(child12.getModel());

        root.setEdbId("root");
        root.setName("root");
        child1.setEdbId("child1");
        child1.setName("child1");
        child2.setEdbId("child2");
        child2.setName("child2");
        child11.setEdbId("child11");
        child11.setName("child11");
        child12.setEdbId("child12");
        child12.setName("child12");
        leaf.setEdbId("leaf");
        leaf.setName("leaf");

        child11.setSubModel(leaf.getModel());
        child1.setChildren(child1Children);
        root.setChildren(rootChildren);

        // test
        EKBCommit commit = getTestEKBCommit().addInsert(root.getModel());
        persist.commit(commit);

        rRoot = new TestModelDecorator(query.getModel(getTestModel(), getModelOid("root")));

        // assert
        assertThat(rRoot.getEdbId(), is("root"));
        assertThat(rRoot.getChildren(), notNullValue());

        List<?> resultChildren = rRoot.getChildren();
        assertThat(resultChildren.size(), is(2));

        rChild1 = new TestModelDecorator(resultChildren.get(0));
        rChild2 = new TestModelDecorator(resultChildren.get(1));

        assertThat(rChild1.getEdbId(), is("child1"));
        assertThat(rChild1.getChildren(), notNullValue());

        assertThat(rChild2.getEdbId(), is("child2"));

        List<Object> rChild1Children = rChild1.getChildren();
        assertThat(rChild1Children.size(), is(2));

        rChild11 = new TestModelDecorator(rChild1Children.get(0));
        rChild12 = new TestModelDecorator(rChild1Children.get(1));

        assertThat(rChild11.getEdbId(), is("child11"));
        assertThat(rChild12.getEdbId(), is("child12"));

        rLeaf = new SubModelDecorator(rChild11.getSubModel());
        assertThat(rLeaf.getEdbId(), is("leaf"));
    }
View Full Code Here

        TestModelDecorator root;
        TestModelDecorator child1;
        TestModelDecorator child2;
        TestModelDecorator child11;
        TestModelDecorator child12;
        SubModelDecorator leaf;

        root = getTestModelDecorator();
        child1 = getTestModelDecorator();
        child2 = getTestModelDecorator();
        child11 = getTestModelDecorator();
        child12 = getTestModelDecorator();
        leaf = getSubModelDecorator();

        List<Object> rootChildren = new ArrayList<>();
        rootChildren.add(child1.getModel());
        rootChildren.add(child2.getModel());

        List<Object> child1Children = new ArrayList<>();
        child1Children.add(child11.getModel());
        child1Children.add(child12.getModel());

        root.setEdbId("root/1");
        root.setName("root/1");
        child1.setEdbId("child1/1");
        child1.setName("child1/1");
        child2.setEdbId("child2/1");
        child2.setName("child2/1");
        child11.setEdbId("child11/1");
        child11.setName("child11/1");
        child12.setEdbId("child12/1");
        child12.setName("child12/1");
        leaf.setEdbId("leaf/1");
        leaf.setName("leaf/1");

        child11.setSubModel(leaf.getModel());
        child1.setChildren(child1Children);
        root.setChildren(rootChildren);

        EKBCommit commit = getTestEKBCommit().addInsert(root.getModel());
        persist.commit(commit);
View Full Code Here

    @Test
    public void testIfSubModelIsPersistedAlso_shouldPersistParentAndSubModel() throws Exception {
        TestModelDecorator model = getTestModelDecorator();
        model.setEdbId("submodeltest/1");

        SubModelDecorator sub = getSubModelDecorator();
        sub.setName("test");
        sub.setEdbId("submodeltest/1/1");
        model.setSubModel(sub.getModel());

        EKBCommit commit = getTestEKBCommit().addInsert(model.getModel());
        persist.commit(commit);
        model = loadTestModel("submodeltest/1");
        assertThat(model.getModel(), notNullValue());
        sub = new SubModelDecorator(model.getSubModel());
        assertThat(sub.getModel(), notNullValue());
        assertThat(sub.getName(), is("test"));
    }
View Full Code Here

    @Test
    public void testIfSubModelsArePersistedAlso_shouldPersistParentAndSubModels() throws Exception {
        TestModelDecorator model = getTestModelDecorator();
        model.setEdbId("submodeltest/2");
        List<Object> subs = new ArrayList<Object>();
        SubModelDecorator sub = getSubModelDecorator();
        sub.setName("test1");
        sub.setEdbId("submodeltest/2/1");
        subs.add(sub.getModel());
        sub = getSubModelDecorator();
        sub.setName("test2");
        sub.setEdbId("submodeltest/2/2");
        subs.add(sub.getModel());
        model.setSubs(subs);

        EKBCommit commit = getTestEKBCommit().addInsert(model.getModel());
        persist.commit(commit);
        model = loadTestModel("submodeltest/2");
        assertThat(model.getModel(), notNullValue());
        assertThat(model.getSubs(), notNullValue());
        assertThat(model.getSubs().get(0), notNullValue());
        assertThat(model.getSubs().get(1), notNullValue());
        sub = new SubModelDecorator(model.getSubs().get(0));
        assertThat(sub.getName(), is("test1"));
        sub = new SubModelDecorator(model.getSubs().get(1));
        assertThat(sub.getName(), is("test2"));
        sub = loadSubModel("submodeltest/2/1");
        assertThat(sub.getName(), is("test1"));
        sub = loadSubModel("submodeltest/2/2");
        assertThat(sub.getName(), is("test2"));
    }
View Full Code Here

    @Test
    public void testIfSubModelIsUpdatedAlso_shouldUpdateParentAndSubModel() throws Exception {
        TestModelDecorator model = getTestModelDecorator();
        model.setEdbId("submodeltest/3");

        SubModelDecorator sub = getSubModelDecorator();
        sub.setName("test");
        sub.setEdbId("submodeltest/3/1");
        model.setSubModel(sub.getModel());

        EKBCommit commit = getTestEKBCommit().addInsert(model.getModel());
        persist.commit(commit);

        sub.setName("updated");
        commit = getTestEKBCommit().addUpdate(model.getModel());
        persist.commit(commit);

        sub = loadSubModel("submodeltest/3/1");
        assertThat(sub.getModel(), notNullValue());
        assertThat(sub.getName(), is("updated"));
    }
View Full Code Here

    @Test
    public void testIfSubModelsAreUpdatedAlso_shouldUpdateParentAndSubModels() throws Exception {
        TestModelDecorator model = getTestModelDecorator();
        model.setEdbId("submodeltest/4");
        List<Object> subs = new ArrayList<Object>();
        SubModelDecorator sub = getSubModelDecorator();
        sub.setName("test1");
        sub.setEdbId("submodeltest/4/1");
        subs.add(sub.getModel());
        sub = getSubModelDecorator();
        sub.setName("test2");
        sub.setEdbId("submodeltest/4/2");
        subs.add(sub.getModel());
        model.setSubs(subs);

        EKBCommit commit = getTestEKBCommit().addInsert(model.getModel());
        persist.commit(commit);

        subs.clear();
        sub = getSubModelDecorator();
        sub.setName("updatedtest1");
        sub.setEdbId("submodeltest/4/1");
        subs.add(sub.getModel());
        sub = getSubModelDecorator();
        sub.setName("updatedtest2");
        sub.setEdbId("submodeltest/4/2");
        subs.add(sub.getModel());
        sub = getSubModelDecorator();
        sub.setName("insertedtest3");
        sub.setEdbId("submodeltest/4/3");
        subs.add(sub.getModel());
        model.setSubs(subs);
        commit = getTestEKBCommit().addUpdate(model.getModel());
        persist.commit(commit);

        model = new TestModelDecorator(query.getModel(getTestModel(), getModelOid("submodeltest/4")));
        assertThat(model.getModel(), notNullValue());
        assertThat(model.getSubs(), notNullValue());
        assertThat(model.getSubs().get(0), notNullValue());
        assertThat(model.getSubs().get(1), notNullValue());
        assertThat(model.getSubs().get(2), notNullValue());
        sub = new SubModelDecorator(model.getSubs().get(0));
        assertThat(sub.getName(), is("updatedtest1"));
        sub = new SubModelDecorator(model.getSubs().get(1));
        assertThat(sub.getName(), is("updatedtest2"));
        sub = new SubModelDecorator(model.getSubs().get(2));
        assertThat(sub.getName(), is("insertedtest3"));
        sub = loadSubModel("submodeltest/4/1");
        assertThat(sub.getName(), is("updatedtest1"));
        sub = loadSubModel("submodeltest/4/2");
        assertThat(sub.getName(), is("updatedtest2"));
        sub = loadSubModel("submodeltest/4/3");
        assertThat(sub.getName(), is("insertedtest3"));
    }
View Full Code Here

    @Test
    public void testIfSubModelIsDeletedAlso_shouldDeleteParentAndSubModel() throws Exception {
        TestModelDecorator model = getTestModelDecorator();
        model.setEdbId("submodeltest/5");

        SubModelDecorator sub = getSubModelDecorator();
        sub.setName("test");
        sub.setEdbId("submodeltest/5/1");
        model.setSubModel(sub.getModel());

        EKBCommit commit = getTestEKBCommit().addInsert(model.getModel());
        persist.commit(commit);
        commit = getTestEKBCommit().addDelete(model.getModel());
        persist.commit(commit);
View Full Code Here

    @Test
    public void testIfSubModelsAreDeletedAlso_shouldDeleteParentAndSubModels() throws Exception {
        TestModelDecorator model = getTestModelDecorator();
        model.setEdbId("submodeltest/6");
        List<Object> subs = new ArrayList<Object>();
        SubModelDecorator sub = getSubModelDecorator();
        sub.setName("test1");
        sub.setEdbId("submodeltest/6/1");
        subs.add(sub.getModel());
        sub = getSubModelDecorator();
        sub.setName("test2");
        sub.setEdbId("submodeltest/6/2");
        subs.add(sub.getModel());
        model.setSubs(subs);

        EKBCommit commit = getTestEKBCommit().addInsert(model.getModel());
        persist.commit(commit);
        commit = getTestEKBCommit().addDelete(model.getModel());
View Full Code Here

TOP

Related Classes of org.openengsb.itests.exam.models.SubModelDecorator

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.