### Question:
HtmlBody { public List<String> extractInputCheckboxNamesByFormId(String formId) { List<String> names = new ArrayList<>(); for(Element checkbox : this.doc.select("#" + formId + " input[type=checkbox]")) { if(Strings.isNullOrEmpty(checkbox.attr("name"))) { throw new IllegalArgumentException("Retrieved checkbox element from form with id " + formId + " with empty name."); } names.add(checkbox.attr("name")); } return names; } HtmlBody(String html); String extractInputFieldValueByName(String fieldName); boolean containsId(String id); List<String> extractInputCheckboxNamesByFormId(String formId);  }### Answer:
@Test public void testExtractInputCheckboxNamesByFormId_whenPresent_shouldReturnList() { HtmlBody htmlBody = new HtmlBody("<html><form id=\"frmConsent\">" + "<input type=\"checkbox\"/ name=\"scope-1\" id=\"id-1\"/>" + "<input type=\"checkbox\"/ name=\"scope-2\" id=\"id-2\"/>" + "</form></html>"); assertThat(htmlBody.extractInputCheckboxNamesByFormId("frmConsent")).contains("scope-1", "scope-2"); }
@Test(expected = IllegalArgumentException.class) public void testExtractInputCheckboxNamesByFormId_whenCheckboxMissesName_shouldThrowException() { HtmlBody htmlBody = new HtmlBody("<html><form id=\"frmConsent\">" + "<input type=\"checkbox\"/ id=\"id-1\"/>" + "</form></html>"); htmlBody.extractInputCheckboxNamesByFormId("frmConsent"); }