IdeasCampaignEntity { public static IdeasCampaignEntity newIdeasCampaign(IdeasCampaign creationCmd, UserEntity initiator) { log.info(creationCmd.toString()); log.debug(creationCmd.toString()); verifyActiveTimeSpan(creationCmd); final IdeasCampaignEntity res = new IdeasCampaignEntity(); res.setStartDate(creationCmd.getStartDate()); res.setEndDate(creationCmd.getEndDate()); res.setInitiator(initiator); res.setSponsor(creationCmd.getSponsor()); res.setContent(creationCmd.getContentI18n()); return res; } private  IdeasCampaignEntity(); static IdeasCampaignEntity newIdeasCampaign(IdeasCampaign creationCmd, UserEntity initiator); void updateMasterdata(IdeasCampaign cmd); boolean isActive(); boolean isExpired(); IdeaEntity createIdea(IdeaIn cmd, UserEntity creator); IdeaEntity approveIdea(IdeaEntity ideaToApprove, UserEntity approvingAdmin); IdeaEntity rejectIdea(IdeaEntity ideaToReject, UserEntity approvingAdmin, String rejectionComment); String getId(); void setId(String id); DateTime getStartDate(); void setStartDate(DateTime startDate); DateTime getEndDate(); void setEndDate(DateTime endDate); DateTime getCreatedDate(); void setCreatedDate(DateTime createdDate); DateTime getLastModifiedDate(); void setLastModifiedDate(DateTime lastModifiedDate); UserEntity getInitiator(); void setInitiator(UserEntity initiator); String getSponsor(); void setSponsor(String sponsor); IdeasCampaignContentI18nMap getContent(); void setContent(IdeasCampaignContentI18nMap content); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void newIdeasCampaign_ShouldReturnFullyInitializedCampaign() { final String userId = "test_userId"; IdeasCampaign cmd = givenIdeasCampaignCmd(userId); UserEntity initiator = givenUserEntity(userId); final IdeasCampaignEntity res = IdeasCampaignEntity.newIdeasCampaign(cmd, initiator); thenIdeasCampaignContainsExpectedFields(res, cmd); }
@Test(expected = IllegalArgumentException.class) public void newIdeasCampaigns_ShouldThrowOnInvalidTimeSpan() { final String userId = "test_userId"; IdeasCampaign cmd = givenIdeasCampaignCmd(userId, DateTime.now().plusDays(3), DateTime.now().minusDays(1)); UserEntity initiator = givenUserEntity(userId); IdeasCampaignEntity.newIdeasCampaign(cmd, initiator); }
@Test(expected = IllegalArgumentException.class) public void newIdeasCampaigns_ShouldThrowOnEmptyStartDate() { final String userId = "test_userId"; IdeasCampaign cmd = givenIdeasCampaignCmd(userId, null, DateTime.now().minusDays(1)); UserEntity initiator = givenUserEntity(userId); IdeasCampaignEntity.newIdeasCampaign(cmd, initiator); }
@Test(expected = IllegalArgumentException.class) public void newIdeasCampaigns_ShouldThrowOnEmptyEndDate() { final String userId = "test_userId"; IdeasCampaign cmd = givenIdeasCampaignCmd(userId, DateTime.now().plusDays(3), null); UserEntity initiator = givenUserEntity(userId); IdeasCampaignEntity.newIdeasCampaign(cmd, initiator); }