@Test public void testGetModelPathWhenDMNModelCouldNotBeFound() { final Metadata metadata = mock(Metadata.class); final String modelNamespace = "0000-1111-2222-3333"; final String modelName = "model name"; assertThatThrownBy(() -> helper.getDMNModelPath(metadata, modelNamespace, modelName)) .isInstanceOf(IllegalStateException.class) .hasMessageContaining("A path for the DMN model with namespace [0000-1111-2222-3333] could not be found."); }
@Override public Path getDMNModelPath(final Metadata metadata, final String modelNamespace, final String modelName) { final WorkspaceProject workspaceProject = getProject(metadata); for (final Path dmnModelPath : pathsHelper.getDMNModelsPaths(workspaceProject)) { final Optional<Definitions> definitions = getDefinitionsByPath(dmnModelPath); if (definitions.map(d -> Objects.equals(d.getNamespace(), modelNamespace) && Objects.equals(d.getName(), modelName)).orElse(false)) { return dmnModelPath; } } throw new IllegalStateException("A path for the DMN model with namespace [" + modelNamespace + "] could not be found."); }
DMNMarshallerImportsHelperStandaloneImpl implements DMNMarshallerImportsHelperStandalone { @Override public Path getDMNModelPath(final Metadata metadata, final String modelNamespace, final String modelName) { final WorkspaceProject workspaceProject = getProject(metadata); for (final Path dmnModelPath : pathsHelper.getDMNModelsPaths(workspaceProject)) { final Optional<Definitions> definitions = getDefinitionsByPath(dmnModelPath); if (definitions.map(d -> Objects.equals(d.getNamespace(), modelNamespace) && Objects.equals(d.getName(), modelName)).orElse(false)) { return dmnModelPath; } } throw new IllegalStateException("A path for the DMN model with namespace [" + modelNamespace + "] could not be found."); } }
DMNMarshallerImportsHelperStandaloneImpl implements DMNMarshallerImportsHelperStandalone { @Override public Path getDMNModelPath(final Metadata metadata, final String modelNamespace, final String modelName) { final WorkspaceProject workspaceProject = getProject(metadata); for (final Path dmnModelPath : pathsHelper.getDMNModelsPaths(workspaceProject)) { final Optional<Definitions> definitions = getDefinitionsByPath(dmnModelPath); if (definitions.map(d -> Objects.equals(d.getNamespace(), modelNamespace) && Objects.equals(d.getName(), modelName)).orElse(false)) { return dmnModelPath; } } throw new IllegalStateException("A path for the DMN model with namespace [" + modelNamespace + "] could not be found."); } DMNMarshallerImportsHelperStandaloneImpl(); @Inject  DMNMarshallerImportsHelperStandaloneImpl(final DMNPathsHelper pathsHelper,
                                                    final WorkspaceProjectService projectService,
                                                    final DMNMarshaller marshaller,
                                                    final DMNIOHelper dmnIOHelper,
                                                    final PMMLIncludedDocumentFactory pmmlDocumentFactory,
                                                    final @Named("ioStrategy") IOService ioService); }
DMNMarshallerImportsHelperStandaloneImpl implements DMNMarshallerImportsHelperStandalone { @Override public Path getDMNModelPath(final Metadata metadata, final String modelNamespace, final String modelName) { final WorkspaceProject workspaceProject = getProject(metadata); for (final Path dmnModelPath : pathsHelper.getDMNModelsPaths(workspaceProject)) { final Optional<Definitions> definitions = getDefinitionsByPath(dmnModelPath); if (definitions.map(d -> Objects.equals(d.getNamespace(), modelNamespace) && Objects.equals(d.getName(), modelName)).orElse(false)) { return dmnModelPath; } } throw new IllegalStateException("A path for the DMN model with namespace [" + modelNamespace + "] could not be found."); } DMNMarshallerImportsHelperStandaloneImpl(); @Inject  DMNMarshallerImportsHelperStandaloneImpl(final DMNPathsHelper pathsHelper,
                                                    final WorkspaceProjectService projectService,
                                                    final DMNMarshaller marshaller,
                                                    final DMNIOHelper dmnIOHelper,
                                                    final PMMLIncludedDocumentFactory pmmlDocumentFactory,
                                                    final @Named("ioStrategy") IOService ioService); @Override Map<Import, Definitions> getImportDefinitions(final Metadata metadata,
                                                         final List<Import> imports); @Override Map<Import, PMMLDocumentMetadata> getPMMLDocuments(final Metadata metadata,
                                                              final List<Import> imports); @Override Map<Import, String> getImportXML(final Metadata metadata,
                                            final List<Import> imports); @Override Path getDMNModelPath(final Metadata metadata,
                                final String modelNamespace,
                                final String modelName); @Override List<DRGElement> getImportedDRGElements(final Map<Import, Definitions> importDefinitions); @Override List<ItemDefinition> getImportedItemDefinitions(final Map<Import, Definitions> importDefinitions); @Override List<ItemDefinition> getImportedItemDefinitionsByNamespace(final WorkspaceProject workspaceProject,
                                                                      final String modelName,
                                                                      final String namespace); @Override Optional<InputStream> loadPath(final Path path); }
DMNMarshallerImportsHelperStandaloneImpl implements DMNMarshallerImportsHelperStandalone { @Override public Path getDMNModelPath(final Metadata metadata, final String modelNamespace, final String modelName) { final WorkspaceProject workspaceProject = getProject(metadata); for (final Path dmnModelPath : pathsHelper.getDMNModelsPaths(workspaceProject)) { final Optional<Definitions> definitions = getDefinitionsByPath(dmnModelPath); if (definitions.map(d -> Objects.equals(d.getNamespace(), modelNamespace) && Objects.equals(d.getName(), modelName)).orElse(false)) { return dmnModelPath; } } throw new IllegalStateException("A path for the DMN model with namespace [" + modelNamespace + "] could not be found."); } DMNMarshallerImportsHelperStandaloneImpl(); @Inject  DMNMarshallerImportsHelperStandaloneImpl(final DMNPathsHelper pathsHelper,
                                                    final WorkspaceProjectService projectService,
                                                    final DMNMarshaller marshaller,
                                                    final DMNIOHelper dmnIOHelper,
                                                    final PMMLIncludedDocumentFactory pmmlDocumentFactory,
                                                    final @Named("ioStrategy") IOService ioService); @Override Map<Import, Definitions> getImportDefinitions(final Metadata metadata,
                                                         final List<Import> imports); @Override Map<Import, PMMLDocumentMetadata> getPMMLDocuments(final Metadata metadata,
                                                              final List<Import> imports); @Override Map<Import, String> getImportXML(final Metadata metadata,
                                            final List<Import> imports); @Override Path getDMNModelPath(final Metadata metadata,
                                final String modelNamespace,
                                final String modelName); @Override List<DRGElement> getImportedDRGElements(final Map<Import, Definitions> importDefinitions); @Override List<ItemDefinition> getImportedItemDefinitions(final Map<Import, Definitions> importDefinitions); @Override List<ItemDefinition> getImportedItemDefinitionsByNamespace(final WorkspaceProject workspaceProject,
                                                                      final String modelName,
                                                                      final String namespace); @Override Optional<InputStream> loadPath(final Path path); static final QName NAMESPACE; }