@Test public void shouldDeleteCampaignRecords() { CampaignRecord campaign = createCampaignRecord(); campaignRecordService.create(campaign); assertEquals(campaign, campaignRecordService.findByName(campaign.getName())); campaignRecordService.delete(campaign); assertNull(campaignRecordService.findByName(campaign.getName())); }
@Test public void shouldUpdateRecord() { CampaignRecord campaign = createCampaignRecord(); CampaignRecord campaign2 = createCampaignRecord(); // add campaignRecordService.create(campaign); assertEquals(campaign, campaignRecordService.findByName(campaign.getName())); // update campaign2.setMaxDuration("20 week"); campaign.updateFrom(campaign2); campaign = campaignRecordService.update(campaign); assertEquals( campaign.getMaxDuration(), campaignRecordService.findByName(campaign.getName()).getMaxDuration()); campaignRecordService.delete(campaign); }
@Test public void getCronBasedMessageProgramTest() { String campaignName = "Cron based Message Program"; CronBasedCampaign campaign = (CronBasedCampaign) campaignRecordService.findByName(campaignName).toCampaign(); assertNotNull(campaign); assertEquals(campaignName, campaign.getName()); assertEquals(new JodaFormatter().parsePeriod("5 years"), campaign.getMaxDuration()); List<CronBasedCampaignMessage> messages = campaign.getMessages(); assertEquals(1, messages.size()); assertMessageWithCronSchedule( messages.get(0), "First", new String[] {"IVR", "SMS"}, "cron-message", "0 11 11 11 11 ?"); }
@Test public void getRelativeDatesMessageProgramTest() { String campaignName = "Relative Dates Message Program"; OffsetCampaign campaign = (OffsetCampaign) campaignRecordService.findByName(campaignName).toCampaign(); assertNotNull(campaign); assertEquals(campaignName, campaign.getName()); List<OffsetCampaignMessage> messages = campaign.getMessages(); assertEquals(3, messages.size()); assertMessageWithRelativeSchedule( messages.get(0), "Week 1", new String[] {"IVR"}, "child-info-week-1", "1 Week"); assertMessageWithRelativeSchedule( messages.get(1), "Week 1A", new String[] {"SMS"}, "child-info-week-1a", "1 Week"); assertMessageWithRelativeSchedule( messages.get(2), "Week 1B", new String[] {"SMS"}, "child-info-week-1b", "9 Days"); }
@Test public void getAbsoluteDatesMessageProgramTest() { String campaignName = "Absolute Dates Message Program"; AbsoluteCampaign campaign = (AbsoluteCampaign) campaignRecordService.findByName(campaignName).toCampaign(); assertNotNull(campaign); assertEquals(campaignName, campaign.getName()); List<AbsoluteCampaignMessage> messages = campaign.getMessages(); assertEquals(2, messages.size()); DateTime firstDate = new DateTime(2013, 6, 15, 0, 0, 0, 0); DateTime secondDate = new DateTime(2013, 6, 22, 0, 0, 0, 0); assertMessageWithAbsoluteSchedule( messages.get(0), "First", new String[] {"IVR", "SMS"}, "random-1", firstDate.toLocalDate()); assertMessageWithAbsoluteSchedule( messages.get(1), "Second", new String[] {"IVR"}, "random-2", secondDate.toLocalDate()); }
@Test public void shouldFindCampaignsByName() { CampaignRecord campaign = createCampaignRecord(); CampaignRecord campaign2 = createCampaignRecord(); campaign2.setName("Different Name"); campaignRecordService.create(campaign); campaignRecordService.create(campaign2); assertEquals(campaign, campaignRecordService.findByName("CampaignName")); assertEquals(campaign2, campaignRecordService.findByName("Different Name")); campaignRecordService.delete(campaign); campaignRecordService.delete(campaign2); }