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