@Test public void testCreatePMML() throws Exception { final PMMLDocumentMetadata pmmlDocument = mock(PMMLDocumentMetadata.class); final Package aPackage = mock(Package.class); final String packageName = "com.kie.pmml"; final String fileName = "file.pmml"; final String uri = "/src/main/java/com/kie/pmml/file.pmml"; final Integer expectedModelsCount = 2; when(aPackage.getPackageName()).thenReturn(packageName); when(includedModelPath.getFileName()).thenReturn(fileName); when(includedModelPath.toURI()).thenReturn(uri); when(moduleService.resolvePackage(includedModelPath)).thenReturn(aPackage); when(importTypesHelper.isDMN(includedModelPath)).thenReturn(false); when(importTypesHelper.isPMML(includedModelPath)).thenReturn(true); when(pathsHelper.getRelativeURI(dmnModelPath, includedModelPath)).thenReturn(uri); when(pmmlDocumentFactory.getDocumentByPath(includedModelPath)).thenReturn(pmmlDocument); when(pmmlDocument.getModels()).thenReturn(asList(mock(PMMLModelMetadata.class), mock(PMMLModelMetadata.class))); final IncludedModel includedModel = factory.create(dmnModelPath, includedModelPath); assertTrue(includedModel instanceof PMMLIncludedModel); final PMMLIncludedModel pmmlIncludedModel = (PMMLIncludedModel) includedModel; assertEquals(packageName, includedModel.getModelPackage()); assertEquals(fileName, includedModel.getModelName()); assertEquals(uri, includedModel.getPath()); assertEquals(expectedModelsCount, pmmlIncludedModel.getModelCount()); }
public IncludedModel create(final Path dmnModelPath, final Path includedModelPath) throws DMNIncludeModelCouldNotBeCreatedException { try { if (importTypesHelper.isDMN(includedModelPath)) { return makeDMNIncludedModel(dmnModelPath, includedModelPath); } else if (importTypesHelper.isPMML(includedModelPath)) { return makePMMLIncludedModel(dmnModelPath, includedModelPath); } else { throw new IllegalArgumentException("Unsupported external model type."); } } catch (final Exception e) { throw new DMNIncludeModelCouldNotBeCreatedException(); } }
IncludedModelFactory { public IncludedModel create(final Path dmnModelPath, final Path includedModelPath) throws DMNIncludeModelCouldNotBeCreatedException { try { if (importTypesHelper.isDMN(includedModelPath)) { return makeDMNIncludedModel(dmnModelPath, includedModelPath); } else if (importTypesHelper.isPMML(includedModelPath)) { return makePMMLIncludedModel(dmnModelPath, includedModelPath); } else { throw new IllegalArgumentException("Unsupported external model type."); } } catch (final Exception e) { throw new DMNIncludeModelCouldNotBeCreatedException(); } } }
IncludedModelFactory { public IncludedModel create(final Path dmnModelPath, final Path includedModelPath) throws DMNIncludeModelCouldNotBeCreatedException { try { if (importTypesHelper.isDMN(includedModelPath)) { return makeDMNIncludedModel(dmnModelPath, includedModelPath); } else if (importTypesHelper.isPMML(includedModelPath)) { return makePMMLIncludedModel(dmnModelPath, includedModelPath); } else { throw new IllegalArgumentException("Unsupported external model type."); } } catch (final Exception e) { throw new DMNIncludeModelCouldNotBeCreatedException(); } } @Inject  IncludedModelFactory(final DMNDiagramHelper diagramHelper,
                                final DMNPathsHelper pathsHelper,
                                final DMNImportTypesHelper importTypesHelper,
                                final PMMLIncludedDocumentFactory pmmlDocumentFactory,
                                final KieModuleService moduleService); }
IncludedModelFactory { public IncludedModel create(final Path dmnModelPath, final Path includedModelPath) throws DMNIncludeModelCouldNotBeCreatedException { try { if (importTypesHelper.isDMN(includedModelPath)) { return makeDMNIncludedModel(dmnModelPath, includedModelPath); } else if (importTypesHelper.isPMML(includedModelPath)) { return makePMMLIncludedModel(dmnModelPath, includedModelPath); } else { throw new IllegalArgumentException("Unsupported external model type."); } } catch (final Exception e) { throw new DMNIncludeModelCouldNotBeCreatedException(); } } @Inject  IncludedModelFactory(final DMNDiagramHelper diagramHelper,
                                final DMNPathsHelper pathsHelper,
                                final DMNImportTypesHelper importTypesHelper,
                                final PMMLIncludedDocumentFactory pmmlDocumentFactory,
                                final KieModuleService moduleService); IncludedModel create(final Path dmnModelPath,
                                final Path includedModelPath); }
IncludedModelFactory { public IncludedModel create(final Path dmnModelPath, final Path includedModelPath) throws DMNIncludeModelCouldNotBeCreatedException { try { if (importTypesHelper.isDMN(includedModelPath)) { return makeDMNIncludedModel(dmnModelPath, includedModelPath); } else if (importTypesHelper.isPMML(includedModelPath)) { return makePMMLIncludedModel(dmnModelPath, includedModelPath); } else { throw new IllegalArgumentException("Unsupported external model type."); } } catch (final Exception e) { throw new DMNIncludeModelCouldNotBeCreatedException(); } } @Inject  IncludedModelFactory(final DMNDiagramHelper diagramHelper,
                                final DMNPathsHelper pathsHelper,
                                final DMNImportTypesHelper importTypesHelper,
                                final PMMLIncludedDocumentFactory pmmlDocumentFactory,
                                final KieModuleService moduleService); IncludedModel create(final Path dmnModelPath,
                                final Path includedModelPath);  }