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();
}
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);
}
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();
}
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;
}
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);
}
Aggregations