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