Search in sources :

Example 96 with ItemDefinition

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

the class ItemDefinitionDestroyHandlerTest method testItemDefinitions.

@Test
public void testItemDefinitions() {
    final Definitions definitions = mock(Definitions.class);
    final ItemDefinition itemDefinition = makeItemDefinition();
    final List<ItemDefinition> expectedItemDefinitions = singletonList(itemDefinition);
    when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
    when(definitions.getItemDefinition()).thenReturn(expectedItemDefinitions);
    final List<ItemDefinition> actualItemDefinitions = handler.itemDefinitions();
    assertEquals(expectedItemDefinitions, actualItemDefinitions);
}
Also used : Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) Test(org.junit.Test)

Example 97 with ItemDefinition

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

the class ItemDefinitionRecordEngineTest method testCreateWithCreationTypeNested.

@Test
public void testCreateWithCreationTypeNested() {
    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);
    when(itemDefinitionCreateHandler.insertNested(dataType, reference)).thenReturn(itemDefinition);
    when(dataTypeCreateHandler.insertNested(dataType, reference, itemDefinition)).thenReturn(expectedAffectedDataTypes);
    final List<DataType> actualAffectedDataTypes = recordEngine.create(dataType, reference, NESTED);
    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 98 with ItemDefinition

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

the class ItemDefinitionDestroyHandlerTest method testFindItemDefinitionParentWhenParentDoesNotHaveTypeRef.

@Test
public void testFindItemDefinitionParentWhenParentDoesNotHaveTypeRef() {
    final DataType dataType = mock(DataType.class);
    final ItemDefinition parent = makeItemDefinition();
    final String parentUUID = "parentUUID";
    when(parent.getTypeRef()).thenReturn(null);
    when(dataType.getParentUUID()).thenReturn(parentUUID);
    when(itemDefinitionStore.get(parentUUID)).thenReturn(parent);
    final Optional<ItemDefinition> expectedParent = Optional.of(parent);
    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)

Example 99 with ItemDefinition

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

the class ItemDefinitionDestroyHandlerTest method testFindItemDefinitionParentWhenItCouldBeFound.

@Test
public void testFindItemDefinitionParentWhenItCouldBeFound() {
    final DataType dataType = mock(DataType.class);
    final ItemDefinition parent = makeItemDefinition();
    final String parentUUID = "parentUUID";
    final String type = "type";
    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(type);
    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.of(itemDefinition);
    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 100 with ItemDefinition

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

the class DataTypePickerWidgetTest method setup.

@Before
public void setup() {
    this.definitions = new Definitions();
    this.definitions.getItemDefinition().add(new ItemDefinition());
    this.definitions.getNsContext().put(Namespace.FEEL.getPrefix(), Namespace.FEEL.getUri());
    this.qNameConverter = spy(new QNameConverter());
    this.itemDefinitionUtils = spy(new ItemDefinitionUtils(dmnGraphUtils));
    when(typeSelector.getElement()).thenReturn(typeSelectorElement);
    when(option.getElement()).thenReturn(optionElement);
    when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
    when(dmnModel.getPrefixForNamespaceURI(Mockito.<String>any())).thenReturn(Optional.empty());
    when(manageContainer.getStyle()).thenReturn(manageContainerStyle);
    when(translationService.getTranslation(Mockito.<String>any())).thenAnswer(i -> i.getArguments()[0]);
    when(typeButton.getClassList()).thenReturn(typeButtonClassList);
    this.picker = spy(new DataTypePickerWidget(typeButton, manageContainer, manageLabel, translationService, qNameConverter, dmnGraphUtils, dataTypePageActiveEvent, itemDefinitionUtils, readOnlyProvider));
}
Also used : ItemDefinitionUtils(org.kie.workbench.common.dmn.client.editors.types.common.ItemDefinitionUtils) Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) Before(org.junit.Before)

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