### Question:
JobSimpleTriggerMapper extends BaseTriggerMapper { @Override public void mapEntityOnForm(JobForm.Builder form, JobFormEntity entity) { mapCommonEntityTriggerFieldsOnEntity(form, entity); JobSimpleTriggerEntity simpleTrigger = entity.getSimpleTrigger(); int occurrenceCount = simpleTrigger.getOccurrenceCount(); Integer recurrenceInterval = simpleTrigger.getRecurrenceInterval(); String recurrenceIntervalUnit = simpleTrigger.getRecurrenceIntervalUnit(); Date endDate = null; String endDateString = simpleTrigger.getEndDate(); if (endDateString != null) { endDate = parseDate(endDateString); } IntervalRecurrence recurrence = new IntervalRecurrence.Builder() .withInterval(recurrenceInterval) .withUnit(RecurrenceIntervalUnit.valueOf(recurrenceIntervalUnit)) .build(); Trigger.SimpleTriggerBuilder triggerBuilder = new Trigger.Builder() .withCalendarName(simpleTrigger.getCalendarName()) .withRecurrence(recurrence); if (occurrenceCount < 0 && endDate != null) { triggerBuilder.withEndDate(new UntilEndDate(endDate)); } else { triggerBuilder.withEndDate(new RepeatedEndDate(occurrenceCount)); } Trigger trigger = triggerBuilder.build(); form.withTrigger(trigger); }  @Override void mapFormOnEntity(JobForm form, JobFormEntity entity); @Override void mapEntityOnForm(JobForm.Builder form, JobFormEntity entity);  }### Answer:
@Test public void should_map_simple_trigger_with_occurrence_count() throws Exception { JobSimpleTriggerEntity simpleTrigger = new JobSimpleTriggerEntity(); simpleTrigger.setOccurrenceCount(1); simpleTrigger.setRecurrenceIntervalUnit("DAY"); simpleTrigger.setCalendarName("Gregorian"); simpleTrigger.setRecurrenceInterval(100); formEntity.setSimpleTrigger(simpleTrigger); JobForm.Builder formBuilder = formFactory.givenJobFormBuilderWithValues(); mapperUnderTest.mapEntityOnForm(formBuilder, formEntity); JobForm expected = formBuilder.build(); Trigger trigger = expected.getTrigger(); IntervalRecurrence recurrence = (IntervalRecurrence) trigger.getRecurrence(); RepeatedEndDate endDate = (RepeatedEndDate) trigger.getEndDate(); assertThat(recurrence.getInterval(), is(100)); assertThat(recurrence.getUnit(), is(RecurrenceIntervalUnit.DAY)); assertThat(endDate.getOccurrenceCount(), is(1)); }
@Test public void should_map_simple_trigger_with_end_date() throws Exception { JobSimpleTriggerEntity simpleTrigger = new JobSimpleTriggerEntity(); simpleTrigger.setOccurrenceCount(-1); simpleTrigger.setRecurrenceInterval(1); simpleTrigger.setRecurrenceIntervalUnit("DAY"); simpleTrigger.setEndDate(formFactory.provideEndDateSrc()); formEntity.setSimpleTrigger(simpleTrigger); JobForm.Builder formBuilder = formFactory.givenJobFormBuilderWithValues(); mapperUnderTest.mapEntityOnForm(formBuilder, formEntity); JobForm expected = formBuilder.build(); Trigger trigger = expected.getTrigger(); IntervalRecurrence recurrence = (IntervalRecurrence) trigger.getRecurrence(); UntilEndDate endDate = (UntilEndDate) trigger.getEndDate(); assertThat(recurrence.getInterval(), is(1)); assertThat(recurrence.getUnit(), is(RecurrenceIntervalUnit.DAY)); assertThat(endDate.getSpecifiedDate(), is(formFactory.provideEndDate())); }