### Question:
Flow2Config { @Bean public Map<String, FlowConfiguration<?>> flowConfigurationMap(List<FlowConfiguration<?>> flowConfigs) { Map<String, FlowConfiguration<?>> flowConfigMap = new HashMap<>(); for (FlowConfiguration<?> flowConfig : flowConfigs) { for (FlowEvent event : flowConfig.getInitEvents()) { String key = event.event(); if (flowConfigMap.get(key) != null) { throw new UnsupportedOperationException("Event already registered: " + key); } flowConfigMap.put(key, flowConfig); } } return ImmutableMap.copyOf(flowConfigMap); }  @Bean Map<String, FlowConfiguration<?>> flowConfigurationMap(List<FlowConfiguration<?>> flowConfigs); @Bean Set<String> retryableEvents(List<RetryableFlowConfiguration<?>> retryableFlowConfigurations); @Bean Set<String> failHandledEvents(List<AbstractFlowConfiguration<?, ?>> flowConfigurations);  }### Answer:
@Test public void testFlowConfigurationMapInit() { List<FlowConfiguration<?>> flowConfigs = new ArrayList<>(); flowConfigs.add(new HelloWorldFlowConfig()); flowConfigs.add(new TestFlowConfig()); Map<String, FlowConfiguration<?>> flowConfigMap = underTest.flowConfigurationMap(flowConfigs); assertEquals("Not all flow type appeared in map!", countEvents(flowConfigs), flowConfigMap.size()); }
@Test public void testFlowConfigurationMapInitIfAlreadyExists() { List<FlowConfiguration<?>> flowConfigs = new ArrayList<>(); HelloWorldFlowConfig helloWorldFlowConfig = new HelloWorldFlowConfig(); flowConfigs.add(helloWorldFlowConfig); flowConfigs.add(helloWorldFlowConfig); thrown.expect(UnsupportedOperationException.class); thrown.expectMessage("Event already registered: " + HelloWorldEvent.HELLOWORLD_TRIGGER_EVENT.event()); underTest.flowConfigurationMap(flowConfigs); }