Skip to content

Instantly share code, notes, and snippets.

View adrianvdh's full-sized avatar

Adrian van den Houten adrianvdh

  • Cape Town
View GitHub Profile
class UserService {
List<User> users = new ArrayList<>();
{
User user = new User();
user.username = "adrianvdh";
user.password = "hello123";
users.add(user);
}
@Test(expected = RuntimeException.class)
public void userLoginWhereUserIsNotFound() {
String username = "kentbeck";
String password = "letmein";
UserService userService = new UserService();
User user = userService.authenticate(username, password);
}
class UserService {
List<User> users = new ArrayList<>();
{
User user = new User();
user.username = "adrianvdh";
user.password = "hello123";
users.add(user);
}
public class UserService {
List<User> users = new ArrayList<>();
{
User user = new User();
user.username = "adrianvdh";
user.password = "hello123";
users.add(user);
}
public class UserService {
public User authenicate(String username, String password) {
User user = new User();
user.username = "adrianvdh";
user.password = "hello123";
return user;
}
}
public class User {
String username = "adrianvdh";
String password = "hello123";
}
public class AuthorisationContext {
public void authenticate(String username, String password) {
}
}
public class User {
String username;
String password;
}
public class AuthorisationContext {
}
@Test
public void userLoginWithCorrectCredentials() throws Exception {
// Given that this user exists
String username = "adrianvdh";
String password = "hello123";
AuthorisationContext authorisationContext = new AuthorisationContext();
// When authenticating
authorisationContext.authenticate(username, password);