@Test public void testCreateUserFeedback() throws Exception { userFeedback.setUsername(null); verifyException(feedbackImpl, NullPointerException.class).createUserFeedback(userFeedback); userFeedback.setUsername(USER); userFeedback.setSubmitted(null); verifyException(feedbackImpl, NullPointerException.class).createUserFeedback(userFeedback); userFeedback.setSubmitted(new Date()); verifyException(feedbackImpl, IllegalArgumentException.class).createUserFeedback(userFeedback); userFeedback.setContactOkay(true); UserInfo userInfo = UserInfo.newInstance(USER).build(); when(userDirectory.lookupUser(USER)).thenReturn(userInfo); userFeedback.setScore(7); feedbackImpl.createUserFeedback(userFeedback); doThrow(RepositoryException.class).when(feedbackRepository).createUserFeedback(userFeedback); verifyException(feedbackImpl, RepositoryException.class).createUserFeedback(userFeedback); doThrow(AuthenticationException.class).when(userDirectory).lookupUser(USER); verifyException(feedbackImpl, AuthenticationException.class).createUserFeedback(userFeedback); }
@Override public void createUserFeedback(UserFeedback userFeedback) { checkNotNull(userFeedback.getUsername(), "Parameter \"username\" cannot be null"); checkNotNull(userFeedback.getSubmitted(), "Parameter \"submitted\" cannot be null"); if (userFeedback.getScore() == 0 && "".equals(userFeedback.getComments()) && !userFeedback.isContactOkay()) { throw new IllegalArgumentException("error, one of score, contactOkay, or comments must be provided"); } if (userFeedback.isContactOkay()) { userFeedback.setEmail(userDirectory.lookupUser(userFeedback.getUsername()).getEmail()); } LOGGER.debug("User Feedback: storing feedback from user " + userFeedback.getUsername().toString() + "submitted " + "at time " + userFeedback.getSubmitted().toString()); feedbackRepository.createUserFeedback(userFeedback); }
FeedbackImpl implements Feedback { @Override public void createUserFeedback(UserFeedback userFeedback) { checkNotNull(userFeedback.getUsername(), "Parameter \"username\" cannot be null"); checkNotNull(userFeedback.getSubmitted(), "Parameter \"submitted\" cannot be null"); if (userFeedback.getScore() == 0 && "".equals(userFeedback.getComments()) && !userFeedback.isContactOkay()) { throw new IllegalArgumentException("error, one of score, contactOkay, or comments must be provided"); } if (userFeedback.isContactOkay()) { userFeedback.setEmail(userDirectory.lookupUser(userFeedback.getUsername()).getEmail()); } LOGGER.debug("User Feedback: storing feedback from user " + userFeedback.getUsername().toString() + "submitted " + "at time " + userFeedback.getSubmitted().toString()); feedbackRepository.createUserFeedback(userFeedback); } }
FeedbackImpl implements Feedback { @Override public void createUserFeedback(UserFeedback userFeedback) { checkNotNull(userFeedback.getUsername(), "Parameter \"username\" cannot be null"); checkNotNull(userFeedback.getSubmitted(), "Parameter \"submitted\" cannot be null"); if (userFeedback.getScore() == 0 && "".equals(userFeedback.getComments()) && !userFeedback.isContactOkay()) { throw new IllegalArgumentException("error, one of score, contactOkay, or comments must be provided"); } if (userFeedback.isContactOkay()) { userFeedback.setEmail(userDirectory.lookupUser(userFeedback.getUsername()).getEmail()); } LOGGER.debug("User Feedback: storing feedback from user " + userFeedback.getUsername().toString() + "submitted " + "at time " + userFeedback.getSubmitted().toString()); feedbackRepository.createUserFeedback(userFeedback); } @Inject  FeedbackImpl(final FeedbackRepository feedbackRepository, final UserDirectory userDirectory); }
FeedbackImpl implements Feedback { @Override public void createUserFeedback(UserFeedback userFeedback) { checkNotNull(userFeedback.getUsername(), "Parameter \"username\" cannot be null"); checkNotNull(userFeedback.getSubmitted(), "Parameter \"submitted\" cannot be null"); if (userFeedback.getScore() == 0 && "".equals(userFeedback.getComments()) && !userFeedback.isContactOkay()) { throw new IllegalArgumentException("error, one of score, contactOkay, or comments must be provided"); } if (userFeedback.isContactOkay()) { userFeedback.setEmail(userDirectory.lookupUser(userFeedback.getUsername()).getEmail()); } LOGGER.debug("User Feedback: storing feedback from user " + userFeedback.getUsername().toString() + "submitted " + "at time " + userFeedback.getSubmitted().toString()); feedbackRepository.createUserFeedback(userFeedback); } @Inject  FeedbackImpl(final FeedbackRepository feedbackRepository, final UserDirectory userDirectory); @Override void createUserFeedback(UserFeedback userFeedback); @Override List<UserFeedback> getUserFeedback(UserInfo.Username username); @Override List<UserFeedback> getAllUserFeedback(); }
FeedbackImpl implements Feedback { @Override public void createUserFeedback(UserFeedback userFeedback) { checkNotNull(userFeedback.getUsername(), "Parameter \"username\" cannot be null"); checkNotNull(userFeedback.getSubmitted(), "Parameter \"submitted\" cannot be null"); if (userFeedback.getScore() == 0 && "".equals(userFeedback.getComments()) && !userFeedback.isContactOkay()) { throw new IllegalArgumentException("error, one of score, contactOkay, or comments must be provided"); } if (userFeedback.isContactOkay()) { userFeedback.setEmail(userDirectory.lookupUser(userFeedback.getUsername()).getEmail()); } LOGGER.debug("User Feedback: storing feedback from user " + userFeedback.getUsername().toString() + "submitted " + "at time " + userFeedback.getSubmitted().toString()); feedbackRepository.createUserFeedback(userFeedback); } @Inject  FeedbackImpl(final FeedbackRepository feedbackRepository, final UserDirectory userDirectory); @Override void createUserFeedback(UserFeedback userFeedback); @Override List<UserFeedback> getUserFeedback(UserInfo.Username username); @Override List<UserFeedback> getAllUserFeedback();  }