### Question:
PathResolver { public HttpUrl resolve(HttpUrl base) { HttpUrl.Builder builder = base.newBuilder(); for (String path : mPaths) { builder.addPathSegment(path); } return builder.build(); } PathResolver(List<String> paths); HttpUrl resolve(HttpUrl base);  }### Answer:
@Test public void shouldAggregateSinglePath() throws Exception { HttpUrl base = HttpUrl.parse("http: PathResolver resolver = new PathResolver.Builder() .addPath("path") .build(); HttpUrl expected = resolver.resolve(base); assertThat(expected, is(HttpUrl.parse("http: }
@Test public void shouldAggregateMultiplePaths() throws Exception { HttpUrl base = HttpUrl.parse("http: PathResolver resolver = new PathResolver.Builder() .addPaths("/path/a/b") .build(); HttpUrl expected = resolver.resolve(base); assertThat(expected, is(HttpUrl.parse("http: }
@Test public void shouldAggregateSinglePathAsItIs() throws Exception { HttpUrl base = HttpUrl.parse("http: PathResolver resolver = new PathResolver.Builder() .addPaths("path") .build(); HttpUrl expected = resolver.resolve(base); assertThat(expected, is(HttpUrl.parse("http: }
@Test public void shouldNotAggregatePathIfEmptinessSupplied() throws Exception { HttpUrl base = HttpUrl.parse("http: PathResolver resolver = new PathResolver.Builder() .addPath("") .build(); HttpUrl expected = resolver.resolve(base); assertThat(expected, is(HttpUrl.parse("http: PathResolver resolver2 = new PathResolver.Builder() .addPaths("") .build(); HttpUrl expected2 = resolver2.resolve(base); assertThat(expected2, is(HttpUrl.parse("http: }