IdeaEntity { public VoteEntity vote(UserEntity voter, int vote) { Assert.isTrue(vote > 0, "Vote value out of bounds: " + vote); Assert.isTrue(vote < 6, "Vote value out of bounds: " + vote); if (IdeaStatus.PUBLISHED != this.status) { throw InvalidRequestException.voteOnInvalidIdeaStatus(); } return new VoteEntity(new VoteId(voter.getId(), this.getId()), vote); } private  IdeaEntity(); static IdeaEntity createIdeaEntity(IdeaIn cmd, String campaignId, UserEntity creator); void approveIdea(UserEntity approvingAdmin); void rejectIdea(UserEntity approvingAdmin, String rejectionComment); VoteEntity vote(UserEntity voter, int vote); Rating calculateRating(Collection<VoteEntity> votes, UserEntity requestingUser); String getId(); void setId(String id); IdeaContentI18nMap getContentI18n(); void setContentI18n(IdeaContentI18nMap contentI18n); IdeaStatus getStatus(); void setStatus(IdeaStatus status); String getRejectionComment(); void setRejectionComment(String rejectionComment); DateTime getCreatedDate(); void setCreatedDate(DateTime createdDate); DateTime getLastModifiedDate(); void setLastModifiedDate(DateTime lastModifiedDate); DateTime getReviewDate(); void setReviewDate(DateTime reviewDate); UserEntity getCreator(); void setCreator(UserEntity creator); String getCampaignId(); String getApprovingAdminId(); void setApprovingAdminId(String approvingAdminId); String getOriginalTitle(); String getOriginalPitch(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void vote_ShouldThrow_On_NonApprovedIdea() { final IdeaEntity ideaEntity = Fixtures.givenIdeaEntity(); try { ideaEntity.vote(Fixtures.givenUserEntity("voter_id"), 3); fail("Expected exception not thrown."); } catch (InvalidRequestException e) { assertThat(e.getMessage(), equalTo("idea_status_invalid_for_vote")); } }