Search in sources :

Example 1 with DMNIncludeModelCouldNotBeCreatedException

use of org.kie.workbench.common.dmn.backend.editors.types.exceptions.DMNIncludeModelCouldNotBeCreatedException in project kie-wb-common by kiegroup.

the class DMNIncludedModelsServiceImplTest method testLoadModelsWhenWorkspaceProjectIsNotNull.

@Test
public void testLoadModelsWhenWorkspaceProjectIsNotNull() throws Exception {
    final WorkspaceProject workspaceProject = mock(WorkspaceProject.class);
    final Path rootPath = mock(Path.class);
    final String uri = "/src/path/file.dmn";
    final Path path1 = mock(Path.class);
    final Path path2 = mock(Path.class);
    final Path path3 = mock(Path.class);
    final IncludedModel includedModel1 = mock(IncludedModel.class);
    final IncludedModel includedModel2 = mock(IncludedModel.class);
    when(workspaceProject.getRootPath()).thenReturn(rootPath);
    when(rootPath.toURI()).thenReturn(uri);
    when(pathsHelper.getModelsPaths(workspaceProject)).thenReturn(asList(path1, path2, path3));
    when(includedModelFactory.create(dmnModelPath, path1)).thenReturn(includedModel1);
    when(includedModelFactory.create(dmnModelPath, path2)).thenReturn(includedModel2);
    when(includedModelFactory.create(dmnModelPath, path3)).thenThrow(new DMNIncludeModelCouldNotBeCreatedException());
    final List<IncludedModel> includedModels = service.loadModels(dmnModelPath, workspaceProject);
    assertEquals(2, includedModels.size());
    assertEquals(includedModel1, includedModels.get(0));
    assertEquals(includedModel2, includedModels.get(1));
}
Also used : Path(org.uberfire.backend.vfs.Path) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) PMMLIncludedModel(org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel) DMNIncludedModel(org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel) IncludedModel(org.kie.workbench.common.dmn.api.editors.included.IncludedModel) DMNIncludeModelCouldNotBeCreatedException(org.kie.workbench.common.dmn.backend.editors.types.exceptions.DMNIncludeModelCouldNotBeCreatedException) Test(org.junit.Test)

Example 2 with DMNIncludeModelCouldNotBeCreatedException

use of org.kie.workbench.common.dmn.backend.editors.types.exceptions.DMNIncludeModelCouldNotBeCreatedException in project kie-wb-common by kiegroup.

the class DMNIncludedModelsServiceImplTest method testLoadModelsWhenWorkspaceProjectIsNull.

@Test
public void testLoadModelsWhenWorkspaceProjectIsNull() throws Exception {
    final WorkspaceProject workspaceProject = null;
    final Path path1 = mock(Path.class);
    final Path path2 = mock(Path.class);
    final Path path3 = mock(Path.class);
    final IncludedModel includedModel1 = mock(IncludedModel.class);
    final IncludedModel includedModel2 = mock(IncludedModel.class);
    when(pathsHelper.getModelsPaths(workspaceProject)).thenReturn(asList(path1, path2, path3));
    when(includedModelFactory.create(dmnModelPath, path1)).thenReturn(includedModel1);
    when(includedModelFactory.create(dmnModelPath, path2)).thenReturn(includedModel2);
    when(includedModelFactory.create(dmnModelPath, path3)).thenThrow(new DMNIncludeModelCouldNotBeCreatedException());
    final List<IncludedModel> includedModels = service.loadModels(dmnModelPath, workspaceProject);
    assertEquals(2, includedModels.size());
    assertEquals(includedModel1, includedModels.get(0));
    assertEquals(includedModel2, includedModels.get(1));
}
Also used : Path(org.uberfire.backend.vfs.Path) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) PMMLIncludedModel(org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel) DMNIncludedModel(org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel) IncludedModel(org.kie.workbench.common.dmn.api.editors.included.IncludedModel) DMNIncludeModelCouldNotBeCreatedException(org.kie.workbench.common.dmn.backend.editors.types.exceptions.DMNIncludeModelCouldNotBeCreatedException) Test(org.junit.Test)

Aggregations

WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)2 Test (org.junit.Test)2 DMNIncludedModel (org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel)2 IncludedModel (org.kie.workbench.common.dmn.api.editors.included.IncludedModel)2 PMMLIncludedModel (org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel)2 DMNIncludeModelCouldNotBeCreatedException (org.kie.workbench.common.dmn.backend.editors.types.exceptions.DMNIncludeModelCouldNotBeCreatedException)2 Path (org.uberfire.backend.vfs.Path)2