use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.
the class ItemDefinitionRecordEngineTest method testCreateWithCreationTypeNotNested.
@Test
public void testCreateWithCreationTypeNotNested() {
final DataType dataType = mock(DataType.class);
final DataType reference = mock(DataType.class);
final List<DataType> expectedAffectedDataTypes = asList(mock(DataType.class), mock(DataType.class));
final ItemDefinition itemDefinition = mock(ItemDefinition.class);
final CreationType creationType = ABOVE;
when(itemDefinitionCreateHandler.insertSibling(dataType, reference, creationType)).thenReturn(itemDefinition);
when(dataTypeCreateHandler.insertSibling(dataType, reference, creationType, itemDefinition)).thenReturn(expectedAffectedDataTypes);
final List<DataType> actualAffectedDataTypes = recordEngine.create(dataType, reference, creationType);
assertEquals(expectedAffectedDataTypes, actualAffectedDataTypes);
}
use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.
the class DataTypeCreateHandlerTest method testInsertNotNested.
@Test
public void testInsertNotNested() {
final DataType dataType = mock(DataType.class);
final DataType reference = mock(DataType.class);
final ItemDefinition itemDefinition = mock(ItemDefinition.class);
final List<DataType> expectedAffectedDataTypes = asList(mock(DataType.class), mock(DataType.class));
final CreationType creationType = ABOVE;
doReturn(expectedAffectedDataTypes).when(handler).insertSibling(dataType, reference, creationType, itemDefinition);
final List<DataType> actualAffectedDataTypes = handler.insertSibling(dataType, reference, creationType, itemDefinition);
assertEquals(expectedAffectedDataTypes, actualAffectedDataTypes);
}
use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.
the class DataTypeCreateHandlerTest method testInsertNestedWhenReferenceTypeIsATopLevelDataType.
@Test
public void testInsertNestedWhenReferenceTypeIsATopLevelDataType() {
final String parentUUID = "parentUUID";
final String type = "tCity";
final DataType dataType = mock(DataType.class);
final DataType reference = mock(DataType.class);
final DataType topLevelReference = mock(DataType.class);
final DataType updatedDataType = mock(DataType.class);
final DataTypeManager updatedDataTypeManager = mock(DataTypeManager.class);
final DataTypeManager topLevelReferenceDataTypeManager = mock(DataTypeManager.class);
final ItemDefinition itemDefinition = mock(ItemDefinition.class);
final List<DataType> expectedAffectedDataTypes = asList(mock(DataType.class), mock(DataType.class));
final List<DataType> referenceSubDataTypes = new ArrayList<>();
when(reference.getUUID()).thenReturn(parentUUID);
when(reference.getType()).thenReturn(type);
when(topLevelReference.getSubDataTypes()).thenReturn(referenceSubDataTypes);
when(topLevelReference.getName()).thenReturn(type);
when(topLevelReference.getType()).thenReturn(BuiltInType.STRING.getName());
when(dataTypeManager.withDataType(topLevelReference)).thenReturn(topLevelReferenceDataTypeManager);
when(dataTypeManager.withDataType(updatedDataType)).thenReturn(updatedDataTypeManager);
when(recordEngine.update(updatedDataType)).thenReturn(expectedAffectedDataTypes);
when(dataTypeStore.getTopLevelDataTypes()).thenReturn(singletonList(topLevelReference));
doReturn(updatedDataType).when(handler).updateDataTypeProperties(dataType, parentUUID, itemDefinition);
final List<DataType> actualAffectedDataTypes = handler.insertNested(dataType, reference, itemDefinition);
verify(topLevelReferenceDataTypeManager).asStructure();
assertEquals(singletonList(updatedDataType), referenceSubDataTypes);
assertEquals(expectedAffectedDataTypes, actualAffectedDataTypes);
}
use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.
the class DataTypeCreateHandlerTest method testAppend.
@Test
public void testAppend() {
final DataType dataType = mock(DataType.class);
final DataType dataTypeWithoutName = mock(DataType.class);
final DataType updatedDataType = mock(DataType.class);
final DataTypeManager withDataType = mock(DataTypeManager.class);
final DataTypeManager withNoName = mock(DataTypeManager.class);
final ItemDefinition itemDefinition = mock(ItemDefinition.class);
final List<DataType> expectedAffectedDataTypes = asList(mock(DataType.class), mock(DataType.class));
when(dataTypeManager.withDataType(dataType)).thenReturn(withDataType);
when(withDataType.withNoName()).thenReturn(withNoName);
when(withNoName.get()).thenReturn(dataTypeWithoutName);
when(recordEngine.update(updatedDataType)).thenReturn(expectedAffectedDataTypes);
doReturn(updatedDataType).when(handler).updateDataTypeProperties(dataTypeWithoutName, TOP_LEVEL_PARENT_UUID, itemDefinition);
final List<DataType> actualAffectedDataTypes = handler.append(dataType, itemDefinition);
assertEquals(expectedAffectedDataTypes, actualAffectedDataTypes);
}
use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.
the class ItemDefinitionDestroyHandlerTest method testFindItemDefinitionParentWhenParentDoesNotExist.
@Test
public void testFindItemDefinitionParentWhenParentDoesNotExist() {
final DataType dataType = mock(DataType.class);
final String parentUUID = "parentUUID";
when(dataType.getParentUUID()).thenReturn(parentUUID);
when(itemDefinitionStore.get(parentUUID)).thenReturn(null);
final Optional<ItemDefinition> expectedParent = Optional.empty();
final Optional<ItemDefinition> actualParent = handler.findItemDefinitionParent(dataType);
assertEquals(expectedParent, actualParent);
}
Aggregations