use of org.kie.workbench.common.dmn.api.definition.model.Definitions in project kie-wb-common by kiegroup.
the class ItemDefinitionUtilsTest method testFindByName.
@Test
public void testFindByName() {
final String name = "item1";
final ItemDefinition item1 = makeItem("item1");
final ItemDefinition item2 = makeItem("item2");
final Definitions definitions = mock(Definitions.class);
final List<ItemDefinition> itemDefinitions = asList(item1, item2);
when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
when(definitions.getItemDefinition()).thenReturn(itemDefinitions);
final Optional<ItemDefinition> actual = utils.findByName(name);
final Optional<ItemDefinition> expected = Optional.of(item1);
assertEquals(expected, actual);
}
use of org.kie.workbench.common.dmn.api.definition.model.Definitions in project kie-wb-common by kiegroup.
the class ItemDefinitionUtilsTest method testGetPrefixForNamespaceURIWhenPrefixForNamespaceURIIsNotPresent.
@Test
public void testGetPrefixForNamespaceURIWhenPrefixForNamespaceURIIsNotPresent() {
final String namespaceURI = FEEL.getUri();
final Definitions definitions = mock(Definitions.class);
when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
when(definitions.getPrefixForNamespaceURI(namespaceURI)).thenReturn(Optional.empty());
final Optional<String> prefix = utils.getPrefixForNamespaceURI(namespaceURI);
assertFalse(prefix.isPresent());
}
use of org.kie.workbench.common.dmn.api.definition.model.Definitions in project kie-wb-common by kiegroup.
the class QNameConverterTest method testToWidgetValueWhenDMNDiagramDefinesNameSpaces.
@Test
public void testToWidgetValueWhenDMNDiagramDefinesNameSpaces() {
final Definitions definitions = new Definitions();
definitions.getNsContext().put(DMNModelInstrumentedBase.Namespace.FEEL.getPrefix(), DMNModelInstrumentedBase.Namespace.FEEL.getUri());
final Decision decision = new Decision();
decision.setParent(definitions);
converter.setDMNModel(decision);
final String encoding = converter.toWidgetValue(BuiltInType.DATE.asQName());
assertEquals(ENCODED_FEEL_DATE, encoding);
}
use of org.kie.workbench.common.dmn.api.definition.model.Definitions in project kie-wb-common by kiegroup.
the class DMNGraphUtilsTest method testGetDefinitionsWithDiagram.
@Test
public void testGetDefinitionsWithDiagram() {
final Definitions expectedDefinitions = mock(Definitions.class);
final Diagram diagram = mock(Diagram.class);
when(dmnDiagramUtils.getDefinitions(diagram)).thenReturn(expectedDefinitions);
final Definitions actualDefinitions = utils.getDefinitions(diagram);
assertNotNull(actualDefinitions);
assertEquals(expectedDefinitions, actualDefinitions);
}
use of org.kie.workbench.common.dmn.api.definition.model.Definitions in project kie-wb-common by kiegroup.
the class HrefBuilderTest method testGetHrefForImportedDRGElement.
@Test
public void testGetHrefForImportedDRGElement() {
final DRGElement drgElement = mock(DRGElement.class);
final Name drgElementName = mock(Name.class);
final Name importName = mock(Name.class);
final Id id = mock(Id.class);
final Definitions definitions = mock(Definitions.class);
final Import anImport = mock(Import.class);
final List<Import> imports = singletonList(anImport);
final String includedModelName = "includedModel";
when(importName.getValue()).thenReturn(includedModelName);
when(anImport.getName()).thenReturn(importName);
when(anImport.getNamespace()).thenReturn("https://github.com/kiegroup/dmn/something");
when(id.getValue()).thenReturn("0000-1111-2222");
when(drgElementName.getValue()).thenReturn(includedModelName + ".Decision");
when(drgElement.getId()).thenReturn(id);
when(drgElement.getName()).thenReturn(drgElementName);
when(drgElement.getParent()).thenReturn(definitions);
when(definitions.getImport()).thenReturn(imports);
final String actual = HrefBuilder.getHref(drgElement);
final String expected = "https://github.com/kiegroup/dmn/something#0000-1111-2222";
assertEquals(expected, actual);
}
Aggregations