@Test public void getShouldThrowExceptionWhenUserWasNotFound() throws Exception { final String username = UUID.randomUUID().toString(); expectedException.expect(Exception.class); expectedException.expectMessage(String.format("User for username %s was not found", username)); userDAO.get(username); }
@Override public User get(String username) throws Exception { return Optional.ofNullable(dynamoDBMapper.load(User.class, username)) .orElseThrow(() -> new Exception(String.format("User for username %s was not found", username))); }
UserRepositoryImpl implements UserRepository { @Override public User get(String username) throws Exception { return Optional.ofNullable(dynamoDBMapper.load(User.class, username)) .orElseThrow(() -> new Exception(String.format("User for username %s was not found", username))); } }
UserRepositoryImpl implements UserRepository { @Override public User get(String username) throws Exception { return Optional.ofNullable(dynamoDBMapper.load(User.class, username)) .orElseThrow(() -> new Exception(String.format("User for username %s was not found", username))); } UserRepositoryImpl(DynamoDBMapper dynamoDBMapper); }
UserRepositoryImpl implements UserRepository { @Override public User get(String username) throws Exception { return Optional.ofNullable(dynamoDBMapper.load(User.class, username)) .orElseThrow(() -> new Exception(String.format("User for username %s was not found", username))); } UserRepositoryImpl(DynamoDBMapper dynamoDBMapper); @Override void put(User user); @Override void delete(String username); @Override User get(String username); @Override List<User> findAll(); @Override List<User> findByEmail(String email); }
UserRepositoryImpl implements UserRepository { @Override public User get(String username) throws Exception { return Optional.ofNullable(dynamoDBMapper.load(User.class, username)) .orElseThrow(() -> new Exception(String.format("User for username %s was not found", username))); } UserRepositoryImpl(DynamoDBMapper dynamoDBMapper); @Override void put(User user); @Override void delete(String username); @Override User get(String username); @Override List<User> findAll(); @Override List<User> findByEmail(String email);  }