Search in sources :

Example 6 with DataObjectProperty

use of org.kie.workbench.common.dmn.api.editors.types.DataObjectProperty in project kie-wb-common by kiegroup.

the class DataTypeListTest method testUpdatePropertiesReferences.

@Test
public void testUpdatePropertiesReferences() {
    final List<DataObject> imported = new ArrayList<>();
    final HashMap<String, String> renamed = new HashMap<>();
    final String propertyType1 = "type";
    final String propertyNewType1 = "type-1";
    final String uniqueType = "uniqueType";
    renamed.put(propertyType1, propertyNewType1);
    final DataObjectProperty prop1 = mock(DataObjectProperty.class);
    final DataObjectProperty prop2 = mock(DataObjectProperty.class);
    when(prop1.getType()).thenReturn(propertyType1);
    when(prop2.getType()).thenReturn(uniqueType);
    doReturn(true).when(dataTypeList).isPropertyTypePresent(uniqueType, imported);
    doReturn(true).when(dataTypeList).isPropertyTypePresent(propertyNewType1, imported);
    final DataObject do1 = new DataObject();
    do1.setProperties(Arrays.asList(prop1, prop2));
    imported.add(do1);
    dataTypeList.updatePropertiesReferences(imported, renamed);
    verify(prop1).setType(propertyNewType1);
    verify(prop2).setType(uniqueType);
    verify(dataTypeList).isPropertyTypePresent(propertyNewType1, imported);
    verify(dataTypeList).isPropertyTypePresent(uniqueType, imported);
}
Also used : DataObjectProperty(org.kie.workbench.common.dmn.api.editors.types.DataObjectProperty) DataObject(org.kie.workbench.common.dmn.api.editors.types.DataObject) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

DataObjectProperty (org.kie.workbench.common.dmn.api.editors.types.DataObjectProperty)6 Test (org.junit.Test)4 DataObject (org.kie.workbench.common.dmn.api.editors.types.DataObject)3 DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)3 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1