NotificationServiceImpl implements NotificationService { @Override public boolean checkConsentSignedStatus(Set<Consent> consents) { if (consents.size() == 0) return false; for (Consent consent : consents) { if (consent.getSignedPdfConsent() != null) { if (consent.getSignedPdfConsent().getSignedPdfConsentContent() != null) return true; } } return false; } NotificationServiceImpl(PatientRepository patientRepository); @Override String notificationStage(String username, String notify); @Override boolean checkConsentReviewStatus(Set<Consent> consents); @Override boolean checkConsentSignedStatus(Set<Consent> consents); @Override String notificationValuesetMgmt(String username, String notify,
			String message);  }
@Test public void testcheckConsentSignedStatus_when_consent_size_0() { Set<Consent> consents = new HashSet<Consent>(); boolean result = nst.checkConsentSignedStatus(consents); assertEquals(false, result); }
@Test public void testcheckConsentSignedStatus_when_consent_has_not_reviewed() { Set<Consent> consents = new HashSet<Consent>(); Consent consent = mock(Consent.class); consents.add(consent); when(consent.getSignedPdfConsent()).thenReturn(null); boolean result = nst.checkConsentSignedStatus(consents); assertEquals(false, result); }
@Test public void testcheckConsentSignedStatus_when_consent_has_reviewed_not_signed() { Set<Consent> consents = new HashSet<Consent>(); Consent consent = mock(Consent.class); SignedPDFConsent signedPdfConsent = mock(SignedPDFConsent.class); consents.add(consent); when(consent.getSignedPdfConsent()).thenReturn(signedPdfConsent); when(consent.getSignedPdfConsent().getSignedPdfConsentContent()) .thenReturn(null); boolean result = nst.checkConsentSignedStatus(consents); assertEquals(false, result); }
@Test public void testcheckConsentSignedStatus_when_consent_has_reviewed_signed() { Set<Consent> consents = new HashSet<Consent>(); Consent consent = mock(Consent.class); SignedPDFConsent signedPdfConsent = mock(SignedPDFConsent.class); byte[] signedPdfConsentContent = new byte[] { (byte) 0xba, (byte) 0x8a, }; consents.add(consent); when(consent.getSignedPdfConsent()).thenReturn(signedPdfConsent); when(consent.getSignedPdfConsent().getSignedPdfConsentContent()) .thenReturn(signedPdfConsentContent); boolean result = nst.checkConsentSignedStatus(consents); assertEquals(true, result); }