Search in sources :

Example 91 with ItemDefinition

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);
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 92 with ItemDefinition

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);
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) CreationType(org.kie.workbench.common.dmn.client.editors.types.persistence.CreationType) Test(org.junit.Test)

Example 93 with ItemDefinition

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);
}
Also used : DataTypeManager(org.kie.workbench.common.dmn.client.editors.types.common.DataTypeManager) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) ArrayList(java.util.ArrayList) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 94 with ItemDefinition

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);
}
Also used : DataTypeManager(org.kie.workbench.common.dmn.client.editors.types.common.DataTypeManager) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 95 with ItemDefinition

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);
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Aggregations

ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)119 Test (org.junit.Test)86 DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)39 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)37 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)36 ArrayList (java.util.ArrayList)18 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)16 UnaryTests (org.kie.workbench.common.dmn.api.definition.model.UnaryTests)9 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)8 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)7 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)7 JSITItemDefinition (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITItemDefinition)7 Text (org.kie.workbench.common.dmn.api.property.dmn.Text)6 DataTypeManager (org.kie.workbench.common.dmn.client.editors.types.common.DataTypeManager)6 QName (javax.xml.namespace.QName)4 Import (org.kie.workbench.common.dmn.api.definition.model.Import)4 InputClause (org.kie.workbench.common.dmn.api.definition.model.InputClause)4 RefreshDataTypesListEvent (org.kie.workbench.common.dmn.client.editors.types.common.events.RefreshDataTypesListEvent)4 DMNGraphUtils (org.kie.workbench.common.dmn.client.graph.DMNGraphUtils)4 PMMLDocumentMetadata (org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata)3