コード例 #1
0
  @Test
  public void shouldDeleteCampaignRecords() {

    CampaignRecord campaign = createCampaignRecord();

    campaignRecordService.create(campaign);

    assertEquals(campaign, campaignRecordService.findByName(campaign.getName()));

    campaignRecordService.delete(campaign);

    assertNull(campaignRecordService.findByName(campaign.getName()));
  }
コード例 #2
0
  @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);
  }
コード例 #3
0
  private CampaignRecord createCampaignRecord() {
    CampaignRecord campaign = new CampaignRecord();
    campaign.setCampaignType(CampaignType.ABSOLUTE);
    campaign.setMaxDuration("10 week");
    campaign.setName("CampaignName");

    CampaignMessageRecord message = new CampaignMessageRecord();
    message.setDate(LocalDate.now());
    message.setMessageType(CampaignType.ABSOLUTE);
    message.setStartTime("20:44");
    message.setMessageKey("key");
    message.setLanguages(new ArrayList<>(asList("lang1", "lang2", "lang3")));

    campaign.setMessages(new ArrayList<>(asList(message)));

    return campaign;
  }
コード例 #4
0
  @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);
  }