Package org.openengsb.core.ekb.common.models

Examples of org.openengsb.core.ekb.common.models.TestModel


        assertThat(object.getString(EDBConverter.getEntryNameForMapValue("map", 1)), is("valueB"));
    }

    @Test
    public void testConversionInBothDirections_shouldWork() throws Exception {
        TestModel model = new TestModel();
        model.setId("test");
        Date date = new Date();
        model.setDate(date);
        model.setEnumeration(ENUM.A);
        model.setName("testobject");
        EDBObject object = converter.convertModelToEDBObject(model, getTestConnectorInformation()).get(0);
        TestModel result = converter.convertEDBObjectToModel(TestModel.class, object);

        assertThat(model.getId(), is(result.getId()));
        assertThat(model.getDate(), is(result.getDate()));
        assertThat(model.getEnumeration(), is(result.getEnumeration()));
        assertThat(model.getName(), is(result.getName()));
    }
View Full Code Here


        assertThat(model.getName(), is(result.getName()));
    }

    @Test
    public void testIfArraysAreSupported_shouldWork() throws Exception {
        TestModel model = new TestModel();
        Integer[] numbers = new Integer[]{ 1, 2, 3, 4 };
        model.setNumbers(numbers);
        EDBObject object = converter.convertModelToEDBObject(model, getTestConnectorInformation()).get(0);
        TestModel result = converter.convertEDBObjectToModel(TestModel.class, object);

        assertThat(result.getNumbers(), notNullValue());
        assertThat(numbers[0], is(result.getNumbers()[0]));
        assertThat(numbers[1], is(result.getNumbers()[1]));
        assertThat(numbers[2], is(result.getNumbers()[2]));
        assertThat(numbers[3], is(result.getNumbers()[3]));
    }
View Full Code Here

        object.putEDBObjectEntry("id", "test");
        object.putEDBObjectEntry("name", "testname");
        object.putEDBObjectEntry("number", 42);
        object.putEDBObjectEntry("check", false);
        object.putEDBObjectEntry("check2", true);
        TestModel model = converter.convertEDBObjectToModel(TestModel.class, object);
        assertThat(model.getId(), is("test"));
        assertThat(model.getName(), is("testname"));
        assertThat(model.isCheck(), is(false));
        assertThat(model.isCheck2(), is(true));
        Object version = ModelWrapper.wrap(model).retrieveInternalModelVersion();
        assertThat(version, notNullValue());
        assertThat((Integer) version, is(1));
    }
View Full Code Here

        ContextHolder.get().setCurrentContextId(CONTEXT_ID);
    }

    @Test
    public void testIfModelAgentIsSet_shouldWork() throws Exception {
        TestModel model = new TestModel();
        assertThat("TestModel isn't enhanced. Maybe you forgot to set the java agent?",
            ModelWrapper.isModel(model.getClass()), is(true));
    }
View Full Code Here

        assertThat(model.getWrappedDouble(), is(Double.MAX_VALUE));
    }

    @Test
    public void testSimpleModelToEDBObjectConversion_shouldWork() throws Exception {
        TestModel model = new TestModel();
        model.setId("test");
        Date date = new Date();
        model.setDate(date);
        model.setEnumeration(ENUM.A);
        model.setName("testobject");
        model.setCheck(false);
        model.setCheck2(true);
        model.setCheck3(false);

        ConnectorInformation id = getTestConnectorInformation();

        List<EDBObject> objects = converter.convertModelToEDBObject(model, id);
        EDBObject object = objects.get(0);
View Full Code Here

        assertThat(object.getString(EDBConstants.MODEL_TYPE), is(TestModel.class.getName()));
    }

    @Test
    public void testComplexModelToEDBObjectConversion_shouldWork() throws Exception {
        TestModel model = new TestModel();
        model.setId("test");
        SubModel sub = new SubModel();
        sub.setId("sub");
        sub.setValue("teststring");
        model.setSub(sub);
        ConnectorInformation id = getTestConnectorInformation();

        List<EDBObject> objects = converter.convertModelToEDBObject(model, id);
        EDBObject object = objects.get(1);
        assertThat(object.getString("sub"), is(ModelWrapper.wrap(sub).getCompleteModelOID()));
View Full Code Here

        assertThat(obj.getString(EDBConstants.MODEL_TYPE), is(RecursiveModel.class.getName()));
    }

    @Test
    public void testIfEDBObjectsContainCorrectType_shouldWork() throws Exception {
        TestModel model = new TestModel();
        model.setNumber(42);
        ConnectorInformation id = getTestConnectorInformation();
        List<EDBObject> objects = converter.convertModelToEDBObject(model, id);
        EDBObject object = objects.get(0);
        EDBObjectEntry entry = object.get("number");
        assertThat(entry.getType(), is(Integer.class.getName()));
View Full Code Here

        assertThat(entry.getType(), is(Integer.class.getName()));
    }

    @Test
    public void testComplexListModelToEDBObjectConversion_shouldWork() throws Exception {
        TestModel model = new TestModel();
        model.setId("test");
        SubModel sub1 = new SubModel();
        sub1.setId("sub1");
        sub1.setValue("teststring1");
        SubModel sub2 = new SubModel();
        sub2.setId("sub2");
        sub2.setValue("teststring2");
        List<SubModel> subs = new ArrayList<SubModel>();
        subs.add(sub1);
        subs.add(sub2);
        model.setSubs(subs);
        ConnectorInformation id = getTestConnectorInformation();
        List<EDBObject> objects = converter.convertModelToEDBObject(model, id);
        EDBObject object = objects.get(2);
        EDBObject subObject1 = objects.get(0);
        EDBObject subObject2 = objects.get(1);
View Full Code Here

    @Test
    public void testMapModelToEDBObjectConversion_shouldWork() throws Exception {
        Map<String, String> map = new HashMap<String, String>();
        map.put("keyA", "valueA");
        map.put("keyB", "valueB");
        TestModel model = new TestModel();
        model.setId("test");
        model.setMap(map);
        ConnectorInformation id = getTestConnectorInformation();
        EDBObject object = converter.convertModelToEDBObject(model, id).get(0);

        assertThat(object.getString(EDBConverter.getEntryNameForMapKey("map", 0)), is("keyA"));
        assertThat(object.getString(EDBConverter.getEntryNameForMapValue("map", 0)), is("valueA"));
View Full Code Here

TOP

Related Classes of org.openengsb.core.ekb.common.models.TestModel

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.