### Question:
DefaultLoginFormAdapter implements LoginFormAdapter { protected LoginCommandImpl parseLoginForm(String loginPage) { Document doc = Jsoup.parse(loginPage); if (doc == null) throw new IllegalArgumentException("Unable to parse login page content"); LoginCommandImpl params = new LoginCommandImpl(); Element form = doc.selectFirst("form"); if (form == null) throw new IllegalArgumentException("Login page does not have a form"); params.setActionUrl(form.attr("action")); params.setMethod(form.attr("method")); params.setInputValues(new HashMap<String, String>()); form.select("input").forEach(input -> { params.getInputValues().put(input.attr("name"), input.attr("value")); }); return params; } DefaultLoginFormAdapter(String authorizeUrl); @Override LoginCommand parseAndFill(String content, String username, String password); String getAuthorizeUrl(); List<String> getValidInputNamesUsername(); void setValidInputNamesUsername(List<String> validInputNamesUsername); List<String> getValidInputNamesPassword(); void setValidInputNamesPassword(List<String> validInputNamesPassword);  }### Answer:
@Test public void testParseLoginForm() { String content = TestFileUtil.readFile("login.html"); LoginCommandImpl cmd = adapter.parseLoginForm(content); assertEquals("wrong action url", "/ticket/login", cmd.getActionUrl()); assertEquals("wrong method", "post", cmd.getMethod()); assertTrue("Wrong number of inputs", cmd.getInputValues().size() == 3); assertEquals("wrong input someinput value", "somevalue", cmd.getInputValues().get("someinput")); }
@Test public void testParseLoginFormNoForm() { thrown.expect(IllegalArgumentException.class); String content = TestFileUtil.readFile("login-no-form.html"); adapter.parseLoginForm(content); }