Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class UserRepoDynamoDBTest {
// ...
@Test
public void Given_UserRepoDynamoDB_Then_CreateAndReadUserSuccessfully() {
userDAO.createUser(UserMockData.USER_NEW);
UserModel loadedUser = userDAO.getUser(UserMockData.USER_NEW).get();
assertEquals(UserMockData.USER_NEW, loadedUser);
}
@Test
public void Given_UserRepoDynamoDB_Then_UpdateAndReadUserSuccessfully() {
UserMockData.USER_EXISTS.setIsActive(true);
userDAO.updateUser(UserMockData.USER_EXISTS);
UserModel loadedUser = userDAO.getUser(UserMockData.USER_EXISTS).get();
assertEquals(UserMockData.USER_EXISTS, loadedUser);
}
@Test
public void Given_UserRepoDynamoDBAndExistingUser_Then_CreateUserThrowsException() {
assertThrows(UserAlreadyExistsException.class, () -> {
userDAO.createUser(UserMockData.USER_EXISTS);
});
}
@Test
public void Given_UserRepoDynamoDBAndNonExistingUser_Then_UpdateUserThrowsException() {
assertThrows(UserNotFoundException.class, () -> {
userDAO.updateUser(UserMockData.USER_NEW);
});
}
@Test
public void Given_UserRepoDynamoDB_Then_DeleteSuccessfully() {
userDAO.deleteUser(UserMockData.USER_EXISTS);
assertFalse(userDAO.getUser(UserMockData.USER_EXISTS).isPresent());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.