EligibleCoupleService { public void register(FormSubmission submission) { if (isNotBlank(submission.getFieldValue(AllConstants.CommonFormFields.SUBMISSION_DATE))) { allTimelineEvents.add(TimelineEvent.forECRegistered(submission.entityId(), submission.getFieldValue(AllConstants.CommonFormFields.SUBMISSION_DATE))); } } EligibleCoupleService(AllEligibleCouples allEligibleCouples, AllTimelineEvents allTimelineEvents, AllBeneficiaries allBeneficiaries); void register(FormSubmission submission); void fpComplications(FormSubmission submission); void fpChange(FormSubmission submission); void renewFPProduct(FormSubmission submission); void closeEligibleCouple(FormSubmission submission);  }
@Test public void shouldCreateTimelineEventWhenECIsRegistered() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("submissionDate")).thenReturn("2012-01-01"); service.register(submission); verify(allTimelineEvents).add(TimelineEvent.forECRegistered("entity id 1", "2012-01-01")); }
@Test public void shouldNotCreateTimelineEventWhenECIsRegisteredWithoutSubmissionDate() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("submissionDate")).thenReturn(null); service.register(submission); verifyZeroInteractions(allTimelineEvents); }