### Question:
ImportIdReplacer { public InputStream createStreamWithLegalId(InputStream inputStream) throws IOException { String string = IOUtils.toString(inputStream); string = string.replaceFirst("\"repositoryId\": \"" + oldId + "\"", "\"repositoryId\": \"" + newId + "\""); return new ByteArrayInputStream(string.getBytes()); } ImportIdReplacer(String oldId, String newId); InputStream createStreamWithLegalId(InputStream inputStream);  }### Answer:
@Test public void replacesRepositoryId() throws Exception { InputStream stream = new ByteArrayInputStream("{\"repositoryId\": \"old\"}".getBytes()); InputStream newStream = new ImportIdReplacer("old", "new").createStreamWithLegalId(stream); String replacementString = IOUtils.toString(newStream); assertThat(replacementString, containsString("\"repositoryId\": \"new\"")); }