Search in sources :

Example 41 with ItemDefinition

use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.

the class ItemDefinitionDestroyHandlerTest method makeItemDefinition.

private ItemDefinition makeItemDefinition(final ItemDefinition... itemDefinitions) {
    final ItemDefinition itemDefinition = spy(new ItemDefinition());
    itemDefinition.getItemComponent().addAll(asList(itemDefinitions));
    return itemDefinition;
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)

Example 42 with ItemDefinition

use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.

the class ItemDefinitionDestroyHandlerTest method testFindItemDefinitionParentWhenItCouldNotBeFound.

@Test
public void testFindItemDefinitionParentWhenItCouldNotBeFound() {
    final DataType dataType = mock(DataType.class);
    final ItemDefinition parent = makeItemDefinition();
    final String parentUUID = "parentUUID";
    final String type = "type";
    final String nameValue = "name";
    final QName parentQName = mock(QName.class);
    final ItemDefinition itemDefinition = makeItemDefinition();
    final Name name = mock(Name.class);
    final List<ItemDefinition> itemDefinitions = singletonList(itemDefinition);
    when(name.getValue()).thenReturn(nameValue);
    when(itemDefinition.getName()).thenReturn(name);
    when(parentQName.getLocalPart()).thenReturn(type);
    when(parent.getTypeRef()).thenReturn(parentQName);
    when(dataType.getParentUUID()).thenReturn(parentUUID);
    when(itemDefinitionStore.get(parentUUID)).thenReturn(parent);
    doReturn(itemDefinitions).when(handler).itemDefinitions();
    final Optional<ItemDefinition> expectedParent = Optional.empty();
    final Optional<ItemDefinition> actualParent = handler.findItemDefinitionParent(dataType);
    assertEquals(expectedParent, actualParent);
}
Also used : QName(org.kie.workbench.common.dmn.api.property.dmn.QName) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Test(org.junit.Test)

Example 43 with ItemDefinition

use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.

the class ItemDefinitionRecordEngineTest method testCreate.

@Test
public void testCreate() {
    final DataType dataType = mock(DataType.class);
    final List<DataType> expectedAffectedDataTypes = asList(mock(DataType.class), mock(DataType.class));
    final ItemDefinition itemDefinition = mock(ItemDefinition.class);
    when(itemDefinitionCreateHandler.appendItemDefinition()).thenReturn(itemDefinition);
    when(dataTypeCreateHandler.append(dataType, itemDefinition)).thenReturn(expectedAffectedDataTypes);
    final List<DataType> actualAffectedDataTypes = recordEngine.create(dataType);
    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 44 with ItemDefinition

use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.

the class ItemDefinitionRecordEngineTest method testDoUpdate.

@Test
public void testDoUpdate() {
    final DataType dataType = mock(DataType.class);
    final ItemDefinition itemDefinition = mock(ItemDefinition.class);
    recordEngine.doUpdate(dataType, itemDefinition);
    verify(dataTypeUpdateHandler).update(dataType);
    verify(itemDefinitionUpdateHandler).update(dataType, itemDefinition);
}
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 45 with ItemDefinition

use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.

the class ItemDefinitionRecordEngineTest method testUpdate.

@Test
public void testUpdate() {
    final String uuid = "uuid";
    final String nameValue = "nameValue";
    final DataType dataType = mock(DataType.class);
    final ItemDefinition itemDefinition = mock(ItemDefinition.class);
    final Name name = mock(Name.class);
    final List<DataType> expectedDependentDataTypes = asList(mock(DataType.class), mock(DataType.class));
    when(dataType.isValid()).thenReturn(true);
    when(dataType.getUUID()).thenReturn(uuid);
    when(itemDefinitionStore.get(uuid)).thenReturn(itemDefinition);
    when(itemDefinition.getName()).thenReturn(name);
    when(name.getValue()).thenReturn(nameValue);
    when(dataTypeUpdateHandler.refreshDependentDataTypes(dataType, nameValue)).thenReturn(expectedDependentDataTypes);
    final List<DataType> actualDependentDataTypes = recordEngine.update(dataType);
    verify(recordEngine).doUpdate(dataType, itemDefinition);
    assertEquals(expectedDependentDataTypes, actualDependentDataTypes);
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) 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