Search in sources :

Example 6 with DMNIncludedModel

use of org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel in project kie-wb-common by kiegroup.

the class DMNIncludedNodesFilterTest method testGetNodesFromImportsWhenPathDoesNotRepresentsAnImportedDiagram.

@Test
public void testGetNodesFromImportsWhenPathDoesNotRepresentsAnImportedDiagram() {
    final Path path = mock(Path.class);
    final DMNIncludedModel includedModel1 = mock(DMNIncludedModel.class);
    final DMNIncludedModel includedModel2 = mock(DMNIncludedModel.class);
    final DMNIncludedModel includedModel3 = mock(DMNIncludedModel.class);
    final List<DMNIncludedModel> imports = asList(includedModel1, includedModel2, includedModel3);
    when(includedModel1.getNamespace()).thenReturn("://namespace1");
    when(includedModel2.getNamespace()).thenReturn("://namespace2");
    when(includedModel3.getNamespace()).thenReturn("://namespace3");
    when(diagramHelper.getDiagramByPath(path)).thenReturn(diagram);
    when(diagramHelper.getNamespace(diagram)).thenReturn("://namespace4");
    final List<DMNIncludedNode> actualNodes = filter.getNodesFromImports(path, imports);
    final List<DMNIncludedNode> expectedNodes = emptyList();
    assertEquals(expectedNodes, actualNodes);
}
Also used : Path(org.uberfire.backend.vfs.Path) DMNIncludedNode(org.kie.workbench.common.dmn.api.editors.included.DMNIncludedNode) DMNIncludedModel(org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel) Test(org.junit.Test)

Example 7 with DMNIncludedModel

use of org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel in project kie-wb-common by kiegroup.

the class DMNIncludedModelsServiceImplTest method testLoadNodesFromImports.

@Test
public void testLoadNodesFromImports() {
    final WorkspaceProject workspaceProject = mock(WorkspaceProject.class);
    final DMNIncludedModel includedModel1 = mock(DMNIncludedModel.class);
    final DMNIncludedModel includedModel2 = mock(DMNIncludedModel.class);
    final DMNIncludedModel includedModel3 = mock(DMNIncludedModel.class);
    final Path path1 = mock(Path.class);
    final Path path2 = mock(Path.class);
    final Path path3 = mock(Path.class);
    final DMNIncludedNode node1 = mock(DMNIncludedNode.class);
    final DMNIncludedNode node2 = mock(DMNIncludedNode.class);
    final DMNIncludedNode node3 = mock(DMNIncludedNode.class);
    final DMNIncludedNode node4 = mock(DMNIncludedNode.class);
    final DMNIncludedNode node5 = mock(DMNIncludedNode.class);
    final DMNIncludedNode node6 = mock(DMNIncludedNode.class);
    final DMNIncludedNode node7 = mock(DMNIncludedNode.class);
    final List<DMNIncludedNode> path1Nodes = asList(node1, node2, node3, node4);
    final List<DMNIncludedNode> path2Nodes = singletonList(node5);
    final List<DMNIncludedNode> path3Nodes = asList(node6, node7);
    final List<DMNIncludedModel> includedModels = asList(includedModel1, includedModel2, includedModel3);
    final List<Path> paths = asList(path1, path2, path3);
    when(pathsHelper.getDMNModelsPaths(workspaceProject)).thenReturn(paths);
    when(includedNodesFilter.getNodesFromImports(path1, includedModels)).thenReturn(path1Nodes);
    when(includedNodesFilter.getNodesFromImports(path2, includedModels)).thenReturn(path2Nodes);
    when(includedNodesFilter.getNodesFromImports(path3, includedModels)).thenReturn(path3Nodes);
    final List<DMNIncludedNode> actualNodes = service.loadNodesFromImports(workspaceProject, includedModels);
    final List<DMNIncludedNode> expectedNodes = asList(node1, node2, node3, node4, node5, node6, node7);
    assertEquals(expectedNodes, actualNodes);
}
Also used : Path(org.uberfire.backend.vfs.Path) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) DMNIncludedNode(org.kie.workbench.common.dmn.api.editors.included.DMNIncludedNode) DMNIncludedModel(org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel) Test(org.junit.Test)

Example 8 with DMNIncludedModel

use of org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel in project kie-wb-common by kiegroup.

the class DecisionComponentsTest method testAsDMNIncludedModel.

@Test
public void testAsDMNIncludedModel() {
    final String modelName = "Model Name";
    final String namespace = "The Namespace";
    final String type = "The type";
    final String file = "my file.dmn";
    final String filePath = "//users//some//" + file;
    final Import anImport = new Import();
    anImport.setName(new Name(modelName));
    anImport.setNamespace(namespace);
    anImport.setImportType(type);
    anImport.setLocationURI(new LocationURI(filePath));
    final DMNIncludedModel includedModel = decisionComponents.asDMNIncludedModel(anImport);
    assertEquals(modelName, includedModel.getModelName());
    assertEquals(namespace, includedModel.getNamespace());
    assertEquals(type, includedModel.getImportType());
    assertEquals(file, includedModel.getPath());
}
Also used : LocationURI(org.kie.workbench.common.dmn.api.property.dmn.LocationURI) Import(org.kie.workbench.common.dmn.api.definition.model.Import) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) DMNIncludedModel(org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel) Test(org.junit.Test)

Example 9 with DMNIncludedModel

use of org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel in project kie-wb-common by kiegroup.

the class DecisionComponentsTest method testGetDMNIncludedModelsOnlyIncludesDMN.

@Test
public void testGetDMNIncludedModelsOnlyIncludesDMN() {
    final ImportDMN dmnImport = new ImportDMN();
    final ImportPMML pmmlImport = new ImportPMML();
    dmnImport.getName().setValue("dmn");
    dmnImport.setImportType(DMNImportTypes.DMN.getDefaultNamespace());
    pmmlImport.setImportType(DMNImportTypes.PMML.getDefaultNamespace());
    when(dmnDiagramsSession.getModelImports()).thenReturn(asList(dmnImport, pmmlImport));
    final List<DMNIncludedModel> includedModels = decisionComponents.getDMNIncludedModels();
    assertThat(includedModels).hasSize(1);
    assertThat(includedModels.get(0).getModelName()).isEqualTo("dmn");
    assertThat(includedModels.get(0).getImportType()).isEqualTo(DMNImportTypes.DMN.getDefaultNamespace());
}
Also used : ImportDMN(org.kie.workbench.common.dmn.api.definition.model.ImportDMN) ImportPMML(org.kie.workbench.common.dmn.api.definition.model.ImportPMML) DMNIncludedModel(org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel) Test(org.junit.Test)

Example 10 with DMNIncludedModel

use of org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel in project kie-wb-common by kiegroup.

the class DMNAssetsDropdownItemsProviderTest method testAsKieAssetForDMNIncludedModel.

@Test
public void testAsKieAssetForDMNIncludedModel() {
    final DMNIncludedModel model = makeDMNIncludedModel(1, 2, 3);
    final KieAssetsDropdownItem dropdownItem = itemsProvider.asKieAsset(model);
    assertEquals(model.getModelName(), dropdownItem.getText());
    assertEquals(model.getModelPackage(), dropdownItem.getSubText());
    assertEquals(model.getNamespace(), dropdownItem.getValue());
    assertEquals(model.getPath(), dropdownItem.getMetaData().get(PATH_METADATA));
    assertEquals(model.getImportType(), dropdownItem.getMetaData().get(IMPORT_TYPE_METADATA));
    assertEquals(model.getDrgElementsCount().toString(), dropdownItem.getMetaData().get(DRG_ELEMENT_COUNT_METADATA));
    assertEquals(model.getItemDefinitionsCount().toString(), dropdownItem.getMetaData().get(ITEM_DEFINITION_COUNT_METADATA));
}
Also used : KieAssetsDropdownItem(org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem) DMNIncludedModel(org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel) Test(org.junit.Test)

Aggregations

DMNIncludedModel (org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel)11 Test (org.junit.Test)9 DMNIncludedNode (org.kie.workbench.common.dmn.api.editors.included.DMNIncludedNode)5 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)3 IncludedModel (org.kie.workbench.common.dmn.api.editors.included.IncludedModel)3 PMMLIncludedModel (org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel)3 Path (org.uberfire.backend.vfs.Path)3 Promise (elemental2.promise.Promise)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 Comparator (java.util.Comparator)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Objects (java.util.Objects)2 Optional (java.util.Optional)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Level (java.util.logging.Level)2 Logger (java.util.logging.Logger)2