@Test public void getPMMLDocumentsAsyncWhenAnyFileCouldBeRead() { when(dmnImportsContentService.getModelsPMMLFilesURIs()).thenReturn(promises.resolve(new String[0])); final Promise<Map<JSITImport, PMMLDocumentMetadata>> returnPromise = importsHelper.getPMMLDocumentsAsync(metadataMock, singletonList(mock(JSITImport.class))); returnPromise.then(p0 -> { assertEquals(0, p0.size()); return promises.resolve(); }).catch_(i -> { fail("Promise should've been resolved!"); return promises.resolve(); }); }
public Promise<Map<JSITImport, PMMLDocumentMetadata>> getPMMLDocumentsAsync(final Metadata metadata, final List<JSITImport> imports) { if (!imports.isEmpty()) { return loadPMMLDefinitions().then(otherDefinitions -> { final Map<JSITImport, PMMLDocumentMetadata> importDefinitions = new HashMap<>(); for (final Map.Entry<String, PMMLDocumentMetadata> entry : otherDefinitions.entrySet()) { final PMMLDocumentMetadata def = entry.getValue(); findImportByPMMLDocument(FileUtils.getFileName(def.getPath()), imports).ifPresent(anImport -> { final JSITImport foundImported = Js.uncheckedCast(anImport); importDefinitions.put(foundImported, def); }); } return promises.resolve(importDefinitions); }); } return promises.resolve(Collections.emptyMap()); }
DMNMarshallerImportsClientHelper implements DMNMarshallerImportsHelper<JSITImport, JSITDefinitions, JSITDRGElement, JSITItemDefinition> { public Promise<Map<JSITImport, PMMLDocumentMetadata>> getPMMLDocumentsAsync(final Metadata metadata, final List<JSITImport> imports) { if (!imports.isEmpty()) { return loadPMMLDefinitions().then(otherDefinitions -> { final Map<JSITImport, PMMLDocumentMetadata> importDefinitions = new HashMap<>(); for (final Map.Entry<String, PMMLDocumentMetadata> entry : otherDefinitions.entrySet()) { final PMMLDocumentMetadata def = entry.getValue(); findImportByPMMLDocument(FileUtils.getFileName(def.getPath()), imports).ifPresent(anImport -> { final JSITImport foundImported = Js.uncheckedCast(anImport); importDefinitions.put(foundImported, def); }); } return promises.resolve(importDefinitions); }); } return promises.resolve(Collections.emptyMap()); } }
DMNMarshallerImportsClientHelper implements DMNMarshallerImportsHelper<JSITImport, JSITDefinitions, JSITDRGElement, JSITItemDefinition> { public Promise<Map<JSITImport, PMMLDocumentMetadata>> getPMMLDocumentsAsync(final Metadata metadata, final List<JSITImport> imports) { if (!imports.isEmpty()) { return loadPMMLDefinitions().then(otherDefinitions -> { final Map<JSITImport, PMMLDocumentMetadata> importDefinitions = new HashMap<>(); for (final Map.Entry<String, PMMLDocumentMetadata> entry : otherDefinitions.entrySet()) { final PMMLDocumentMetadata def = entry.getValue(); findImportByPMMLDocument(FileUtils.getFileName(def.getPath()), imports).ifPresent(anImport -> { final JSITImport foundImported = Js.uncheckedCast(anImport); importDefinitions.put(foundImported, def); }); } return promises.resolve(importDefinitions); }); } return promises.resolve(Collections.emptyMap()); } @Inject  DMNMarshallerImportsClientHelper(final DMNMarshallerImportsService dmnImportsService,
                                            final DMNMarshallerImportsContentService dmnImportsContentService,
                                            final Promises promises,
                                            final DMNIncludedNodeFactory includedModelFactory); }
DMNMarshallerImportsClientHelper implements DMNMarshallerImportsHelper<JSITImport, JSITDefinitions, JSITDRGElement, JSITItemDefinition> { public Promise<Map<JSITImport, PMMLDocumentMetadata>> getPMMLDocumentsAsync(final Metadata metadata, final List<JSITImport> imports) { if (!imports.isEmpty()) { return loadPMMLDefinitions().then(otherDefinitions -> { final Map<JSITImport, PMMLDocumentMetadata> importDefinitions = new HashMap<>(); for (final Map.Entry<String, PMMLDocumentMetadata> entry : otherDefinitions.entrySet()) { final PMMLDocumentMetadata def = entry.getValue(); findImportByPMMLDocument(FileUtils.getFileName(def.getPath()), imports).ifPresent(anImport -> { final JSITImport foundImported = Js.uncheckedCast(anImport); importDefinitions.put(foundImported, def); }); } return promises.resolve(importDefinitions); }); } return promises.resolve(Collections.emptyMap()); } @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 Promise<Map<JSITImport, PMMLDocumentMetadata>> getPMMLDocumentsAsync(final Metadata metadata, final List<JSITImport> imports) { if (!imports.isEmpty()) { return loadPMMLDefinitions().then(otherDefinitions -> { final Map<JSITImport, PMMLDocumentMetadata> importDefinitions = new HashMap<>(); for (final Map.Entry<String, PMMLDocumentMetadata> entry : otherDefinitions.entrySet()) { final PMMLDocumentMetadata def = entry.getValue(); findImportByPMMLDocument(FileUtils.getFileName(def.getPath()), imports).ifPresent(anImport -> { final JSITImport foundImported = Js.uncheckedCast(anImport); importDefinitions.put(foundImported, def); }); } return promises.resolve(importDefinitions); }); } return promises.resolve(Collections.emptyMap()); } @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);  }