### Question:
CommunityRuntime implements TransactionEventHandler<Map<String, Object>>, GraphAwareRuntime, KernelEventHandler { @Override public synchronized void registerModule(RuntimeModule module) { if (!State.REGISTERED.equals(state)) { LOG.error("Modules must be registered before GraphAware Runtime is started!"); throw new IllegalStateException("Modules must be registered before GraphAware Runtime is started!"); } LOG.info("Registering module " + module.getId() + " with GraphAware Runtime."); txDrivenModuleManager.checkNotAlreadyRegistered(module); timerDrivenModuleManager.checkNotAlreadyRegistered(module); if (module instanceof TxDrivenModule) { txDrivenModuleManager.registerModule((TxDrivenModule) module); } if (module instanceof TimerDrivenModule) { timerDrivenModuleManager.registerModule((TimerDrivenModule) module); } } protected  CommunityRuntime(RuntimeConfiguration configuration, GraphDatabaseService database, TxDrivenModuleManager<TxDrivenModule> txDrivenModuleManager, TimerDrivenModuleManager timerDrivenModuleManager, Neo4jWriter writer); @Override synchronized void registerModule(RuntimeModule module); @Override final synchronized void start(); @Override final void waitUntilStarted(); @Override Map<String, Object> beforeCommit(TransactionData data); @Override final void afterCommit(TransactionData data, Map<String, Object> states); @Override final void afterRollback(TransactionData data, Map<String, Object> states); @Override void beforeShutdown(); @Override M getModule(String moduleId, Class<M> clazz); @Override M getModule(Class<M> clazz); @Override final void kernelPanic(ErrorState error); @Override final Object getResource(); @Override final ExecutionOrder orderComparedTo(KernelEventHandler other); @Override RuntimeConfiguration getConfiguration(); @Override Neo4jWriter getDatabaseWriter();  }### Answer:
@Test(expected = IllegalStateException.class) public void shouldNotBeAbleToRegisterDifferentModulesWithSameId() { GraphAwareRuntime runtime = createRuntime(database, defaultConfiguration(database).withTimingStrategy(TIMING_STRATEGY)); runtime.registerModule(mockTxModule()); runtime.registerModule(mockTimerModule()); }
@Test(expected = IllegalStateException.class) public void shouldNotBeAbleToRegisterSameTimerModuleTwice() { GraphAwareRuntime runtime = createRuntime(database, defaultConfiguration(database).withTimingStrategy(TIMING_STRATEGY)); runtime.registerModule(mockTimerModule()); runtime.registerModule(mockTimerModule()); }
@Test(expected = IllegalStateException.class) public void shouldNotBeAbleToRegisterTheSameModuleTwice() { final TxDrivenModule mockModule = mockTxModule(); GraphAwareRuntime runtime = createRuntime(database, defaultConfiguration(database).withTimingStrategy(TIMING_STRATEGY)); runtime.registerModule(mockModule); runtime.registerModule(mockModule); }
@Test(expected = IllegalStateException.class) public void shouldNotBeAbleToRegisterModuleWithTheSameIdTwice() { final TxDrivenModule mockModule1 = mockTxModule(); final TxDrivenModule mockModule2 = mockTxModule(); when(mockModule1.getId()).thenReturn("ID"); when(mockModule2.getId()).thenReturn("ID"); GraphAwareRuntime runtime = createRuntime(database, defaultConfiguration(database).withTimingStrategy(TIMING_STRATEGY)); runtime.registerModule(mockModule1); runtime.registerModule(mockModule2); }