@Test public void getPMMLDocumentsMetadataFromFiles() { final PMMLDocumentMetadata documentMetadata = new PMMLDocumentMetadata(PMML_FILE, PMML.getDefaultNamespace(), Collections.emptyList()); final List<PMMLIncludedModel> includedModels = Arrays.asList(new PMMLIncludedModel(PMML_MODEL_NAME, "", PMML_FILE, PMML.getDefaultNamespace(), 0)); when(dmnImportsContentService.getModelsPMMLFilesURIs()).thenReturn(promises.resolve(new String[]{PMML_PATH})); when(dmnImportsContentService.loadFile(PMML_PATH)).thenReturn(promises.resolve(PMML_CONTENT)); doReturn(promises.resolve(documentMetadata)).when(dmnImportsContentService).getPMMLDocumentMetadata(PMML_PATH); importsHelper.getPMMLDocumentsMetadataFromFiles(includedModels, pmmlMetadataServiceCallback); verify(pmmlMetadataServiceCallback, times(1)).onSuccess(pmmlDocumentMetadataArgumentCaptor.capture()); assertEquals(1, pmmlDocumentMetadataArgumentCaptor.getValue().size()); assertEquals(PMML_FILE, pmmlDocumentMetadataArgumentCaptor.getValue().get(0).getPath()); assertEquals(PMML_MODEL_NAME, pmmlDocumentMetadataArgumentCaptor.getValue().get(0).getName()); assertEquals(PMML.getDefaultNamespace(), pmmlDocumentMetadataArgumentCaptor.getValue().get(0).getImportType()); assertTrue(pmmlDocumentMetadataArgumentCaptor.getValue().get(0).getModels().isEmpty()); }
public void getPMMLDocumentsMetadataFromFiles(final List<PMMLIncludedModel> includedModels, final ServiceCallback<List<PMMLDocumentMetadata>> callback) { if (includedModels == null || includedModels.isEmpty()) { callback.onSuccess(Collections.emptyList()); return; } loadPMMLDefinitions().then(allDefinitions -> { final Map<String, String> filesToNameMap = includedModels.stream().collect(Collectors.toMap(PMMLIncludedModel::getPath, PMMLIncludedModel::getModelName)); final List<PMMLDocumentMetadata> pmmlDocumentMetadata = allDefinitions.entrySet().stream() .filter(entry -> filesToNameMap.keySet().contains(FileUtils.getFileName(entry.getKey()))) .map(entry -> new PMMLDocumentMetadata(entry.getValue().getPath(), filesToNameMap.get(FileUtils.getFileName(entry.getKey())), entry.getValue().getImportType(), entry.getValue().getModels())) .collect(Collectors.toList()); pmmlDocumentMetadata.sort(Comparator.comparing(PMMLDocumentMetadata::getName)); callback.onSuccess(pmmlDocumentMetadata); return promises.resolve(); }); }
DMNMarshallerImportsClientHelper implements DMNMarshallerImportsHelper<JSITImport, JSITDefinitions, JSITDRGElement, JSITItemDefinition> { public void getPMMLDocumentsMetadataFromFiles(final List<PMMLIncludedModel> includedModels, final ServiceCallback<List<PMMLDocumentMetadata>> callback) { if (includedModels == null || includedModels.isEmpty()) { callback.onSuccess(Collections.emptyList()); return; } loadPMMLDefinitions().then(allDefinitions -> { final Map<String, String> filesToNameMap = includedModels.stream().collect(Collectors.toMap(PMMLIncludedModel::getPath, PMMLIncludedModel::getModelName)); final List<PMMLDocumentMetadata> pmmlDocumentMetadata = allDefinitions.entrySet().stream() .filter(entry -> filesToNameMap.keySet().contains(FileUtils.getFileName(entry.getKey()))) .map(entry -> new PMMLDocumentMetadata(entry.getValue().getPath(), filesToNameMap.get(FileUtils.getFileName(entry.getKey())), entry.getValue().getImportType(), entry.getValue().getModels())) .collect(Collectors.toList()); pmmlDocumentMetadata.sort(Comparator.comparing(PMMLDocumentMetadata::getName)); callback.onSuccess(pmmlDocumentMetadata); return promises.resolve(); }); } }
DMNMarshallerImportsClientHelper implements DMNMarshallerImportsHelper<JSITImport, JSITDefinitions, JSITDRGElement, JSITItemDefinition> { public void getPMMLDocumentsMetadataFromFiles(final List<PMMLIncludedModel> includedModels, final ServiceCallback<List<PMMLDocumentMetadata>> callback) { if (includedModels == null || includedModels.isEmpty()) { callback.onSuccess(Collections.emptyList()); return; } loadPMMLDefinitions().then(allDefinitions -> { final Map<String, String> filesToNameMap = includedModels.stream().collect(Collectors.toMap(PMMLIncludedModel::getPath, PMMLIncludedModel::getModelName)); final List<PMMLDocumentMetadata> pmmlDocumentMetadata = allDefinitions.entrySet().stream() .filter(entry -> filesToNameMap.keySet().contains(FileUtils.getFileName(entry.getKey()))) .map(entry -> new PMMLDocumentMetadata(entry.getValue().getPath(), filesToNameMap.get(FileUtils.getFileName(entry.getKey())), entry.getValue().getImportType(), entry.getValue().getModels())) .collect(Collectors.toList()); pmmlDocumentMetadata.sort(Comparator.comparing(PMMLDocumentMetadata::getName)); callback.onSuccess(pmmlDocumentMetadata); return promises.resolve(); }); } @Inject  DMNMarshallerImportsClientHelper(final DMNMarshallerImportsService dmnImportsService,
                                            final DMNMarshallerImportsContentService dmnImportsContentService,
                                            final Promises promises,
                                            final DMNIncludedNodeFactory includedModelFactory); }
DMNMarshallerImportsClientHelper implements DMNMarshallerImportsHelper<JSITImport, JSITDefinitions, JSITDRGElement, JSITItemDefinition> { public void getPMMLDocumentsMetadataFromFiles(final List<PMMLIncludedModel> includedModels, final ServiceCallback<List<PMMLDocumentMetadata>> callback) { if (includedModels == null || includedModels.isEmpty()) { callback.onSuccess(Collections.emptyList()); return; } loadPMMLDefinitions().then(allDefinitions -> { final Map<String, String> filesToNameMap = includedModels.stream().collect(Collectors.toMap(PMMLIncludedModel::getPath, PMMLIncludedModel::getModelName)); final List<PMMLDocumentMetadata> pmmlDocumentMetadata = allDefinitions.entrySet().stream() .filter(entry -> filesToNameMap.keySet().contains(FileUtils.getFileName(entry.getKey()))) .map(entry -> new PMMLDocumentMetadata(entry.getValue().getPath(), filesToNameMap.get(FileUtils.getFileName(entry.getKey())), entry.getValue().getImportType(), entry.getValue().getModels())) .collect(Collectors.toList()); pmmlDocumentMetadata.sort(Comparator.comparing(PMMLDocumentMetadata::getName)); callback.onSuccess(pmmlDocumentMetadata); return promises.resolve(); }); } @Inject  DMNMarshallerImportsClientHelper(final DMNMarshallerImportsService dmnImportsService,
                                            final DMNMarshallerImportsContentService dmnImportsContentService,
                                            final Promises promises,
                                            final DMNIncludedNodeFactory includedModelFactory); Promise<Map<JSITImport, JSITDefinitions>> getImportDefinitionsAsync(final Metadata metadata,
                                                                               final List<JSITImport> imports); void loadNodesFromModels(final List<DMNIncludedModel> includedModels,
                                    final ServiceCallback<List<DMNIncludedNode>> callback); void loadModels(final ServiceCallback<List<IncludedModel>> callback); Promise<Map<JSITImport, PMMLDocumentMetadata>> getPMMLDocumentsAsync(final Metadata metadata,
                                                                                final List<JSITImport> imports); @Override Map<JSITImport, String> getImportXML(final Metadata metadata,
                                                final List<JSITImport> imports); @Override List<JSITDRGElement> getImportedDRGElements(final Map<JSITImport, JSITDefinitions> importDefinitions); @Override List<JSITItemDefinition> getImportedItemDefinitions(final Map<JSITImport, JSITDefinitions> importDefinitions); void getPMMLDocumentsMetadataFromFiles(final List<PMMLIncludedModel> includedModels,
                                                  final ServiceCallback<List<PMMLDocumentMetadata>> callback); void getImportedItemDefinitionsByNamespaceAsync(final String modelName,
                                                           final String namespace,
                                                           final ServiceCallback<List<ItemDefinition>> callback); }
DMNMarshallerImportsClientHelper implements DMNMarshallerImportsHelper<JSITImport, JSITDefinitions, JSITDRGElement, JSITItemDefinition> { public void getPMMLDocumentsMetadataFromFiles(final List<PMMLIncludedModel> includedModels, final ServiceCallback<List<PMMLDocumentMetadata>> callback) { if (includedModels == null || includedModels.isEmpty()) { callback.onSuccess(Collections.emptyList()); return; } loadPMMLDefinitions().then(allDefinitions -> { final Map<String, String> filesToNameMap = includedModels.stream().collect(Collectors.toMap(PMMLIncludedModel::getPath, PMMLIncludedModel::getModelName)); final List<PMMLDocumentMetadata> pmmlDocumentMetadata = allDefinitions.entrySet().stream() .filter(entry -> filesToNameMap.keySet().contains(FileUtils.getFileName(entry.getKey()))) .map(entry -> new PMMLDocumentMetadata(entry.getValue().getPath(), filesToNameMap.get(FileUtils.getFileName(entry.getKey())), entry.getValue().getImportType(), entry.getValue().getModels())) .collect(Collectors.toList()); pmmlDocumentMetadata.sort(Comparator.comparing(PMMLDocumentMetadata::getName)); callback.onSuccess(pmmlDocumentMetadata); return promises.resolve(); }); } @Inject  DMNMarshallerImportsClientHelper(final DMNMarshallerImportsService dmnImportsService,
                                            final DMNMarshallerImportsContentService dmnImportsContentService,
                                            final Promises promises,
                                            final DMNIncludedNodeFactory includedModelFactory); Promise<Map<JSITImport, JSITDefinitions>> getImportDefinitionsAsync(final Metadata metadata,
                                                                               final List<JSITImport> imports); void loadNodesFromModels(final List<DMNIncludedModel> includedModels,
                                    final ServiceCallback<List<DMNIncludedNode>> callback); void loadModels(final ServiceCallback<List<IncludedModel>> callback); Promise<Map<JSITImport, PMMLDocumentMetadata>> getPMMLDocumentsAsync(final Metadata metadata,
                                                                                final List<JSITImport> imports); @Override Map<JSITImport, String> getImportXML(final Metadata metadata,
                                                final List<JSITImport> imports); @Override List<JSITDRGElement> getImportedDRGElements(final Map<JSITImport, JSITDefinitions> importDefinitions); @Override List<JSITItemDefinition> getImportedItemDefinitions(final Map<JSITImport, JSITDefinitions> importDefinitions); void getPMMLDocumentsMetadataFromFiles(final List<PMMLIncludedModel> includedModels,
                                                  final ServiceCallback<List<PMMLDocumentMetadata>> callback); void getImportedItemDefinitionsByNamespaceAsync(final String modelName,
                                                           final String namespace,
                                                           final ServiceCallback<List<ItemDefinition>> callback);  }