### Question:
InternalTopicConfig { public Properties toProperties(final long additionalRetentionMs) { final Properties result = new Properties(); for (Map.Entry<String, String> configEntry : logConfig.entrySet()) { result.put(configEntry.getKey(), configEntry.getValue()); } if (retentionMs != null && isCompactDelete()) { result.put(InternalTopicManager.RETENTION_MS, String.valueOf(retentionMs + additionalRetentionMs)); } if (!logConfig.containsKey(InternalTopicManager.CLEANUP_POLICY_PROP)) { final StringBuilder builder = new StringBuilder(); for (CleanupPolicy cleanupPolicy : cleanupPolicies) { builder.append(cleanupPolicy.name()).append(","); } builder.deleteCharAt(builder.length() - 1); result.put(InternalTopicManager.CLEANUP_POLICY_PROP, builder.toString()); } return result; } InternalTopicConfig(final String name, final Set<CleanupPolicy> defaultCleanupPolicies, final Map<String, String> logConfig); Properties toProperties(final long additionalRetentionMs); String name(); void setRetentionMs(final long retentionMs); @Override boolean equals(final Object o); @Override int hashCode();  }### Answer:
@Test public void shouldHaveCompactionPropSetIfSupplied() throws Exception { final Properties properties = new InternalTopicConfig("name", Collections.singleton(InternalTopicConfig.CleanupPolicy.compact), Collections.<String, String>emptyMap()).toProperties(0); assertEquals("compact", properties.getProperty(InternalTopicManager.CLEANUP_POLICY_PROP)); }
@Test public void shouldUseCleanupPolicyFromConfigIfSupplied() throws Exception { final InternalTopicConfig config = new InternalTopicConfig("name", Collections.singleton(InternalTopicConfig.CleanupPolicy.delete), Collections.singletonMap("cleanup.policy", "compact")); final Properties properties = config.toProperties(0); assertEquals("compact", properties.getProperty("cleanup.policy")); }
@Test public void shouldHavePropertiesSuppliedByUser() throws Exception { final Map<String, String> configs = new HashMap<>(); configs.put("retention.ms", "1000"); configs.put("retention.bytes", "10000"); final InternalTopicConfig topicConfig = new InternalTopicConfig("name", Collections.singleton(InternalTopicConfig.CleanupPolicy.delete), configs); final Properties properties = topicConfig.toProperties(0); assertEquals("1000", properties.getProperty("retention.ms")); assertEquals("10000", properties.getProperty("retention.bytes")); }