### Question:
TokenStrategyFactory { public Collection<BlobStrategy> getStrategies(CoreTokenConfig config) { List<BlobStrategy> strategies = new ArrayList<BlobStrategy>(); if (config.isAttributeNamesCompressed()) { strategies.add(attributeCompression); } if (config.isTokenCompressed()) { strategies.add(compression); } if (config.isTokenEncrypted()) { strategies.add(encryption); } return strategies; } @Inject  TokenStrategyFactory(CompressionStrategy compression, EncryptionStrategy encryption,
                                AttributeCompressionStrategy attributeCompression); Collection<BlobStrategy> getStrategies(CoreTokenConfig config);  }### Answer:
@Test public void shouldReturnCompression() { CoreTokenConfig config = mock(CoreTokenConfig.class); given(config.isTokenCompressed()).willReturn(true); Collection<BlobStrategy> strategies = factory.getStrategies(config); assertThat(strategies).contains(compression); }
@Test public void shouldReturnEncryption() { CoreTokenConfig config = mock(CoreTokenConfig.class); given(config.isTokenEncrypted()).willReturn(true); Collection<BlobStrategy> strategies = factory.getStrategies(config); assertThat(strategies).contains(encryption); }
@Test public void shouldReturnAttributeCompression() { CoreTokenConfig config = mock(CoreTokenConfig.class); given(config.isAttributeNamesCompressed()).willReturn(true); Collection<BlobStrategy> strategies = factory.getStrategies(config); assertThat(strategies).contains(attributeCompression); }
@Test public void shouldReturnMultipleStrategies() { CoreTokenConfig config = mock(CoreTokenConfig.class); given(config.isTokenEncrypted()).willReturn(true); given(config.isTokenCompressed()).willReturn(true); Collection<BlobStrategy> strategies = factory.getStrategies(config); assertThat(strategies).contains(compression, encryption); }
@Test public void shouldReturnAttributeCompressionBeforeGzipCompression() { CoreTokenConfig config = mock(CoreTokenConfig.class); given(config.isAttributeNamesCompressed()).willReturn(true); given(config.isTokenCompressed()).willReturn(true); List<BlobStrategy> strategies = new ArrayList<BlobStrategy>(factory.getStrategies(config)); assertThat(strategies.get(0)).isEqualTo(attributeCompression); assertThat(strategies.get(1)).isEqualTo(compression); }