@Test public void testAmbiguityException() { modelPath.resolveModel(ambiguousModel); assertEquals(1, Log.getErrorCount()); }
public ModelCoordinate resolveModel(ModelCoordinate qualifiedModel) { String fixedPath = qualifiedModel.getQualifiedPath().toString() .replaceAll("\\" + File.separator, "/"); List<URL> resolvedURLS = classloaderMap.keySet().stream() .map(classloader -> FileReaderWriter.getResource(classloader, fixedPath)) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); if(1 < resolvedURLS.size()) { List<URL> resolvedURLSfinal = resolvedURLS; Set<URL> duplicateURLs = resolvedURLS.stream() .filter(i -> Collections.frequency(resolvedURLSfinal, i) >1) .collect(Collectors.toSet()); duplicateURLs.forEach(duplicateURL ->{ Log.warn("0xA1293 Multiple duplicate matching entries where located in the modelpath for the model " + fixedPath + "\n" + duplicateURL.toString()); }); } resolvedURLS = resolvedURLS.stream().distinct().collect(Collectors.toList()); if (1 < resolvedURLS.size()) { StringBuilder ambiguitiyArray = new StringBuilder("{"); String sep = ""; for (URL url: resolvedURLS) { ambiguitiyArray.append(sep); sep = ",\n"; ambiguitiyArray.append(url.toString()); } ambiguitiyArray.append("}"); Log.error( "0xA1294 Multiple matching entries where located in the modelpath for the model " + fixedPath + "\n" + ambiguitiyArray.toString()); } if (1 == resolvedURLS.size()) { qualifiedModel.setLocation(Iterables.getOnlyElement(resolvedURLS)); } return qualifiedModel; }
ModelPath { public ModelCoordinate resolveModel(ModelCoordinate qualifiedModel) { String fixedPath = qualifiedModel.getQualifiedPath().toString() .replaceAll("\\" + File.separator, "/"); List<URL> resolvedURLS = classloaderMap.keySet().stream() .map(classloader -> FileReaderWriter.getResource(classloader, fixedPath)) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); if(1 < resolvedURLS.size()) { List<URL> resolvedURLSfinal = resolvedURLS; Set<URL> duplicateURLs = resolvedURLS.stream() .filter(i -> Collections.frequency(resolvedURLSfinal, i) >1) .collect(Collectors.toSet()); duplicateURLs.forEach(duplicateURL ->{ Log.warn("0xA1293 Multiple duplicate matching entries where located in the modelpath for the model " + fixedPath + "\n" + duplicateURL.toString()); }); } resolvedURLS = resolvedURLS.stream().distinct().collect(Collectors.toList()); if (1 < resolvedURLS.size()) { StringBuilder ambiguitiyArray = new StringBuilder("{"); String sep = ""; for (URL url: resolvedURLS) { ambiguitiyArray.append(sep); sep = ",\n"; ambiguitiyArray.append(url.toString()); } ambiguitiyArray.append("}"); Log.error( "0xA1294 Multiple matching entries where located in the modelpath for the model " + fixedPath + "\n" + ambiguitiyArray.toString()); } if (1 == resolvedURLS.size()) { qualifiedModel.setLocation(Iterables.getOnlyElement(resolvedURLS)); } return qualifiedModel; } }
ModelPath { public ModelCoordinate resolveModel(ModelCoordinate qualifiedModel) { String fixedPath = qualifiedModel.getQualifiedPath().toString() .replaceAll("\\" + File.separator, "/"); List<URL> resolvedURLS = classloaderMap.keySet().stream() .map(classloader -> FileReaderWriter.getResource(classloader, fixedPath)) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); if(1 < resolvedURLS.size()) { List<URL> resolvedURLSfinal = resolvedURLS; Set<URL> duplicateURLs = resolvedURLS.stream() .filter(i -> Collections.frequency(resolvedURLSfinal, i) >1) .collect(Collectors.toSet()); duplicateURLs.forEach(duplicateURL ->{ Log.warn("0xA1293 Multiple duplicate matching entries where located in the modelpath for the model " + fixedPath + "\n" + duplicateURL.toString()); }); } resolvedURLS = resolvedURLS.stream().distinct().collect(Collectors.toList()); if (1 < resolvedURLS.size()) { StringBuilder ambiguitiyArray = new StringBuilder("{"); String sep = ""; for (URL url: resolvedURLS) { ambiguitiyArray.append(sep); sep = ",\n"; ambiguitiyArray.append(url.toString()); } ambiguitiyArray.append("}"); Log.error( "0xA1294 Multiple matching entries where located in the modelpath for the model " + fixedPath + "\n" + ambiguitiyArray.toString()); } if (1 == resolvedURLS.size()) { qualifiedModel.setLocation(Iterables.getOnlyElement(resolvedURLS)); } return qualifiedModel; } ModelPath(Collection<Path> modelPathEntries);  ModelPath(Path... modelPathEntries); }
ModelPath { public ModelCoordinate resolveModel(ModelCoordinate qualifiedModel) { String fixedPath = qualifiedModel.getQualifiedPath().toString() .replaceAll("\\" + File.separator, "/"); List<URL> resolvedURLS = classloaderMap.keySet().stream() .map(classloader -> FileReaderWriter.getResource(classloader, fixedPath)) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); if(1 < resolvedURLS.size()) { List<URL> resolvedURLSfinal = resolvedURLS; Set<URL> duplicateURLs = resolvedURLS.stream() .filter(i -> Collections.frequency(resolvedURLSfinal, i) >1) .collect(Collectors.toSet()); duplicateURLs.forEach(duplicateURL ->{ Log.warn("0xA1293 Multiple duplicate matching entries where located in the modelpath for the model " + fixedPath + "\n" + duplicateURL.toString()); }); } resolvedURLS = resolvedURLS.stream().distinct().collect(Collectors.toList()); if (1 < resolvedURLS.size()) { StringBuilder ambiguitiyArray = new StringBuilder("{"); String sep = ""; for (URL url: resolvedURLS) { ambiguitiyArray.append(sep); sep = ",\n"; ambiguitiyArray.append(url.toString()); } ambiguitiyArray.append("}"); Log.error( "0xA1294 Multiple matching entries where located in the modelpath for the model " + fixedPath + "\n" + ambiguitiyArray.toString()); } if (1 == resolvedURLS.size()) { qualifiedModel.setLocation(Iterables.getOnlyElement(resolvedURLS)); } return qualifiedModel; } ModelPath(Collection<Path> modelPathEntries);  ModelPath(Path... modelPathEntries); void removeEntry(Path modelPathEntry); void addEntry(Path modelPathEntry); ModelCoordinate resolveModel(ModelCoordinate qualifiedModel); @Override String toString(); Collection<Path> getFullPathOfEntries(); }
ModelPath { public ModelCoordinate resolveModel(ModelCoordinate qualifiedModel) { String fixedPath = qualifiedModel.getQualifiedPath().toString() .replaceAll("\\" + File.separator, "/"); List<URL> resolvedURLS = classloaderMap.keySet().stream() .map(classloader -> FileReaderWriter.getResource(classloader, fixedPath)) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); if(1 < resolvedURLS.size()) { List<URL> resolvedURLSfinal = resolvedURLS; Set<URL> duplicateURLs = resolvedURLS.stream() .filter(i -> Collections.frequency(resolvedURLSfinal, i) >1) .collect(Collectors.toSet()); duplicateURLs.forEach(duplicateURL ->{ Log.warn("0xA1293 Multiple duplicate matching entries where located in the modelpath for the model " + fixedPath + "\n" + duplicateURL.toString()); }); } resolvedURLS = resolvedURLS.stream().distinct().collect(Collectors.toList()); if (1 < resolvedURLS.size()) { StringBuilder ambiguitiyArray = new StringBuilder("{"); String sep = ""; for (URL url: resolvedURLS) { ambiguitiyArray.append(sep); sep = ",\n"; ambiguitiyArray.append(url.toString()); } ambiguitiyArray.append("}"); Log.error( "0xA1294 Multiple matching entries where located in the modelpath for the model " + fixedPath + "\n" + ambiguitiyArray.toString()); } if (1 == resolvedURLS.size()) { qualifiedModel.setLocation(Iterables.getOnlyElement(resolvedURLS)); } return qualifiedModel; } ModelPath(Collection<Path> modelPathEntries);  ModelPath(Path... modelPathEntries); void removeEntry(Path modelPathEntry); void addEntry(Path modelPathEntry); ModelCoordinate resolveModel(ModelCoordinate qualifiedModel); @Override String toString(); Collection<Path> getFullPathOfEntries();  }