Search in sources :

Example 31 with ItemDefinition

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

the class IncludedModelModalTest method testGetItemDefinitionConsumer.

@Test
public void testGetItemDefinitionConsumer() {
    final ItemDefinition itemDefinition1 = mock(ItemDefinition.class);
    final ItemDefinition itemDefinition2 = mock(ItemDefinition.class);
    final List<ItemDefinition> expectedNewItemDefinitions = asList(itemDefinition1, itemDefinition2);
    modal.getItemDefinitionConsumer().accept(expectedNewItemDefinitions);
    verify(refreshDataTypesListEvent).fire(refreshDataTypesListArgumentCaptor.capture());
    final List<ItemDefinition> actualNewItemDefinitions = refreshDataTypesListArgumentCaptor.getValue().getNewItemDefinitions();
    assertEquals(expectedNewItemDefinitions, actualNewItemDefinitions);
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) Test(org.junit.Test)

Example 32 with ItemDefinition

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

the class IncludedModelModalTest method testRefreshDataTypesList.

@Test
public void testRefreshDataTypesList() {
    final BaseIncludedModelActiveRecord includedModel = mock(BaseIncludedModelActiveRecord.class);
    final Consumer<List<ItemDefinition>> listConsumer = list -> {
    /* Nothing. */
    };
    final String modelName = "model1";
    final String namespace = "://namespace1";
    when(includedModel.getName()).thenReturn(modelName);
    when(includedModel.getNamespace()).thenReturn(namespace);
    doReturn(listConsumer).when(modal).getItemDefinitionConsumer();
    modal.refreshDataTypesList(includedModel);
    verify(client).loadItemDefinitionsByNamespace(modelName, namespace, listConsumer);
}
Also used : GwtMockitoTestRunner(com.google.gwtmockito.GwtMockitoTestRunner) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) DMNAssetsDropdown(org.kie.workbench.common.dmn.client.editors.included.modal.dropdown.DMNAssetsDropdown) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) RefreshDataTypesListEvent(org.kie.workbench.common.dmn.client.editors.types.common.events.RefreshDataTypesListEvent) IncludedModelsPagePresenter(org.kie.workbench.common.dmn.client.editors.included.IncludedModelsPagePresenter) BaseIncludedModelActiveRecord(org.kie.workbench.common.dmn.client.editors.included.BaseIncludedModelActiveRecord) Maps(org.kie.soup.commons.util.Maps) Mockito.spy(org.mockito.Mockito.spy) Captor(org.mockito.Captor) ITEM_DEFINITION_COUNT_METADATA(org.kie.workbench.common.dmn.client.editors.included.modal.dropdown.DMNAssetsDropdownItemsProvider.ITEM_DEFINITION_COUNT_METADATA) ArgumentCaptor(org.mockito.ArgumentCaptor) IMPORT_TYPE_METADATA(org.kie.workbench.common.dmn.client.editors.included.modal.dropdown.DMNAssetsDropdownItemsProvider.IMPORT_TYPE_METADATA) HTMLElement(elemental2.dom.HTMLElement) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) PATH_METADATA(org.kie.workbench.common.dmn.client.editors.included.modal.dropdown.DMNAssetsDropdownItemsProvider.PATH_METADATA) Mockito.doReturn(org.mockito.Mockito.doReturn) Command(org.uberfire.mvp.Command) Before(org.junit.Before) PMMLIncludedModelActiveRecord(org.kie.workbench.common.dmn.client.editors.included.PMMLIncludedModelActiveRecord) ImportRecordEngine(org.kie.workbench.common.dmn.client.editors.included.imports.persistence.ImportRecordEngine) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) WIDTH(org.kie.workbench.common.dmn.client.editors.included.modal.IncludedModelModal.WIDTH) Mockito.doNothing(org.mockito.Mockito.doNothing) Mockito.when(org.mockito.Mockito.when) DMNIncludeModelsClient(org.kie.workbench.common.dmn.client.api.included.legacy.DMNIncludeModelsClient) KieAssetsDropdownItem(org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem) DRG_ELEMENT_COUNT_METADATA(org.kie.workbench.common.dmn.client.editors.included.modal.dropdown.DMNAssetsDropdownItemsProvider.DRG_ELEMENT_COUNT_METADATA) Mockito.verify(org.mockito.Mockito.verify) Consumer(java.util.function.Consumer) PMML_MODEL_COUNT_METADATA(org.kie.workbench.common.dmn.client.editors.included.modal.dropdown.DMNAssetsDropdownItemsProvider.PMML_MODEL_COUNT_METADATA) List(java.util.List) DMNImportTypes(org.kie.workbench.common.dmn.api.editors.included.DMNImportTypes) Assert.assertFalse(org.junit.Assert.assertFalse) Optional(java.util.Optional) DMNIncludedModelActiveRecord(org.kie.workbench.common.dmn.client.editors.included.DMNIncludedModelActiveRecord) RefreshDecisionComponents(org.kie.workbench.common.dmn.client.docks.navigator.events.RefreshDecisionComponents) EventSourceMock(org.uberfire.mocks.EventSourceMock) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) Arrays.asList(java.util.Arrays.asList) List(java.util.List) BaseIncludedModelActiveRecord(org.kie.workbench.common.dmn.client.editors.included.BaseIncludedModelActiveRecord) Test(org.junit.Test)

Example 33 with ItemDefinition

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

the class DataTypesPageTest method makeItem.

private ItemDefinition makeItem(final String itemName) {
    final ItemDefinition itemDefinition = mock(ItemDefinition.class);
    final Name name = mock(Name.class);
    when(name.getValue()).thenReturn(itemName);
    when(itemDefinition.getName()).thenReturn(name);
    return itemDefinition;
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) Name(org.kie.workbench.common.dmn.api.property.dmn.Name)

Example 34 with ItemDefinition

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

the class DataTypesPageTest method testMakeDataType.

@Test
public void testMakeDataType() {
    final ItemDefinition itemDefinition = mock(ItemDefinition.class);
    final DataType expectedDataType = mock(DataType.class);
    when(dataTypeManager.from(itemDefinition)).thenReturn(dataTypeManager);
    when(dataTypeManager.get()).thenReturn(expectedDataType);
    final DataType actualDataType = page.makeDataType(itemDefinition);
    assertEquals(expectedDataType, actualDataType);
}
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 35 with ItemDefinition

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

the class DataTypesPageTest method testOnRefreshDataTypesListWithNewItemDefinitionWhenPageIsLoaded.

@Test
public void testOnRefreshDataTypesListWithNewItemDefinitionWhenPageIsLoaded() {
    final ItemDefinition itemDefinition1 = mock(ItemDefinition.class);
    final ItemDefinition itemDefinition2 = mock(ItemDefinition.class);
    final List<ItemDefinition> newItemDefinitions = asList(itemDefinition1, itemDefinition2);
    final RefreshDataTypesListEvent event = new RefreshDataTypesListEvent(newItemDefinitions);
    doReturn(true).when(page).isLoaded();
    page.onRefreshDataTypesListWithNewItemDefinitions(event);
    verify(page).refreshItemDefinitions(newItemDefinitions);
    verify(page).reload();
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) RefreshDataTypesListEvent(org.kie.workbench.common.dmn.client.editors.types.common.events.RefreshDataTypesListEvent) 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