@Test(expected = RepositoryException.class) public void testCreateFeedbackThrowsException() { UserFeedback userFeedback = new UserFeedback(); userFeedback.setUsername(Username.valueOf("userId1")); userFeedback.setSubmitted(new Date()); userFeedback.setScore(2); userFeedback.setComments("comments1"); userFeedback.setContactOkay(true); userFeedback.setEmail("userId1@example.com"); doThrow(new RuntimeException("testException")).when(userFeedbackAccessor).createUserFeedback( userFeedback.getUsername().toString(), userFeedback.getSubmitted(), userFeedback.getScore(), userFeedback.getComments(), userFeedback.isContactOkay(), userFeedback.getEmail()); repository.createUserFeedback(userFeedback); }
@Override public void createUserFeedback(UserFeedback userFeedback) { LOGGER.debug("creating user feedback {}", userFeedback); try { userFeedbackAccessor.createUserFeedback(userFeedback.getUsername().getUsername(), userFeedback.getSubmitted(), userFeedback.getScore(), userFeedback.getComments(), userFeedback.isContactOkay(), userFeedback.getEmail()); } catch (Exception e) { LOGGER.error("Error while creating user feedback", e); throw new RepositoryException("Could not save feedback from user " + userFeedback, e); } }
CassandraFeedbackRepository implements FeedbackRepository { @Override public void createUserFeedback(UserFeedback userFeedback) { LOGGER.debug("creating user feedback {}", userFeedback); try { userFeedbackAccessor.createUserFeedback(userFeedback.getUsername().getUsername(), userFeedback.getSubmitted(), userFeedback.getScore(), userFeedback.getComments(), userFeedback.isContactOkay(), userFeedback.getEmail()); } catch (Exception e) { LOGGER.error("Error while creating user feedback", e); throw new RepositoryException("Could not save feedback from user " + userFeedback, e); } } }
CassandraFeedbackRepository implements FeedbackRepository { @Override public void createUserFeedback(UserFeedback userFeedback) { LOGGER.debug("creating user feedback {}", userFeedback); try { userFeedbackAccessor.createUserFeedback(userFeedback.getUsername().getUsername(), userFeedback.getSubmitted(), userFeedback.getScore(), userFeedback.getComments(), userFeedback.isContactOkay(), userFeedback.getEmail()); } catch (Exception e) { LOGGER.error("Error while creating user feedback", e); throw new RepositoryException("Could not save feedback from user " + userFeedback, e); } } @Inject  CassandraFeedbackRepository(UserFeedbackAccessor userFeedbackAccessor); }
CassandraFeedbackRepository implements FeedbackRepository { @Override public void createUserFeedback(UserFeedback userFeedback) { LOGGER.debug("creating user feedback {}", userFeedback); try { userFeedbackAccessor.createUserFeedback(userFeedback.getUsername().getUsername(), userFeedback.getSubmitted(), userFeedback.getScore(), userFeedback.getComments(), userFeedback.isContactOkay(), userFeedback.getEmail()); } catch (Exception e) { LOGGER.error("Error while creating user feedback", e); throw new RepositoryException("Could not save feedback from user " + userFeedback, e); } } @Inject  CassandraFeedbackRepository(UserFeedbackAccessor userFeedbackAccessor); @Override void createUserFeedback(UserFeedback userFeedback); @Override List<UserFeedback> getUserFeedback(UserInfo.Username username); @Override List<UserFeedback> getAllUserFeedback(); }
CassandraFeedbackRepository implements FeedbackRepository { @Override public void createUserFeedback(UserFeedback userFeedback) { LOGGER.debug("creating user feedback {}", userFeedback); try { userFeedbackAccessor.createUserFeedback(userFeedback.getUsername().getUsername(), userFeedback.getSubmitted(), userFeedback.getScore(), userFeedback.getComments(), userFeedback.isContactOkay(), userFeedback.getEmail()); } catch (Exception e) { LOGGER.error("Error while creating user feedback", e); throw new RepositoryException("Could not save feedback from user " + userFeedback, e); } } @Inject  CassandraFeedbackRepository(UserFeedbackAccessor userFeedbackAccessor); @Override void createUserFeedback(UserFeedback userFeedback); @Override List<UserFeedback> getUserFeedback(UserInfo.Username username); @Override List<UserFeedback> getAllUserFeedback();  }