use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.
the class DMNMarshallerTest method testWithIncludedModelsWhenNodeParentIsDefinitions.
@Test
public void testWithIncludedModelsWhenNodeParentIsDefinitions() {
final DMNMarshaller dmnMarshaller = spy(new DMNMarshaller());
final Node node = mock(Node.class);
final Definition nodeDefinition = mock(Definition.class);
final DRGElement drgElement = mock(DRGElement.class);
final Definitions definitionsStunnerPojo = mock(Definitions.class);
final Import import1 = mock(Import.class);
final Import import2 = mock(Import.class);
final List<Import> diagramImports = new ArrayList<>(asList(import1, import2));
final Definitions nodeDiagramDefinitions = mock(Definitions.class);
final List<Import> nodeDiagramImports = new ArrayList<>();
when(node.getContent()).thenReturn(nodeDefinition);
when(nodeDefinition.getDefinition()).thenReturn(drgElement);
when(definitionsStunnerPojo.getImport()).thenReturn(diagramImports);
when(drgElement.getParent()).thenReturn(nodeDiagramDefinitions);
when(nodeDiagramDefinitions.getImport()).thenReturn(nodeDiagramImports);
dmnMarshaller.withIncludedModels(node, definitionsStunnerPojo);
assertEquals(2, nodeDiagramImports.size());
assertTrue(nodeDiagramImports.contains(import1));
assertTrue(nodeDiagramImports.contains(import2));
}
use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.
the class DMNElementsSynchronizerTest method testSynchronizeBaseDRGProperties.
@Test
public void testSynchronizeBaseDRGProperties() {
final DRGElement from = mock(DRGElement.class);
final DRGElement to = mock(DRGElement.class);
final Description description = mock(Description.class);
final DocumentationLinksHolder linksHolder = mock(DocumentationLinksHolder.class);
final Name name = mock(Name.class);
when(from.getDescription()).thenReturn(description);
when(from.getLinksHolder()).thenReturn(linksHolder);
when(from.getName()).thenReturn(name);
synchronizer.synchronizeBaseDRGProperties(from, to);
verify(to).setDescription(description);
verify(to).setName(name);
verify(to).setLinksHolder(linksHolder);
}
use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.
the class DMNElementsSynchronizerTest method testGetElementsWithContentId.
@Test
public void testGetElementsWithContentId() {
final Node node1 = mock(Node.class);
final Node node2 = mock(Node.class);
final Node node3 = mock(Node.class);
final DRGElement contentDefinition1 = mock(DRGElement.class);
final DRGElement contentDefinition3 = mock(DRGElement.class);
final String theId = "the id";
final String anotherId = "another id";
final List<Node> nodes = Arrays.asList(node1, node2, node3);
when(dmnDiagramsSession.getAllNodes()).thenReturn(nodes);
when(contentDefinition1.getContentDefinitionId()).thenReturn(theId);
when(contentDefinition3.getContentDefinitionId()).thenReturn(anotherId);
doReturn(contentDefinition1).when(synchronizer).getDRGElementFromContentDefinition(node1);
doReturn(contentDefinition3).when(synchronizer).getDRGElementFromContentDefinition(node3);
doReturn(true).when(synchronizer).definitionContainsDRGElement(node1);
doReturn(false).when(synchronizer).definitionContainsDRGElement(node2);
doReturn(true).when(synchronizer).definitionContainsDRGElement(node3);
final List<Node> elements = synchronizer.getElementsWithContentId(theId);
verify(synchronizer).definitionContainsDRGElement(node1);
verify(synchronizer).definitionContainsDRGElement(node2);
verify(synchronizer).definitionContainsDRGElement(node3);
verify(synchronizer).getDRGElementFromContentDefinition(node1);
verify(synchronizer, never()).getDRGElementFromContentDefinition(node2);
verify(synchronizer).getDRGElementFromContentDefinition(node3);
assertEquals(1, elements.size());
assertTrue(elements.contains(node1));
}
use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.
the class DMNElementsSynchronizerTest method testSynchronizeElementsFrom.
@Test
public void testSynchronizeElementsFrom() {
final Node node1 = mock(Node.class);
final Node node2 = mock(Node.class);
final Node node3 = mock(Node.class);
final List<Node> nodes = Arrays.asList(node1, node2, node3);
final DRGElement drgElement = mock(DRGElement.class);
final String contentDefinitionId = "id";
final DRGElement drgElement1 = mock(DRGElement.class);
final DRGElement drgElement2 = mock(DRGElement.class);
final DRGElement drgElement3 = mock(DRGElement.class);
when(drgElement.getContentDefinitionId()).thenReturn(contentDefinitionId);
doNothing().when(synchronizer).updateText(any(DRGElement.class), any(Node.class));
doReturn(nodes).when(synchronizer).getElementsWithContentId(contentDefinitionId);
doReturn(drgElement1).when(synchronizer).getDRGElementFromContentDefinition(node1);
doReturn(drgElement2).when(synchronizer).getDRGElementFromContentDefinition(node2);
doReturn(drgElement3).when(synchronizer).getDRGElementFromContentDefinition(node3);
doNothing().when(synchronizer).synchronizeBaseDRGProperties(any(DRGElement.class), any(DRGElement.class));
doNothing().when(synchronizer).synchronizeSpecializedProperties(any(DRGElement.class), any(DRGElement.class));
synchronizer.synchronizeElementsFrom(drgElement);
verify(synchronizer).getElementsWithContentId(contentDefinitionId);
verify(synchronizer).updateText(drgElement, node1);
verify(synchronizer).updateText(drgElement, node2);
verify(synchronizer).updateText(drgElement, node3);
verify(synchronizer).synchronizeBaseDRGProperties(drgElement, drgElement1);
verify(synchronizer).synchronizeBaseDRGProperties(drgElement, drgElement2);
verify(synchronizer).synchronizeBaseDRGProperties(drgElement, drgElement3);
verify(synchronizer).synchronizeSpecializedProperties(drgElement, drgElement1);
verify(synchronizer).synchronizeSpecializedProperties(drgElement, drgElement2);
verify(synchronizer).synchronizeSpecializedProperties(drgElement, drgElement3);
verify(refreshDecisionComponentsEvent).fire(any(RefreshDecisionComponents.class));
}
use of org.kie.workbench.common.dmn.api.definition.model.DRGElement 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