### Question:
AppcacheLinker extends AbstractLinker { @Nonnull final ArtifactSet perPermutationLink( @Nonnull final TreeLogger logger, @Nonnull final LinkerContext context, @Nonnull final ArtifactSet artifacts ) throws UnableToCompleteException { final Permutation permutation = calculatePermutation( logger, context, artifacts ); if ( null == permutation ) { logger.log( Type.ERROR, "Unable to calculate permutation " ); throw new UnableToCompleteException(); } final ArtifactSet results = new ArtifactSet( artifacts ); results.add( new PermutationArtifact( AppcacheLinker.class, permutation ) ); return results; }  @Override String getDescription(); @Override ArtifactSet link( @Nonnull final TreeLogger logger,
                           @Nonnull final LinkerContext context,
                           @Nonnull final ArtifactSet artifacts,
                           final boolean onePermutation );  }### Answer:
@Test public void perPermutationLink() throws UnableToCompleteException { final AppcacheLinker linker = new AppcacheLinker(); final ArtifactSet artifacts1 = new ArtifactSet(); artifacts1.add( new StandardGeneratedResource( "myapp.devmode.js", new byte[ 0 ] ) ); artifacts1.add( new StandardGeneratedResource( "file1.txt", new byte[ 0 ] ) ); final TreeMap<String, String> configs2 = new TreeMap<>(); configs2.put( "user.agent", "ie9" ); artifacts1.add( new SelectionInformation( "S2", 0, configs2 ) ); final LinkerContext linkerContext = mock( LinkerContext.class ); when( linkerContext.getModuleName() ).thenReturn( "myapp" ); { final ArtifactSet artifactSet = linker.perPermutationLink( TreeLogger.NULL, linkerContext, artifacts1 ); final SortedSet<PermutationArtifact> permutationArtifacts = artifactSet.find( PermutationArtifact.class ); assertEquals( permutationArtifacts.size(), 1 ); final PermutationArtifact permutationArtifact = permutationArtifacts.iterator().next(); final Permutation permutation = permutationArtifact.getPermutation(); assertEquals( permutation.getPermutationName(), "S2" ); assertTrue( permutation.getPermutationFiles().contains( "myapp/file1.txt" ) ); assertEquals( permutation.getSelectors().size(), 1 ); } { final ArtifactSet artifactSet = linker.link( TreeLogger.NULL, linkerContext, artifacts1, true ); final SortedSet<PermutationArtifact> permutationArtifacts = artifactSet.find( PermutationArtifact.class ); assertEquals( permutationArtifacts.size(), 1 ); final PermutationArtifact permutationArtifact = permutationArtifacts.iterator().next(); final Permutation permutation = permutationArtifact.getPermutation(); assertEquals( permutation.getPermutationName(), "S2" ); assertTrue( permutation.getPermutationFiles().contains( "myapp/file1.txt" ) ); assertEquals( permutation.getSelectors().size(), 1 ); } }