Package org.openengsb.core.ekb.persistence.persist.edb.models

Examples of org.openengsb.core.ekb.persistence.persist.edb.models.EngineeringObjectModel


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

    @Test
    public void testIfDifferenceCalculationWorks_shouldReturnTheCorrectAmountOfChanges() throws Exception {
        EngineeringObjectModel old = new EngineeringObjectModel();
        old.setInternalModelName("testModel");
        old.setNameA("nameA-old");
        old.setNameB("nameB-old");
        old.setModelAId("testreference1");
        old.setModelBId("testreference2");
        old.setTest("this is a teststring");
        EngineeringObjectModel updated = new EngineeringObjectModel();
        updated.setInternalModelName("testModel");
        updated.setNameA("nameA-new");
        updated.setNameB("nameB-new");
        updated.setModelAId("testreference1_1");
        updated.setModelBId("testreference2_1");
        ModelDiff diff = ModelDiff.createModelDiff((OpenEngSBModel) old, (OpenEngSBModel) updated);
        // The difference is 5 since also the null value of the test property is calculated as change since it was
        // before not null
        assertThat(diff.getDifferences().size(), is(5));
    }
View Full Code Here


        assertThat(diff.getDifferences().size(), is(5));
    }

    @Test
    public void testIfDifferenceCalculationWorks_shouldReturnTheCorrectChangee() throws Exception {
        EngineeringObjectModel old = new EngineeringObjectModel();
        old.setInternalModelName("testModel");
        old.setNameA("nameA-old");
        old.setNameB("nameB-old");
        old.setModelAId("testreference1");
        old.setModelBId("testreference2");
        old.setTest("this is a teststring");
        EngineeringObjectModel updated = new EngineeringObjectModel();
        updated.setInternalModelName("testModel");
        updated.setNameA("nameA-old");
        updated.setNameB("nameB-old");
        updated.setModelAId("testreference1");
        updated.setModelBId("testreference2");
        updated.setTest("this is a new teststring");
        ModelDiff diff = ModelDiff.createModelDiff((OpenEngSBModel) old, (OpenEngSBModel) updated);
        assertThat(diff.getDifferences().size(), is(1));
        ModelDiffEntry entry = diff.getDifferences().values().iterator().next();
        assertThat((String) entry.getBefore(), is("this is a teststring"));
        assertThat((String) entry.getAfter(), is("this is a new teststring"));
View Full Code Here

        assertThat((String) entry.getAfter(), is("this is a new teststring"));
    }

    @Test
    public void testIfForeignKeyCheckWorks_shouldSayThatAValueWasChanged() throws Exception {
        EngineeringObjectModel old = new EngineeringObjectModel();
        old.setInternalModelName("testModel");
        old.setModelAId("testreference1");
        old.setModelBId("testreference2");
        EngineeringObjectModel updated = new EngineeringObjectModel();
        updated.setInternalModelName("testModel");
        updated.setModelAId("testreference1_1");
        updated.setModelBId("testreference2");
        ModelDiff diff = ModelDiff.createModelDiff((OpenEngSBModel) old, (OpenEngSBModel) updated);
        assertThat(diff.getDifferences().size(), is(1));
        assertThat(diff.isForeignKeyChanged(), is(true));
        assertThat(diff.isValueChanged(), is(false));
    }
View Full Code Here

        assertThat(diff.isValueChanged(), is(false));
    }

    @Test
    public void testIfValueChangedCheckWorks_shouldSayThatForeignKeyWasChanged() throws Exception {
        EngineeringObjectModel old = new EngineeringObjectModel();
        old.setInternalModelName("testModel");
        old.setNameA("hello");
        old.setModelAId("testreference1");
        old.setModelBId("testreference2");
        EngineeringObjectModel updated = new EngineeringObjectModel();
        updated.setInternalModelName("testModel");
        updated.setNameA("world");
        updated.setModelAId("testreference1");
        updated.setModelBId("testreference2");
        ModelDiff diff = ModelDiff.createModelDiff((OpenEngSBModel) old, (OpenEngSBModel) updated);
        assertThat(diff.getDifferences().size(), is(1));
        assertThat(diff.isForeignKeyChanged(), is(false));
        assertThat(diff.isValueChanged(), is(true));
    }
View Full Code Here

    }
   
    @Test
    public void testIfEngineeringObjectUpdateAlsoUpdatesReferencedModel_shouldUpdateNothing()
        throws Exception {
        EngineeringObjectModel model = new EngineeringObjectModel();
        model.setInternalModelName("common/reference/2");
        model.setModelAId("objectA/reference/1");
        model.setNameA("updatedFirstObject");
        EKBCommit commit = getTestCommit().addUpdate(model);
        int before = commit.getUpdates().size();
        enhancer.onPreCommit(commit);
        int after = commit.getUpdates().size();
        SourceModelA modelA = null;
View Full Code Here

        super(EOMode.FULLY_ACTIVATED);
    }

    @Test
    public void testIfEngineeringObjectModelInsertionWorks_shouldLoadTheValuesOfTheForeignKeys() throws Exception {
        EngineeringObjectModel model = new EngineeringObjectModel();
        model.setModelAId("objectA/reference/1");
        model.setModelBId("objectB/reference/1");
        EKBCommit commit = getTestCommit().addInsert(model);
        enhancer.onPreCommit(commit);

        assertThat(model.getNameA(), is("firstObject"));
        assertThat(model.getNameB(), is("secondObject"));
    }
View Full Code Here

        EKBCommit commit = getTestCommit().addUpdate(model);
        int before = commit.getUpdates().size();
        enhancer.onPreCommit(commit);
        int after = commit.getUpdates().size();
        Object inserted = commit.getUpdates().get(commit.getUpdates().size() - 1);
        EngineeringObjectModel result = (EngineeringObjectModel) inserted;
        assertThat(before < after, is(true));
        assertThat(result.getNameA(), is("updatedFirstObject"));
    }
View Full Code Here

        EKBCommit commit = getTestCommit().addUpdate(modelA).addUpdate(modelb);
        int before = commit.getUpdates().size();
        enhancer.onPreCommit(commit);
        int after = commit.getUpdates().size();
        Object inserted = commit.getUpdates().get(commit.getUpdates().size() - 1);
        EngineeringObjectModel result = (EngineeringObjectModel) inserted;
        assertThat(before < after, is(true));
        assertThat(result.getNameA(), is("updatedFirstObject"));
        assertThat(result.getNameB(), is("updatedSecondObject"));
    }
View Full Code Here

    }

    @Test(expected = EKBException.class)
    public void testIfTheEngineeringObjectUpdateIsCheckedCorrectly_shouldNotAllowReferenceAndValueChange()
        throws Exception {
        EngineeringObjectModel model = new EngineeringObjectModel();
        model.setInternalModelName("common/reference/1");
        model.setModelAId("objectA/reference/2");
        model.setNameA("teststring");
        EKBCommit commit = getTestCommit().addUpdate(model);
        enhancer.onPreCommit(commit);
    }
View Full Code Here

        enhancer.onPreCommit(commit);
    }

    @Test
    public void testIfTheEngineeringObjectReferenceUpdateWorks_shouldLoadOtherModelAndMergeIt() throws Exception {
        EngineeringObjectModel model = new EngineeringObjectModel();
        model.setInternalModelName("common/reference/1");
        model.setModelAId("objectA/reference/2");
        model.setModelBId("objectB/reference/1");
        model.setNameA("firstObject");
        model.setNameB("secondObject");
        EKBCommit commit = getTestCommit().addUpdate(model);
        int before = commit.getUpdates().size();
        enhancer.onPreCommit(commit);
        int after = commit.getUpdates().size();
        Object inserted = commit.getUpdates().get(commit.getUpdates().size() - 1);
        EngineeringObjectModel result = (EngineeringObjectModel) inserted;
        assertThat(before == after, is(true));
        assertThat(result.getNameA(), is("updatedFirstObject"));
        assertThat(result.getNameB(), is("secondObject"));
    }
View Full Code Here

TOP

Related Classes of org.openengsb.core.ekb.persistence.persist.edb.models.EngineeringObjectModel

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.