AkkaModule extends AbstractModule { @Provides @Singleton @Named("routerConfigMap") public Map<String, Integer> getRouterConfigs(DeploymentUnitsManager deploymentUnitsManager, TaskRouterUtil taskRouterUtil) { Map<String, Integer> routerConfigMap = new ConcurrentHashMap<>(); for (DeploymentUnit deploymentUnit : deploymentUnitsManager.getAllDeploymentUnits()) { Map<String, Method> taskMethods = deploymentUnit.getTaskMethods(); for (Method taskMethod : taskMethods.values()) { String routerName = taskRouterUtil.getRouterName(taskMethod); Integer taskExecConcurrency = taskRouterUtil.getConcurrency(deploymentUnit, routerName); routerConfigMap.put(routerName, taskExecConcurrency); } } return routerConfigMap; }  @Provides @Singleton @Named("routerConfigMap") Map<String, Integer> getRouterConfigs(DeploymentUnitsManager deploymentUnitsManager,
                                                 TaskRouterUtil taskRouterUtil);  }
@Test public void testGetRouterConfigurations_shouldGetConcurrencyValueFromConfigFile() throws Exception { when(configuration.getProperty("com.flipkart.flux.integration.SimpleWorkflow_simpleIntegerReturningTask.executionConcurrency")).thenReturn(5); when(deploymentUnit.getTaskConfiguration()).thenReturn(configuration); Map<String, DeploymentUnit> deploymentUnitsMap = new HashMap<String, DeploymentUnit>(){{ put("DeploymentUnit1", deploymentUnit); }}; int defaultNoOfActors = 10; Class simpleWorkflowClass = this.getClass().getClassLoader().loadClass("com.flipkart.flux.integration.SimpleWorkflow"); Map<String, Method> taskMethods = Collections.singletonMap("com.flipkart.flux.integration.SimpleWorkflow_simpleIntegerReturningTask_com.flipkart.flux.integration.IntegerEvent_version1", simpleWorkflowClass.getMethod("simpleIntegerReturningTask")); when(deploymentUnit.getTaskMethods()).thenReturn(taskMethods); when(deploymentUnitManager.getAllDeploymentUnits()).thenReturn(Collections.singleton(deploymentUnit)); assertThat(akkaModule.getRouterConfigs(deploymentUnitManager, new TaskRouterUtil(defaultNoOfActors))). containsEntry("com.flipkart.flux.integration.SimpleWorkflow_simpleIntegerReturningTask", 5); }
@Test public void testGetRouterConfigurations_shouldUseDefaultConcurrentValue() throws Exception { when(deploymentUnit.getTaskConfiguration()).thenReturn(configuration); Map<String, DeploymentUnit> deploymentUnitsMap = new HashMap<String, DeploymentUnit>(){{ put("DeploymentUnit1", deploymentUnit); }}; int defaultNoOfActors = 10; Class simpleWorkflowClass = this.getClass().getClassLoader().loadClass("com.flipkart.flux.integration.SimpleWorkflow"); Map<String, Method> taskMethods = Collections.singletonMap("com.flipkart.flux.integration.SimpleWorkflow_simpleIntegerReturningTask_com.flipkart.flux.integration.IntegerEvent_version1", simpleWorkflowClass.getMethod("simpleIntegerReturningTask")); when(deploymentUnit.getTaskMethods()).thenReturn(taskMethods); when(deploymentUnitManager.getAllDeploymentUnits()).thenReturn(Collections.singleton(deploymentUnit)); assertThat(akkaModule.getRouterConfigs(deploymentUnitManager, new TaskRouterUtil(defaultNoOfActors))). containsEntry("com.flipkart.flux.integration.SimpleWorkflow_simpleIntegerReturningTask", defaultNoOfActors); }