Examples of EDBObject


Examples of org.openengsb.core.edb.api.EDBObject

    @Before
    public void setup() {
        this.service = new QueryInterfaceService();
        EngineeringDatabaseService edbService = mock(EngineeringDatabaseService.class);

        EDBObject edbObject = new EDBObject("testoid");
        edbObject.putEDBObjectEntry("id", "testid");
        edbObject.putEDBObjectEntry("date", new Date());
        edbObject.putEDBObjectEntry("name", "testname");
        edbObject.putEDBObjectEntry("enumeration", "A", ENUM.class);
        edbObject.putEDBObjectEntry(EDBConverter.getEntryNameForList("list", 0), "blub");
        edbObject.putEDBObjectEntry(EDBConverter.getEntryNameForList("list", 1), "blab");
        edbObject.putEDBObjectEntry(EDBConverter.getEntryNameForList("list", 2), "blob");
        edbObject.putEDBObjectEntry("sub", "suboid1", SubModel.class);
        edbObject.putEDBObjectEntry(EDBConverter.getEntryNameForList("subs", 0), "suboid2", SubModel.class);
        edbObject.putEDBObjectEntry(EDBConverter.getEntryNameForList("subs", 1), "suboid3", SubModel.class);
        edbObject.putEDBObjectEntry("number", Integer.valueOf(42));
        edbObject.putEDBObjectEntry(EDBConstants.MODEL_TYPE, TestModel.class.getName());

        EDBObject edbObjectImpl = new EDBObject("testoidimpl");
        edbObjectImpl.putEDBObjectEntry("id", "testid");
        edbObjectImpl.putEDBObjectEntry("date", new Date());
        edbObjectImpl.putEDBObjectEntry("name", "testname");
        edbObjectImpl.putEDBObjectEntry("enumeration", "A", ENUM.class);
        edbObjectImpl.putEDBObjectEntry(EDBConverter.getEntryNameForList("list", 0), "blub");
        edbObjectImpl.putEDBObjectEntry(EDBConverter.getEntryNameForList("list", 1), "blab");
        edbObjectImpl.putEDBObjectEntry(EDBConverter.getEntryNameForList("list", 2), "blob");
        edbObjectImpl.putEDBObjectEntry("sub", "suboid1", SubModel.class);
        edbObjectImpl.putEDBObjectEntry(EDBConverter.getEntryNameForList("subs", 0), "suboid2", SubModel.class);
        edbObjectImpl.putEDBObjectEntry(EDBConverter.getEntryNameForList("subs", 1), "suboid3", SubModel.class);
        edbObjectImpl.putEDBObjectEntry(EDBConstants.MODEL_TYPE, TestModel2.class.getName());

        EDBObject mapTest = new EDBObject("mapoid");
        mapTest.putEDBObjectEntry("id", "testid");
        mapTest.putEDBObjectEntry(EDBConverter.getEntryNameForMapKey("map", 0), "keyA");
        mapTest.putEDBObjectEntry(EDBConverter.getEntryNameForMapValue("map", 0), "valueA");
        mapTest.putEDBObjectEntry(EDBConverter.getEntryNameForMapKey("map", 1), "keyB");
        mapTest.putEDBObjectEntry(EDBConverter.getEntryNameForMapValue("map", 1), "valueB");
        mapTest.putEDBObjectEntry(EDBConverter.getEntryNameForMapKey("map", 2), "keyC");
        mapTest.putEDBObjectEntry(EDBConverter.getEntryNameForMapValue("map", 2), "valueC");
        mapTest.putEDBObjectEntry("number", Integer.valueOf(42));
        mapTest.putEDBObjectEntry(EDBConstants.MODEL_TYPE, TestModel.class.getName());

        EDBObject subObject1 = new EDBObject("suboid1");
        subObject1.putEDBObjectEntry("id", "testid");
        subObject1.putEDBObjectEntry("value", "testvalue");
        subObject1.putEDBObjectEntry(EDBConstants.MODEL_TYPE, SubModel.class.getName());

        EDBObject subObject2 = new EDBObject("suboid2");
        subObject2.putEDBObjectEntry("id", "AAAAA");
        subObject2.putEDBObjectEntry("value", "BBBBB");
        subObject2.putEDBObjectEntry(EDBConstants.MODEL_TYPE, SubModel.class.getName());

        EDBObject subObject3 = new EDBObject("suboid3");
        subObject3.putEDBObjectEntry("id", "CCCCC");
        subObject3.putEDBObjectEntry("value", "DDDDD");
        subObject3.putEDBObjectEntry(EDBConstants.MODEL_TYPE, SubModel.class.getName());

        when(edbService.getObject(eq("testoid"), anyLong())).thenReturn(edbObject);
        when(edbService.getObject(eq("testoidimpl"), anyLong())).thenReturn(edbObjectImpl);
        when(edbService.getObject(eq("mapoid"), anyLong())).thenReturn(mapTest);
        when(edbService.getObject(eq("suboid1"), anyLong())).thenReturn(subObject1);
View Full Code Here

Examples of org.openengsb.core.edb.api.EDBObject

    }

    @Test
    public void testEDBObjectToRecursiveModelWithCompositionConversion_shouldWork() throws Exception {
        // prepare
        EDBObject root = new EDBObject("root");
        root.putEDBObjectEntry(EDBConstants.MODEL_TYPE, RecursiveModel.class.getName());
        root.putEDBObjectEntry(EDBConstants.MODEL_OID, "root");
        root.putEDBObjectEntry(EDBConstants.MODEL_VERSION, Integer.valueOf(1));
        root.putEDBObjectEntry("id", "root");
        root.putEDBObjectEntry("children.0", "child1");
        root.putEDBObjectEntry("children.1", "child2");

        EDBObject child1 = new EDBObject("child1");
        child1.putEDBObjectEntry(EDBConstants.MODEL_TYPE, RecursiveModel.class.getName());
        child1.putEDBObjectEntry(EDBConstants.MODEL_OID, "child1");
        child1.putEDBObjectEntry(EDBConstants.MODEL_VERSION, Integer.valueOf(1));
        child1.putEDBObjectEntry("id", "child1");
        child1.putEDBObjectEntry("children.0", "child3");
        child1.putEDBObjectEntry("children.1", "child4");

        EDBObject child2 = new EDBObject("child2");
        child2.putEDBObjectEntry(EDBConstants.MODEL_TYPE, RecursiveModel.class.getName());
        child2.putEDBObjectEntry(EDBConstants.MODEL_OID, "child2");
        child2.putEDBObjectEntry(EDBConstants.MODEL_VERSION, Integer.valueOf(1));
        child2.putEDBObjectEntry("id", "child2");

        EDBObject child3 = new EDBObject("child3");
        child3.putEDBObjectEntry(EDBConstants.MODEL_TYPE, RecursiveModel.class.getName());
        child3.putEDBObjectEntry(EDBConstants.MODEL_OID, "child3");
        child3.putEDBObjectEntry(EDBConstants.MODEL_VERSION, Integer.valueOf(1));
        child3.putEDBObjectEntry("id", "child3");

        EDBObject child4 = new EDBObject("child4");
        child4.putEDBObjectEntry(EDBConstants.MODEL_TYPE, RecursiveModel.class.getName());
        child4.putEDBObjectEntry(EDBConstants.MODEL_OID, "child4");
        child4.putEDBObjectEntry(EDBConstants.MODEL_VERSION, Integer.valueOf(1));
        child4.putEDBObjectEntry("id", "child4");

        when(mockedService.getObject("child1")).thenReturn(child1);
        when(mockedService.getObject("child2")).thenReturn(child2);
        when(mockedService.getObject("child3")).thenReturn(child3);
        when(mockedService.getObject("child4")).thenReturn(child4);
View Full Code Here

Examples of org.openengsb.core.edb.api.EDBObject

        model.setModelAId("testReferenceToModelA");
        model.setModelBId("testReferenceToModelB");

        List<EDBObject> objects = converter.convertModelToEDBObject(model, getTestConnectorInformation());
        assertThat(objects.size(), is(1));
        EDBObject result = objects.get(0);
        String key1 = getReferenceString(model.getClass(), "modelAId");
        String key2 = getReferenceString(model.getClass(), "modelBId");
        assertThat(result.getString(key1), is(CONTEXT_ID + "/testReferenceToModelA"));
        assertThat(result.getString(key2), is(CONTEXT_ID + "/testReferenceToModelB"));
    }
View Full Code Here

Examples of org.openengsb.core.edb.api.EDBObject

        assertThat(result.getString(key2), is(CONTEXT_ID + "/testReferenceToModelB"));
    }

    @Test
    public void testIfEngineeringObjectInformationIsDeleted_shouldDeleteEOInformation() throws Exception {
        EDBObject object = new EDBObject("test");
        object.putEDBObjectEntry(EDBConstants.MODEL_TYPE, EngineeringObjectModel.class.getName());
        object.putEDBObjectEntry(EDBConstants.MODEL_OID, "test");
        object.putEDBObjectEntry(EDBConstants.MODEL_VERSION, Integer.valueOf(1));
        String key1 = getReferenceString(EngineeringObjectModel.class, "modelAId");
        String key2 = getReferenceString(EngineeringObjectModel.class, "modelBId");
        object.putEDBObjectEntry(key1, "testReferenceA");
        object.putEDBObjectEntry(key2, "testReferenceB");
        converter.convertEDBObjectToModel(EngineeringObjectModel.class, object);
        assertThat(object.get(key1), nullValue());
        assertThat(object.get(key2), nullValue());
    }
View Full Code Here

Examples of org.openengsb.core.edb.api.EDBObject

    /**
     * Converts a JPAObject object into an EDBObject.
     */
    public static EDBObject convertJPAObjectToEDBObject(JPAObject object) {
        EDBObject result = new EDBObject(object.getOID());
        for (JPAEntry kvp : object.getEntries()) {
            EDBObjectEntry entry = convertJPAEntryToEDBObjectEntry(kvp);
            result.put(entry.getKey(), entry);
        }
        result.setDeleted(object.isDeleted());
        if (object.getTimestamp() != null) {
            result.updateTimestamp(object.getTimestamp());
        }
        return result;
    }
View Full Code Here

Examples of org.openengsb.core.edb.api.EDBObject

        model.setPrimitiveInt(Integer.MAX_VALUE);
        model.setPrimitiveLong(Long.MAX_VALUE);
        model.setPrimitiveShort(Short.MAX_VALUE);
        ConnectorInformation id = getTestConnectorInformation();
        List<EDBObject> objects = converter.convertModelToEDBObject(model, id);
        EDBObject object = objects.get(0);
        // check entry types
        assertThat(object.get("booleanByGet").getType(), is(Boolean.class.getName()));
        assertThat(object.get("booleanByIs").getType(), is(Boolean.class.getName()));
        assertThat(object.get("primitiveChar").getType(), is(Character.class.getName()));
        assertThat(object.get("primitiveShort").getType(), is(Short.class.getName()));
        assertThat(object.get("primitiveInt").getType(), is(Integer.class.getName()));
        assertThat(object.get("primitiveLong").getType(), is(Long.class.getName()));
        assertThat(object.get("primitiveFloat").getType(), is(Float.class.getName()));
        assertThat(object.get("primitiveDouble").getType(), is(Double.class.getName()));
        // check values
        assertThat(object.getBoolean("booleanByGet"), is(true));
        assertThat(object.getBoolean("booleanByIs"), is(true));
        assertThat(object.getChar("primitiveChar"), is(Character.MAX_VALUE));
        assertThat(object.getShort("primitiveShort"), is(Short.MAX_VALUE));
        assertThat(object.getInteger("primitiveInt"), is(Integer.MAX_VALUE));
        assertThat(object.getLong("primitiveLong"), is(Long.MAX_VALUE));
        assertThat(object.getFloat("primitiveFloat"), is(Float.MAX_VALUE));
        assertThat(object.getDouble("primitiveDouble"), is(Double.MAX_VALUE));
    }
View Full Code Here

Examples of org.openengsb.core.edb.api.EDBObject

        assertThat(object.getDouble("primitiveDouble"), is(Double.MAX_VALUE));
    }

    @Test
    public void primitivePropertyConversion_toModel_works() {
        EDBObject object = new EDBObject("test");
        object.putEDBObjectEntry(EDBConstants.MODEL_TYPE, PrimitivePropertiesModel.class.getName());
        object.putEDBObjectEntry(EDBConstants.MODEL_OID, "test");
        object.putEDBObjectEntry(EDBConstants.MODEL_VERSION, Integer.valueOf(1));
        object.putEDBObjectEntry("id", "test");
        object.putEDBObjectEntry("booleanByGet", true);
        object.putEDBObjectEntry("booleanByIs", true);
        object.putEDBObjectEntry("primitiveChar", Character.MAX_VALUE);
        object.putEDBObjectEntry("primitiveShort", Short.MAX_VALUE);
        object.putEDBObjectEntry("primitiveInt", Integer.MAX_VALUE);
        object.putEDBObjectEntry("primitiveLong", Long.MAX_VALUE);
        object.putEDBObjectEntry("primitiveFloat", Float.MAX_VALUE);
        object.putEDBObjectEntry("primitiveDouble", Double.MAX_VALUE);

        PrimitivePropertiesModel model = converter.convertEDBObjectToModel(PrimitivePropertiesModel.class, object);
        assertThat(model.getId(), is("test"));
        assertThat(model.getBooleanByGet(), is(true));
        assertThat(model.isBooleanByIs(), is(true));
View Full Code Here

Examples of org.openengsb.core.edb.api.EDBObject

    }

    @Test
    public void testInsert_shouldWork() throws Exception {
        EDBCommit commit = edbService.createEDBCommit(null, null, null);
        EDBObject testObject = new EDBObject("testobject");
        testObject.putEDBObjectEntry("testkey", "testvalue");
        commit.insert(testObject);
        Long testtime = edbService.commit(commit);
        assertThat(testtime.longValue(), not(0L));
    }
View Full Code Here

Examples of org.openengsb.core.edb.api.EDBObject

    }

    @Test
    public void testRetrieveObject_shouldWork() throws Exception {
        EDBCommit commit = edbService.createEDBCommit(null, null, null);
        EDBObject testObject = new EDBObject("newtestobject");
        testObject.putEDBObjectEntry("newtestkey", "newtestvalue");
        commit.insert(testObject);

        edbService.commit(commit);

        EDBObject obj = edbService.getObject("newtestobject");
        assertThat(obj, notNullValue());
    }
View Full Code Here

Examples of org.openengsb.core.edb.api.EDBObject

        model.setWrappedLong(Long.MAX_VALUE);
        model.setWrappedShort(Short.MAX_VALUE);

        ConnectorInformation id = getTestConnectorInformation();
        List<EDBObject> objects = converter.convertModelToEDBObject(model, id);
        EDBObject object = objects.get(0);
        // check entry types
        assertThat(object.get("booleanByGet").getType(), is(Boolean.class.getName()));
        assertThat(object.get("booleanByIs").getType(), is(Boolean.class.getName()));
        assertThat(object.get("wrappedChar").getType(), is(Character.class.getName()));
        assertThat(object.get("wrappedShort").getType(), is(Short.class.getName()));
        assertThat(object.get("wrappedInt").getType(), is(Integer.class.getName()));
        assertThat(object.get("wrappedLong").getType(), is(Long.class.getName()));
        assertThat(object.get("wrappedFloat").getType(), is(Float.class.getName()));
        assertThat(object.get("wrappedDouble").getType(), is(Double.class.getName()));
        // check values
        assertThat(object.getBoolean("booleanByGet"), is(true));
        assertThat(object.getBoolean("booleanByIs"), is(true));
        assertThat(object.getChar("wrappedChar"), is(Character.MAX_VALUE));
        assertThat(object.getShort("wrappedShort"), is(Short.MAX_VALUE));
        assertThat(object.getInteger("wrappedInt"), is(Integer.MAX_VALUE));
        assertThat(object.getLong("wrappedLong"), is(Long.MAX_VALUE));
        assertThat(object.getFloat("wrappedFloat"), is(Float.MAX_VALUE));
        assertThat(object.getDouble("wrappedDouble"), is(Double.MAX_VALUE));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.