### Question:
TopicServiceImpl implements TopicService { @Override public void alterConfiguration(List<ConfiguredTopic> topics) { AlterConfigsOptions options = dryRun ? new AlterConfigsOptions().validateOnly(true) : new AlterConfigsOptions(); Map<ConfigResource, Config> configs = topics .stream() .collect(toMap(t -> new ConfigResource(Type.TOPIC, t.getName()), TopicServiceImpl::resourceConfig)); try { adminClient.alterConfigs(configs, options).all().get(); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); } } TopicServiceImpl(AdminClient adminClient, boolean dryRun); @Override Map<String, ConfiguredTopic> listExisting(boolean excludeInternal); @Override void create(List<ConfiguredTopic> topics); @Override void increasePartitions(List<ConfiguredTopic> topics); @Override void alterConfiguration(List<ConfiguredTopic> topics); @Override void delete(List<ConfiguredTopic> topics);  }### Answer:
@Test public void testAlterConfiguration() { TopicService service = new TopicServiceImpl(adminClient, true); AlterConfigsResult result = mock(AlterConfigsResult.class); when(result.all()).thenReturn(KafkaFuture.completedFuture(null)); when(adminClient.alterConfigs(any(Map.class), any(AlterConfigsOptions.class))).thenReturn(result); service.alterConfiguration(Collections.singletonList( new ConfiguredTopic("test", 3, (short) 2, Collections.singletonMap("k", "v")))); ArgumentCaptor<Map> alter = ArgumentCaptor.forClass(Map.class); ArgumentCaptor<AlterConfigsOptions> options = ArgumentCaptor.forClass(AlterConfigsOptions.class); verify(adminClient).alterConfigs((Map<ConfigResource, Config>) alter.capture(), options.capture()); Assert.assertEquals(1, alter.getValue().size()); ConfigResource expectedKey = new ConfigResource(TOPIC, "test"); Assert.assertTrue(alter.getValue().containsKey(expectedKey)); Assert.assertEquals("v", ((Config) alter.getValue().get(expectedKey)).get("k").value()); Assert.assertTrue(options.getValue().shouldValidateOnly()); }