### Question:
Authenticator { public User logInUser(String username, String password) throws LoginException { User user = getUserWithValidPassword(username, password); updateLoggedinColumn(username, true); user.setLoggedIn(true); return user; } Authenticator(Connection dbConnection); static String getSaltedSHA256String(String input, String salt); User logInUser(String username, String password); User lookUpUser(String username); Map<String, Object> lookUpUserProperties(String username); User logOutUser(String username); Object lookUpUserProperty(String username, String propertyName); static boolean isWrapperType(Class<?> clazz); static final int HEX_CONVERSION_CONSTANT; }### Answer:
@Test public void testLogInUser() throws Exception { Authenticator connector = new Authenticator(connection); String username = "TestAccount2"; String password = "testPassword"; connector.logInUser(username, password); User user = connector.lookUpUser(username); Assert.assertTrue(user.isLoggedIn()); }
@Test(expectedExceptions = LoginException.class) public void testConcurrentLogins() throws Exception { Authenticator connector = new Authenticator(connection); String username = "TestAccount3"; String password = "testPassword"; connector.logInUser(username, password); connector.logInUser(username, password); }
@Test(expectedExceptions = LoginException.class) public void testInvalidPassword() throws Exception { Authenticator connector = new Authenticator(connection); String username = "TestAccount5"; String password = "incorrectPassword"; connector.logInUser(username, password); }