@Test public void testWithNullArgument() { final Argument[] args = new Argument[] { mock(Argument.class), null, mock(Argument.class) }; IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> { adder.withArguments(args); }); assertThat(e.getMessage()).isEqualTo("Null arguments are not allowed: " + Arrays.toString(args)); }
@Override public ScriptExecutionAdder withArguments(final Argument... arguments) { if (arguments == null) { throw new IllegalArgumentException("Arguments cannot be null."); } if (arguments.length == 0) { throw new IllegalArgumentException("At least one argument must be supplied."); } for (final Argument argument : arguments) { if (argument == null) { throw new IllegalArgumentException("Null arguments are not allowed: " + Arrays.toString(arguments)); } } this.arguments = Arrays.asList(arguments); return this; }
ScriptExecutionAdderImpl implements ScriptExecutionAdder { @Override public ScriptExecutionAdder withArguments(final Argument... arguments) { if (arguments == null) { throw new IllegalArgumentException("Arguments cannot be null."); } if (arguments.length == 0) { throw new IllegalArgumentException("At least one argument must be supplied."); } for (final Argument argument : arguments) { if (argument == null) { throw new IllegalArgumentException("Null arguments are not allowed: " + Arrays.toString(arguments)); } } this.arguments = Arrays.asList(arguments); return this; } }
ScriptExecutionAdderImpl implements ScriptExecutionAdder { @Override public ScriptExecutionAdder withArguments(final Argument... arguments) { if (arguments == null) { throw new IllegalArgumentException("Arguments cannot be null."); } if (arguments.length == 0) { throw new IllegalArgumentException("At least one argument must be supplied."); } for (final Argument argument : arguments) { if (argument == null) { throw new IllegalArgumentException("Null arguments are not allowed: " + Arrays.toString(arguments)); } } this.arguments = Arrays.asList(arguments); return this; } ScriptExecutionAdderImpl(final String scriptName, final CommandQueue queue); }
ScriptExecutionAdderImpl implements ScriptExecutionAdder { @Override public ScriptExecutionAdder withArguments(final Argument... arguments) { if (arguments == null) { throw new IllegalArgumentException("Arguments cannot be null."); } if (arguments.length == 0) { throw new IllegalArgumentException("At least one argument must be supplied."); } for (final Argument argument : arguments) { if (argument == null) { throw new IllegalArgumentException("Null arguments are not allowed: " + Arrays.toString(arguments)); } } this.arguments = Arrays.asList(arguments); return this; } ScriptExecutionAdderImpl(final String scriptName, final CommandQueue queue); @Override void commit(); @Override ScriptExecutionAdder withReplace(final String recordName, final Record record); @Override ScriptExecutionAdder withArguments(final Argument... arguments); @Override ScriptExecutionAdder withAuthentication(final boolean authenticate); }
ScriptExecutionAdderImpl implements ScriptExecutionAdder { @Override public ScriptExecutionAdder withArguments(final Argument... arguments) { if (arguments == null) { throw new IllegalArgumentException("Arguments cannot be null."); } if (arguments.length == 0) { throw new IllegalArgumentException("At least one argument must be supplied."); } for (final Argument argument : arguments) { if (argument == null) { throw new IllegalArgumentException("Null arguments are not allowed: " + Arrays.toString(arguments)); } } this.arguments = Arrays.asList(arguments); return this; } ScriptExecutionAdderImpl(final String scriptName, final CommandQueue queue); @Override void commit(); @Override ScriptExecutionAdder withReplace(final String recordName, final Record record); @Override ScriptExecutionAdder withArguments(final Argument... arguments); @Override ScriptExecutionAdder withAuthentication(final boolean authenticate);  }