UploadIdFromHttpResponseViaRegex implements Function<HttpResponse, String> { @Override public String apply(HttpResponse response) { String value = null; String content = returnStringIf200.apply(response); if (content != null) { Matcher matcher = pattern.matcher(content); if (matcher.find()) { value = matcher.group(1); } } return value; } @Inject  UploadIdFromHttpResponseViaRegex(ReturnStringIf2xx returnStringIf200); @Override String apply(HttpResponse response);  }
@Test public void test() { HttpResponse response = HttpResponse.builder().statusCode(200).payload( Payloads.newInputStreamPayload(getClass().getResourceAsStream("/initiate-multipart-upload.xml"))) .build(); UploadIdFromHttpResponseViaRegex parser = new UploadIdFromHttpResponseViaRegex(new ReturnStringIf2xx()); assertEquals(parser.apply(response), "VXBsb2FkIElEIGZvciA2aWWpbmcncyBteS1tb3ZpZS5tMnRzIHVwbG9hZA"); }