@Test public void testWithScriptNameTooLong() { final StringBuilder nameBuilder = new StringBuilder(); nameBuilder.append(StringUtils.repeat("a", 31)); IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> { adder.withScriptName(nameBuilder.toString()); }); assertThat(e.getMessage()).isEqualTo("Script name exceeds max length: 31 > 30"); }
@Override public DynamicCompilerAdderImpl withScriptName(final String scriptName) { if (scriptName == null) { throw new NullPointerException("Script name cannot be null."); } if (scriptName.trim().length() == 0) { throw new IllegalArgumentException("Script name cannot be blank."); } if (scriptName.length() > MAX_SCRIPT_NAME_LENGTH) { throw new IllegalArgumentException(String.format("Script name exceeds max length: %d > %d", scriptName.length(), MAX_SCRIPT_NAME_LENGTH)); } this.scriptName = scriptName; return this; }
DynamicCompilerAdderImpl extends AbstractCompilerAdder implements DynamicCompilerAdder<DynamicCompilerAdderImpl> { @Override public DynamicCompilerAdderImpl withScriptName(final String scriptName) { if (scriptName == null) { throw new NullPointerException("Script name cannot be null."); } if (scriptName.trim().length() == 0) { throw new IllegalArgumentException("Script name cannot be blank."); } if (scriptName.length() > MAX_SCRIPT_NAME_LENGTH) { throw new IllegalArgumentException(String.format("Script name exceeds max length: %d > %d", scriptName.length(), MAX_SCRIPT_NAME_LENGTH)); } this.scriptName = scriptName; return this; } }
DynamicCompilerAdderImpl extends AbstractCompilerAdder implements DynamicCompilerAdder<DynamicCompilerAdderImpl> { @Override public DynamicCompilerAdderImpl withScriptName(final String scriptName) { if (scriptName == null) { throw new NullPointerException("Script name cannot be null."); } if (scriptName.trim().length() == 0) { throw new IllegalArgumentException("Script name cannot be blank."); } if (scriptName.length() > MAX_SCRIPT_NAME_LENGTH) { throw new IllegalArgumentException(String.format("Script name exceeds max length: %d > %d", scriptName.length(), MAX_SCRIPT_NAME_LENGTH)); } this.scriptName = scriptName; return this; } DynamicCompilerAdderImpl(final File sourceFile, final CommandQueue queue); }
DynamicCompilerAdderImpl extends AbstractCompilerAdder implements DynamicCompilerAdder<DynamicCompilerAdderImpl> { @Override public DynamicCompilerAdderImpl withScriptName(final String scriptName) { if (scriptName == null) { throw new NullPointerException("Script name cannot be null."); } if (scriptName.trim().length() == 0) { throw new IllegalArgumentException("Script name cannot be blank."); } if (scriptName.length() > MAX_SCRIPT_NAME_LENGTH) { throw new IllegalArgumentException(String.format("Script name exceeds max length: %d > %d", scriptName.length(), MAX_SCRIPT_NAME_LENGTH)); } this.scriptName = scriptName; return this; } DynamicCompilerAdderImpl(final File sourceFile, final CommandQueue queue); @Override DynamicCompilerAdderImpl withDebugModeEnabled(final boolean debugModeEnabled); @Override DynamicCompilerAdderImpl withDependency(final File file); @Override DynamicCompilerAdderImpl withListingOutput(final File file); @Override DynamicCompilerAdderImpl withScriptName(final String scriptName); @Override void commit(); }
DynamicCompilerAdderImpl extends AbstractCompilerAdder implements DynamicCompilerAdder<DynamicCompilerAdderImpl> { @Override public DynamicCompilerAdderImpl withScriptName(final String scriptName) { if (scriptName == null) { throw new NullPointerException("Script name cannot be null."); } if (scriptName.trim().length() == 0) { throw new IllegalArgumentException("Script name cannot be blank."); } if (scriptName.length() > MAX_SCRIPT_NAME_LENGTH) { throw new IllegalArgumentException(String.format("Script name exceeds max length: %d > %d", scriptName.length(), MAX_SCRIPT_NAME_LENGTH)); } this.scriptName = scriptName; return this; } DynamicCompilerAdderImpl(final File sourceFile, final CommandQueue queue); @Override DynamicCompilerAdderImpl withDebugModeEnabled(final boolean debugModeEnabled); @Override DynamicCompilerAdderImpl withDependency(final File file); @Override DynamicCompilerAdderImpl withListingOutput(final File file); @Override DynamicCompilerAdderImpl withScriptName(final String scriptName); @Override void commit();  }