use of org.kie.workbench.common.dmn.api.definition.model.Definitions in project kie-wb-common by kiegroup.
the class HrefBuilderTest method testGetHrefForImportedDRGElementWhenImportHasAnOddName.
@Test
public void testGetHrefForImportedDRGElementWhenImportHasAnOddName() {
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 = "d.i.v.i.";
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);
}
use of org.kie.workbench.common.dmn.api.definition.model.Definitions in project kie-wb-common by kiegroup.
the class HrefBuilderTest method testGetHref.
@Test
public void testGetHref() {
final DRGElement drgElement = mock(DRGElement.class);
final Name name = mock(Name.class);
final Id id = mock(Id.class);
final Definitions definitions = mock(Definitions.class);
final String uuid = "0000-1111-2222";
when(id.getValue()).thenReturn(uuid);
when(name.getValue()).thenReturn("Decision");
when(drgElement.getId()).thenReturn(id);
when(drgElement.getName()).thenReturn(name);
when(drgElement.getParent()).thenReturn(definitions);
when(definitions.getImport()).thenReturn(Collections.emptyList());
final String actual = HrefBuilder.getHref(drgElement);
final String expected = "#" + uuid;
assertEquals(expected, actual);
}
use of org.kie.workbench.common.dmn.api.definition.model.Definitions in project kie-wb-common by kiegroup.
the class IncludedModelsPageStateProviderImplTest method testGetImportsWhenDiagramIsPresent.
@Test
public void testGetImportsWhenDiagramIsPresent() {
final Definitions definitions = mock(Definitions.class);
final List<Import> expectedImports = asList(mock(Import.class), mock(Import.class));
when(dmnGraphUtils.getDefinitions(diagram)).thenReturn(definitions);
when(definitions.getImport()).thenReturn(expectedImports);
final List<Import> actualImports = stateProvider.getImports();
assertEquals(expectedImports, actualImports);
}
use of org.kie.workbench.common.dmn.api.definition.model.Definitions in project kie-wb-common by kiegroup.
the class ItemDefinitionUtilsTest method testGetPrefixForNamespaceURIWhenPrefixForNamespaceURIIsPresent.
@Test
public void testGetPrefixForNamespaceURIWhenPrefixForNamespaceURIIsPresent() {
final String namespaceURI = FEEL.getUri();
final Definitions definitions = mock(Definitions.class);
final Optional<String> expectedPrefix = Optional.of("prefix");
when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
when(definitions.getPrefixForNamespaceURI(namespaceURI)).thenReturn(expectedPrefix);
final Optional<String> actualPrefix = utils.getPrefixForNamespaceURI(namespaceURI);
assertEquals(expectedPrefix, actualPrefix);
}
use of org.kie.workbench.common.dmn.api.definition.model.Definitions in project kie-wb-common by kiegroup.
the class ItemDefinitionUtilsTest method testAddItemDefinitions.
@Test
public void testAddItemDefinitions() {
final Definitions definitions = mock(Definitions.class);
final ItemDefinition itemDefinition1 = mock(ItemDefinition.class);
final ItemDefinition itemDefinition2 = mock(ItemDefinition.class);
final ItemDefinition itemDefinition3 = mock(ItemDefinition.class);
final ItemDefinition itemDefinition4 = mock(ItemDefinition.class);
final List<ItemDefinition> newItemDefinitions = asList(itemDefinition1, itemDefinition3);
final List<ItemDefinition> expectedItemDefinitions = asList(itemDefinition2, itemDefinition4, itemDefinition1, itemDefinition3);
final List<ItemDefinition> actualItemDefinitions = new ArrayList<>(asList(itemDefinition2, itemDefinition4));
when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
when(definitions.getItemDefinition()).thenReturn(actualItemDefinitions);
utils.addItemDefinitions(newItemDefinitions);
assertEquals(expectedItemDefinitions, actualItemDefinitions);
}
Aggregations