@Test public void create_withAdvertisedListenerSameScheme_returnsUrlRelativeToAdvertisedListenerSameScheme() { expect(requestUriInfo.getAbsolutePath()) .andStubReturn(URI.create("http: expect(requestUriInfo.getBaseUri()).andReturn(URI.create("http: replay(requestUriInfo); UrlFactory urlFactory = new UrlFactoryImpl( "", 0, singletonList("http: singletonList("http: requestUriInfo); String url = urlFactory.create("foo", "bar"); assertEquals("http: }
@Override public String create(String... segments) { UrlBuilder urlBuilder = newUrlBuilder(); for (String component : segments) { String stripped = trimSeparator(component); if (!stripped.isEmpty()) { urlBuilder.appendPathSegment(stripped); } } return urlBuilder.build(); }
UrlFactoryImpl implements UrlFactory { @Override public String create(String... segments) { UrlBuilder urlBuilder = newUrlBuilder(); for (String component : segments) { String stripped = trimSeparator(component); if (!stripped.isEmpty()) { urlBuilder.appendPathSegment(stripped); } } return urlBuilder.build(); } }
UrlFactoryImpl implements UrlFactory { @Override public String create(String... segments) { UrlBuilder urlBuilder = newUrlBuilder(); for (String component : segments) { String stripped = trimSeparator(component); if (!stripped.isEmpty()) { urlBuilder.appendPathSegment(stripped); } } return urlBuilder.build(); } @Inject  UrlFactoryImpl(
      @HostNameConfig String hostNameConfig,
      @PortConfig Integer portConfig,
      @AdvertisedListenersConfig List<String> advertisedListenersConfig,
      @ListenersConfig List<String> listenersConfig,
      @Context UriInfo requestUriInfo
  ); }
UrlFactoryImpl implements UrlFactory { @Override public String create(String... segments) { UrlBuilder urlBuilder = newUrlBuilder(); for (String component : segments) { String stripped = trimSeparator(component); if (!stripped.isEmpty()) { urlBuilder.appendPathSegment(stripped); } } return urlBuilder.build(); } @Inject  UrlFactoryImpl(
      @HostNameConfig String hostNameConfig,
      @PortConfig Integer portConfig,
      @AdvertisedListenersConfig List<String> advertisedListenersConfig,
      @ListenersConfig List<String> listenersConfig,
      @Context UriInfo requestUriInfo
  ); @Override String create(String... segments); @Override UrlBuilder newUrlBuilder(); }
UrlFactoryImpl implements UrlFactory { @Override public String create(String... segments) { UrlBuilder urlBuilder = newUrlBuilder(); for (String component : segments) { String stripped = trimSeparator(component); if (!stripped.isEmpty()) { urlBuilder.appendPathSegment(stripped); } } return urlBuilder.build(); } @Inject  UrlFactoryImpl(
      @HostNameConfig String hostNameConfig,
      @PortConfig Integer portConfig,
      @AdvertisedListenersConfig List<String> advertisedListenersConfig,
      @ListenersConfig List<String> listenersConfig,
      @Context UriInfo requestUriInfo
  ); @Override String create(String... segments); @Override UrlBuilder newUrlBuilder();  }