BlacklistedCommandsFilter { public boolean isSystemCommandAllowed(final String commandName, final Set<SystemCommand> blacklistedCommands) { return blacklistedCommands.stream() .noneMatch(systemCommand -> systemCommand.getName().equals(commandName)); }  boolean isSystemCommandAllowed(final String commandName, final Set<SystemCommand> blacklistedCommands);  }
@Test public void shouldReturnTrueIfTheHandlesSystemCommandNameIdDoesNotMatchAnyOfTheNamesOfTheBlacklistedSystemCommands() throws Exception { final SystemCommand_1 systemCommand_1 = new SystemCommand_1(); final SystemCommand_2 systemCommand_2 = new SystemCommand_2(); final SystemCommand_3 systemCommand_3 = new SystemCommand_3(); final Set<SystemCommand> blacklistedCommands = newHashSet( systemCommand_1, systemCommand_2, systemCommand_3 ); assertThat(blacklistedCommandsFilter.isSystemCommandAllowed(systemCommand_1.getName(), blacklistedCommands), is(false)); assertThat(blacklistedCommandsFilter.isSystemCommandAllowed(systemCommand_2.getName(), blacklistedCommands), is(false)); assertThat(blacklistedCommandsFilter.isSystemCommandAllowed(systemCommand_3.getName(), blacklistedCommands), is(false)); assertThat(blacklistedCommandsFilter.isSystemCommandAllowed("SOME_OTHER_COMMAND", blacklistedCommands), is(true)); }