DefaultSystemCommandStore implements SystemCommandStore { @Override public SystemCommandHandlerProxy findCommandProxy(final SystemCommand systemCommand) { final SystemCommandHandlerProxy systemCommandHandlerProxy = handlers.get( systemCommand.getName() ); if (systemCommandHandlerProxy != null) { return systemCommandHandlerProxy; } final String message = format( "Failed to find SystemCommandHandler for command '%s'", systemCommand.getName()); throw new SystemCommandException(message); }  @Override SystemCommandHandlerProxy findCommandProxy(final SystemCommand systemCommand); @Override void store(final List<SystemCommandHandlerProxy> systemCommandProxies);  }
@Test public void shouldFailIfNoHandlerFound() throws Exception { final String missinCommandName = "This command does not exist"; final SystemCommand systemCommand = mock(SystemCommand.class); when(systemCommand.getName()).thenReturn(missinCommandName); try { defaultSystemCommandStore.findCommandProxy(systemCommand); fail(); } catch (final SystemCommandException expected) { assertThat(expected.getMessage(), is("Failed to find SystemCommandHandler for command 'This command does not exist'")); } }