@Test public void testApi() { try { String expected = "http: String actual = null; actual = uriMapper.map("api/account"); Assert.assertEquals(expected, actual); } catch (Exception e) { fail(e.getMessage()); } }
public String map(String uri) { for (Mapping mapping : mappings) { Matcher matcher = mapping.from.matcher(uri); if (matcher.matches()) { String result = mapping.to; log.debug("uri: {}, mapping to: {}", uri, result); for (int i = 1; i <= matcher.groupCount(); i++) { log.debug("group {}: {}", i, matcher.group(i)); result = result.replaceAll("\\$\\{" + i + "\\}", matcher.group(i)); } log.debug("result: {}", result); return result; } } return null; }
URIMapper { public String map(String uri) { for (Mapping mapping : mappings) { Matcher matcher = mapping.from.matcher(uri); if (matcher.matches()) { String result = mapping.to; log.debug("uri: {}, mapping to: {}", uri, result); for (int i = 1; i <= matcher.groupCount(); i++) { log.debug("group {}: {}", i, matcher.group(i)); result = result.replaceAll("\\$\\{" + i + "\\}", matcher.group(i)); } log.debug("result: {}", result); return result; } } return null; } }
URIMapper { public String map(String uri) { for (Mapping mapping : mappings) { Matcher matcher = mapping.from.matcher(uri); if (matcher.matches()) { String result = mapping.to; log.debug("uri: {}, mapping to: {}", uri, result); for (int i = 1; i <= matcher.groupCount(); i++) { log.debug("group {}: {}", i, matcher.group(i)); result = result.replaceAll("\\$\\{" + i + "\\}", matcher.group(i)); } log.debug("result: {}", result); return result; } } return null; } @Inject  URIMapper(@Named("uri-mappings") File mappingsFile); }
URIMapper { public String map(String uri) { for (Mapping mapping : mappings) { Matcher matcher = mapping.from.matcher(uri); if (matcher.matches()) { String result = mapping.to; log.debug("uri: {}, mapping to: {}", uri, result); for (int i = 1; i <= matcher.groupCount(); i++) { log.debug("group {}: {}", i, matcher.group(i)); result = result.replaceAll("\\$\\{" + i + "\\}", matcher.group(i)); } log.debug("result: {}", result); return result; } } return null; } @Inject  URIMapper(@Named("uri-mappings") File mappingsFile); String map(String uri); }
URIMapper { public String map(String uri) { for (Mapping mapping : mappings) { Matcher matcher = mapping.from.matcher(uri); if (matcher.matches()) { String result = mapping.to; log.debug("uri: {}, mapping to: {}", uri, result); for (int i = 1; i <= matcher.groupCount(); i++) { log.debug("group {}: {}", i, matcher.group(i)); result = result.replaceAll("\\$\\{" + i + "\\}", matcher.group(i)); } log.debug("result: {}", result); return result; } } return null; } @Inject  URIMapper(@Named("uri-mappings") File mappingsFile); String map(String uri);  }