Search in sources :

Example 81 with ItemDefinition

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

the class DataTypeConfirmationTest method testIfDataTypeDoesNotHaveLostSubDataTypesWhenSuccessCallbackIsExecuted.

@Test
public void testIfDataTypeDoesNotHaveLostSubDataTypesWhenSuccessCallbackIsExecuted() {
    final DataType dataType = mock(DataType.class);
    final ItemDefinition itemDefinition = mock(ItemDefinition.class);
    final Command onSuccess = mock(Command.class);
    final Command onError = mock(Command.class);
    final String uuid = "uuid";
    when(dataType.getUUID()).thenReturn(uuid);
    when(dataType.getType()).thenReturn(STRUCTURE);
    when(itemDefinitionStore.get(uuid)).thenReturn(itemDefinition);
    confirmation.ifDataTypeDoesNotHaveLostSubDataTypes(dataType, onSuccess, onError);
    verify(onSuccess).execute();
}
Also used : Command(org.uberfire.mvp.Command) 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 82 with ItemDefinition

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

the class DataTypeConfirmationTest method testIfDataTypeDoesNotHaveLostSubDataTypesWhenItemDefinitionItemComponentIsNotEmpty.

@Test
public void testIfDataTypeDoesNotHaveLostSubDataTypesWhenItemDefinitionItemComponentIsNotEmpty() {
    final DataType dataType = mock(DataType.class);
    final ItemDefinition itemDefinition = mock(ItemDefinition.class);
    final List<ItemDefinition> itemComponent = singletonList(mock(ItemDefinition.class));
    final Command onSuccess = mock(Command.class);
    final Command onError = mock(Command.class);
    final FlashMessage warningMessage = mock(FlashMessage.class);
    final String uuid = "uuid";
    when(dataType.getUUID()).thenReturn(uuid);
    when(dataType.getType()).thenReturn("tCity");
    when(itemDefinitionStore.get(uuid)).thenReturn(itemDefinition);
    when(itemDefinition.getItemComponent()).thenReturn(itemComponent);
    when(dataTypeHasFieldsWarningMessage.getFlashMessage(dataType, onSuccess, onError)).thenReturn(warningMessage);
    confirmation.ifDataTypeDoesNotHaveLostSubDataTypes(dataType, onSuccess, onError);
    verify(onSuccess, never()).execute();
    verify(flashMessageEvent).fire(warningMessage);
}
Also used : Command(org.uberfire.mvp.Command) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) FlashMessage(org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage) Test(org.junit.Test)

Example 83 with ItemDefinition

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

the class DataTypeListItemTest method testPersist.

@Test
public void testPersist() {
    final String uuid = "uuid";
    final DataType dataType = spy(makeDataType());
    final ItemDefinition itemDefinition = mock(ItemDefinition.class);
    final List<DataType> affectedDataTypes = emptyList();
    when(itemDefinitionStore.get(uuid)).thenReturn(itemDefinition);
    doReturn(uuid).when(dataType).getUUID();
    doReturn(affectedDataTypes).when(dataType).update();
    listItem.persist(dataType);
    final InOrder inOrder = inOrder(dataTypeManager, dataType);
    inOrder.verify(dataTypeManager).from(dataType);
    inOrder.verify(dataTypeManager).get();
    inOrder.verify(dataType).update();
}
Also used : InOrder(org.mockito.InOrder) 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 84 with ItemDefinition

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

the class DMNDocumentationFactoryTest method makeItemDefinition.

private ItemDefinition makeItemDefinition(final String name, final String type, final ItemDefinition... itemDefinitions) {
    final ItemDefinition itemDefinition = spy(new ItemDefinition());
    itemDefinition.setName(new Name(name));
    if (type != null) {
        itemDefinition.setTypeRef(new QName("://namespace", type));
    }
    itemDefinition.getItemComponent().addAll(asList(itemDefinitions));
    return itemDefinition;
}
Also used : QName(org.kie.workbench.common.dmn.api.property.dmn.QName) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) QName(org.kie.workbench.common.dmn.api.property.dmn.QName)

Example 85 with ItemDefinition

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

the class ItemDefinitionCreateHandlerTest method testGetItemDefinitionSiblingsWhenParentIsPresent.

@Test
public void testGetItemDefinitionSiblingsWhenParentIsPresent() {
    final DataType reference = mock(DataType.class);
    final String parentUUID = "parentUUID";
    final Optional<ItemDefinition> absoluteParent = Optional.of(mock(ItemDefinition.class));
    final List<ItemDefinition> expectedItemDefinitions = new ArrayList<>();
    when(reference.getParentUUID()).thenReturn(parentUUID);
    when(absoluteParent.get().getItemComponent()).thenReturn(expectedItemDefinitions);
    doReturn(absoluteParent).when(handler).lookupAbsoluteParent(parentUUID);
    final List<ItemDefinition> actualItemDefinitions = handler.getItemDefinitionSiblings(reference);
    assertEquals(expectedItemDefinitions, actualItemDefinitions);
}
Also used : 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)

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