### Question:
PingWindow extends Window { protected URL buildURL() { boolean validInput = false; try { validInput = validateInput(); } catch (NumberFormatException e) { getApplication().getMainWindow().showNotification("Inputs must be integers", Notification.TYPE_WARNING_MESSAGE); return null; } if (validInput) { final URL baseUrl = getApplication().getURL(); final StringBuilder options = new StringBuilder(baseAddress); options.append("&address=").append(ipDropdown.getValue()) .append("&timeout=").append(timeoutField.getValue()) .append("&numberOfRequests=").append(requestsField.getValue()) .append("&packetSize=").append(Integer.parseInt(packetSizeDropdown.getValue().toString()) - 8); if (numericalDataCheckBox.getValue().equals(true)) { options.append("&numericOutput=true"); } try { return new URL(baseUrl, options.toString()); } catch (final MalformedURLException e) { getApplication().getMainWindow().showNotification("Could not build URL: " + options.toString(), Notification.TYPE_WARNING_MESSAGE); return null; } } else { getApplication().getMainWindow().showNotification("Inputs must be between 0 and 9999", Notification.TYPE_WARNING_MESSAGE); return null; } } PingWindow(final Node node, final String baseAddress); @Override void attach();  }### Answer:
@Test public void testBuildURL_correctInput() { pingWindow.numericalDataCheckBox.setValue(true); pingWindow.packetSizeDropdown.setValue("32"); pingWindow.requestsField.setValue("100"); pingWindow.timeoutField.setValue("100"); assertNotNull(pingWindow.buildURL()); }
@Test public void testBuildURL_malformedURL() { pingWindow3.numericalDataCheckBox.setValue(true); pingWindow3.packetSizeDropdown.setValue("32"); pingWindow3.requestsField.setValue("100"); pingWindow3.timeoutField.setValue("100"); assertNull(pingWindow3.buildURL()); }
@Test public void testBuildURL_upperBounds() { pingWindow.numericalDataCheckBox.setValue(true); pingWindow.packetSizeDropdown.setValue("1024"); pingWindow.requestsField.setValue("10000"); pingWindow.timeoutField.setValue("10000"); assertNull(pingWindow.buildURL()); }
@Test public void testBuildURL_lowerBounds() { pingWindow.packetSizeDropdown.setValue("16"); pingWindow.requestsField.setValue("0"); pingWindow.timeoutField.setValue("0"); assertNull(pingWindow.buildURL()); }
@Test public void testBuildURL_nonIntegerInput() { pingWindow.numericalDataCheckBox.setValue(true); pingWindow.packetSizeDropdown.setValue("1024"); pingWindow.requestsField.setValue("abcd"); pingWindow.timeoutField.setValue("abcd"); assertNull(pingWindow.buildURL()); }
@Test public void testBuildURL_negativeIntegers() { pingWindow.numericalDataCheckBox.setValue(true); pingWindow.packetSizeDropdown.setValue("1024"); pingWindow.requestsField.setValue("-99"); pingWindow.timeoutField.setValue("-1024"); assertNull(pingWindow.buildURL()); }
@Test public void testBuildURL_invalidRequests() { pingWindow.numericalDataCheckBox.setValue(true); pingWindow.packetSizeDropdown.setValue("1024"); pingWindow.requestsField.setValue("10000"); pingWindow.timeoutField.setValue("100"); assertNull(pingWindow.buildURL()); }