LocalExecutableRegistryImpl implements ExecutableRegistry { @Override public void registerTask(String taskIdentifier, Executable method) { this.identifierToMethodMap.put(taskIdentifier,method); } @Inject  LocalExecutableRegistryImpl(Injector injector);  LocalExecutableRegistryImpl(Map<String, Executable> identifierToMethodMap, Injector injector); @Override Executable getTask(String taskIdentifier); @Override Method getHook(String hookIdentifier); @Override void registerTask(String taskIdentifier, Executable method); @Override void unregisterTask(String taskIdentifier);  }
@Test public void testRegisterNewTask_shouldStoreExecutableInCache() throws Exception { localExecutableRegistry.registerTask("fooBar", new ExecutableImpl(simpleWorkflowForTest,simpleWorkflowForTest.getClass().getDeclaredMethod("simpleStringModifyingTask", StringEvent.class), 2000l)); assertThat(identifierToMethodMap.containsKey("fooBar")).isTrue(); assertThat(identifierToMethodMap.get("fooBar")).isEqualTo(new ExecutableImpl(simpleWorkflowForTest, simpleWorkflowForTest.getClass().getDeclaredMethod("simpleStringModifyingTask", StringEvent.class), 2000l)); }
@Test public void testRegisterNewTask_gracefullyHandleDuplicates() throws Exception { localExecutableRegistry.registerTask("fooBar",new ExecutableImpl(simpleWorkflowForTest,simpleWorkflowForTest.getClass().getDeclaredMethod("simpleStringModifyingTask", StringEvent.class), 2000l)); localExecutableRegistry.registerTask("fooBar",new ExecutableImpl(simpleWorkflowForTest,simpleWorkflowForTest.getClass().getDeclaredMethod("simpleStringModifyingTask", StringEvent.class), 2000l)); assertThat(identifierToMethodMap.containsKey("fooBar")).isTrue(); assertThat(identifierToMethodMap.get("fooBar")).isEqualTo(new ExecutableImpl(simpleWorkflowForTest,simpleWorkflowForTest.getClass().getDeclaredMethod("simpleStringModifyingTask", StringEvent.class), 2000l)); }