Search in sources :

Example 1 with ItemDefinitionUtils

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

the class DecisionTableEditorDefinitionEnricherTest method testAddInputClauseRequirementWhenDataTypeIsStructureAndDontHaveFields.

@Test
public void testAddInputClauseRequirementWhenDataTypeIsStructureAndDontHaveFields() {
    final ItemDefinition tPerson = mock(ItemDefinition.class);
    final String inputData = "InputData";
    final List<DecisionTableEditorDefinitionEnricher.ClauseRequirement> inputClauseRequirements = new ArrayList<>();
    final ItemDefinitionUtils itemDefinitionUtils = new ItemDefinitionUtils(mock(DMNGraphUtils.class));
    final DecisionTableEditorDefinitionEnricher enricher = new DecisionTableEditorDefinitionEnricher(null, null, itemDefinitionUtils);
    when(tPerson.getName()).thenReturn(new Name(TYPE_PERSON));
    when(tPerson.getTypeRef()).thenReturn(null);
    when(tPerson.getItemComponent()).thenReturn(emptyList());
    enricher.addInputClauseRequirement(tPerson, inputClauseRequirements, inputData);
    assertEquals(1, inputClauseRequirements.size());
    assertEquals("InputData", inputClauseRequirements.get(0).text);
    assertEquals(TYPE_PERSON, inputClauseRequirements.get(0).typeRef.getLocalPart());
}
Also used : ItemDefinitionUtils(org.kie.workbench.common.dmn.client.editors.types.common.ItemDefinitionUtils) DMNGraphUtils(org.kie.workbench.common.dmn.client.graph.DMNGraphUtils) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) ArrayList(java.util.ArrayList) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 2 with ItemDefinitionUtils

use of org.kie.workbench.common.dmn.client.editors.types.common.ItemDefinitionUtils 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)2 ItemDefinitionUtils (org.kie.workbench.common.dmn.client.editors.types.common.ItemDefinitionUtils)2 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 Test (org.junit.Test)1 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)1 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)1 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)1 DMNGraphUtils (org.kie.workbench.common.dmn.client.graph.DMNGraphUtils)1