@Ignore @Test public void replacesUrl() throws Exception { InputStream inputStream = getClass().getResourceAsStream("jsonformoderncpp_download_url.json"); AttributesMap attributesMap = new AttributesMap(); when(context.getAttributes()).thenReturn(attributesMap); when(content.openInputStream()).thenReturn(inputStream); when(repository.getUrl()).thenReturn("http: String actual = underTest.updateAbsoluteUrls(context, content, repository); assertAbsoluteUrlMatches(new ByteArrayInputStream(actual.getBytes()), getClass().getResourceAsStream(EXPECTED_DOWNLOAD_URL)); }
public String updateAbsoluteUrls(final Context context, final Content content, final Repository repository) throws IOException { Map<String, URL> downloadUrlContents = readIndex(content.openInputStream()); Map<String, String> remappedContents = new HashMap<>(); State state = context.getAttributes().require(TokenMatcher.State.class); ConanCoords coords = OrientConanProxyHelper.convertFromState(state); for (Map.Entry<String, URL> entry : downloadUrlContents.entrySet()) { String fileName = entry.getKey(); AssetKind assetKind = OrientConanProxyHelper.ASSET_KIND_FILENAMES.get(fileName); remappedContents.put(entry.getKey(), repository.getUrl() + "/" + getProxyAssetPath(coords, assetKind)); } return MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(remappedContents); }
ConanUrlIndexer extends ComponentSupport { public String updateAbsoluteUrls(final Context context, final Content content, final Repository repository) throws IOException { Map<String, URL> downloadUrlContents = readIndex(content.openInputStream()); Map<String, String> remappedContents = new HashMap<>(); State state = context.getAttributes().require(TokenMatcher.State.class); ConanCoords coords = OrientConanProxyHelper.convertFromState(state); for (Map.Entry<String, URL> entry : downloadUrlContents.entrySet()) { String fileName = entry.getKey(); AssetKind assetKind = OrientConanProxyHelper.ASSET_KIND_FILENAMES.get(fileName); remappedContents.put(entry.getKey(), repository.getUrl() + "/" + getProxyAssetPath(coords, assetKind)); } return MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(remappedContents); } }
ConanUrlIndexer extends ComponentSupport { public String updateAbsoluteUrls(final Context context, final Content content, final Repository repository) throws IOException { Map<String, URL> downloadUrlContents = readIndex(content.openInputStream()); Map<String, String> remappedContents = new HashMap<>(); State state = context.getAttributes().require(TokenMatcher.State.class); ConanCoords coords = OrientConanProxyHelper.convertFromState(state); for (Map.Entry<String, URL> entry : downloadUrlContents.entrySet()) { String fileName = entry.getKey(); AssetKind assetKind = OrientConanProxyHelper.ASSET_KIND_FILENAMES.get(fileName); remappedContents.put(entry.getKey(), repository.getUrl() + "/" + getProxyAssetPath(coords, assetKind)); } return MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(remappedContents); }  }
ConanUrlIndexer extends ComponentSupport { public String updateAbsoluteUrls(final Context context, final Content content, final Repository repository) throws IOException { Map<String, URL> downloadUrlContents = readIndex(content.openInputStream()); Map<String, String> remappedContents = new HashMap<>(); State state = context.getAttributes().require(TokenMatcher.State.class); ConanCoords coords = OrientConanProxyHelper.convertFromState(state); for (Map.Entry<String, URL> entry : downloadUrlContents.entrySet()) { String fileName = entry.getKey(); AssetKind assetKind = OrientConanProxyHelper.ASSET_KIND_FILENAMES.get(fileName); remappedContents.put(entry.getKey(), repository.getUrl() + "/" + getProxyAssetPath(coords, assetKind)); } return MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(remappedContents); }  String updateAbsoluteUrls(final Context context,
                                   final Content content,
                                   final Repository repository); String findUrl(final InputStream inputStream, final String find); }
ConanUrlIndexer extends ComponentSupport { public String updateAbsoluteUrls(final Context context, final Content content, final Repository repository) throws IOException { Map<String, URL> downloadUrlContents = readIndex(content.openInputStream()); Map<String, String> remappedContents = new HashMap<>(); State state = context.getAttributes().require(TokenMatcher.State.class); ConanCoords coords = OrientConanProxyHelper.convertFromState(state); for (Map.Entry<String, URL> entry : downloadUrlContents.entrySet()) { String fileName = entry.getKey(); AssetKind assetKind = OrientConanProxyHelper.ASSET_KIND_FILENAMES.get(fileName); remappedContents.put(entry.getKey(), repository.getUrl() + "/" + getProxyAssetPath(coords, assetKind)); } return MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(remappedContents); }  String updateAbsoluteUrls(final Context context,
                                   final Content content,
                                   final Repository repository); String findUrl(final InputStream inputStream, final String find);  }