### Question:
ComposerProxyFacetImpl extends ProxyFacetSupport { @Override protected String getUrl(@Nonnull final Context context) { AssetKind assetKind = context.getAttributes().require(AssetKind.class); switch (assetKind) { case ZIPBALL: return getZipballUrl(context); default: return context.getRequest().getPath().substring(1); } } @Inject  ComposerProxyFacetImpl(final ComposerJsonProcessor composerJsonProcessor);   }### Answer:
@Test public void getUrlPackages() throws Exception { when(contextAttributes.require(AssetKind.class)).thenReturn(LIST); when(request.getPath()).thenReturn("/" + PACKAGES_PATH); assertThat(underTest.getUrl(context), is(PACKAGES_PATH)); }
@Test public void getUrlList() throws Exception { when(contextAttributes.require(AssetKind.class)).thenReturn(LIST); when(request.getPath()).thenReturn("/" + LIST_PATH); assertThat(underTest.getUrl(context), is(LIST_PATH)); }
@Test public void getUrlProvider() throws Exception { when(contextAttributes.require(AssetKind.class)).thenReturn(LIST); when(request.getPath()).thenReturn("/" + PROVIDER_PATH); assertThat(underTest.getUrl(context), is(PROVIDER_PATH)); }
@Test public void getUrlZipball() throws Exception { when(contextAttributes.require(AssetKind.class)).thenReturn(ZIPBALL); when(contextAttributes.require(TokenMatcher.State.class)).thenReturn(state); when(viewFacet.dispatch(any(Request.class), eq(context))).thenReturn(response); when(composerJsonProcessor.getDistUrl("vendor", "project", "version", payload)).thenReturn("distUrl"); when(state.getTokens()).thenReturn(new ImmutableMap.Builder<String, String>() .put("vendor", "vendor") .put("project", "project") .put("version", "version") .put("name", "project-version") .build()); assertThat(underTest.getUrl(context), is("distUrl")); }
@Test(expected = NonResolvableProviderJsonException.class) public void getUrlZipballMissingProviderJson() throws Exception { when(contextAttributes.require(AssetKind.class)).thenReturn(ZIPBALL); when(contextAttributes.require(TokenMatcher.State.class)).thenReturn(state); when(viewFacet.dispatch(any(Request.class), eq(context))).thenReturn(response); when(response.getPayload()).thenReturn(null); when(state.getTokens()).thenReturn(new ImmutableMap.Builder<String, String>() .put("vendor", "vendor") .put("project", "project") .put("version", "version") .put("name", "project-version") .build()); underTest.getUrl(context); }