use of org.sagebionetworks.bridge.models.templates.TemplateRevision in project BridgeServer2 by Sage-Bionetworks.
the class IntentServiceTest method submitIntentToParticipateWithEmail.
@Test
public void submitIntentToParticipateWithEmail() throws Exception {
IntentToParticipate intent = TestUtils.getIntentToParticipate(TIMESTAMP).withPhone(null).withOsName("iOS").withEmail("email@email.com").build();
Map<String, String> installLinks = Maps.newHashMap();
installLinks.put("iOS", "this-is-a-link");
installLinks.put("Android", "the-wrong-link");
when(mockApp.getIdentifier()).thenReturn(TEST_APP_ID);
when(mockApp.getInstallLinks()).thenReturn(installLinks);
when(mockAppService.getApp(intent.getAppId())).thenReturn(mockApp);
TemplateRevision revision = TemplateRevision.create();
revision.setSubject("subject");
revision.setDocumentContent("body ${appInstallUrl}");
revision.setMimeType(HTML);
when(mockTemplateService.getRevisionForUser(mockApp, EMAIL_APP_INSTALL_LINK)).thenReturn(revision);
CacheKey cacheKey = CacheKey.itp(SubpopulationGuid.create("subpopGuid"), TEST_APP_ID, "email@email.com");
service.submitIntentToParticipate(intent);
verify(mockSubpopService).getSubpopulation(eq(TEST_APP_ID), subpopGuidCaptor.capture());
assertEquals(subpopGuidCaptor.getValue().getGuid(), intent.getSubpopGuid());
verify(mockCacheProvider).setObject(keyCaptor.capture(), eq(intent), eq(4 * 60 * 60));
assertEquals(keyCaptor.getValue(), cacheKey);
verify(mockParticipantService).sendInstallLinkMessage(mockApp, TRANSACTIONAL, null, "email@email.com", null, "iPhone OS");
}
use of org.sagebionetworks.bridge.models.templates.TemplateRevision in project BridgeServer2 by Sage-Bionetworks.
the class ConsentServiceTest method resendConsentAgreementWithPhoneOK.
@Test
public void resendConsentAgreementWithPhoneOK() throws Exception {
doReturn("asdf.pdf").when(consentService).getSignedConsentUrl();
account.setConsentSignatureHistory(SUBPOP_GUID, ImmutableList.of(CONSENT_SIGNATURE));
TemplateRevision revision = TemplateRevision.create();
revision.setDocumentContent("some test content");
when(templateService.getRevisionForUser(app, TemplateType.SMS_SIGNED_CONSENT)).thenReturn(revision);
consentService.resendConsentAgreement(app, SUBPOP_GUID, PHONE_PARTICIPANT);
verify(smsService).sendSmsMessage(eq(ID), smsProviderCaptor.capture());
ArgumentCaptor<ObjectMetadata> metadataCaptor = ArgumentCaptor.forClass(ObjectMetadata.class);
verify(s3Helper).writeBytesToS3(eq(ConsentService.USERSIGNED_CONSENTS_BUCKET), eq("asdf.pdf"), any(), metadataCaptor.capture());
assertEquals(metadataCaptor.getValue().getSSEAlgorithm(), ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
SmsMessageProvider provider = smsProviderCaptor.getValue();
assertEquals(provider.getPhone(), PHONE_PARTICIPANT.getPhone());
assertEquals(provider.getApp(), app);
assertEquals(provider.getSmsType(), "Transactional");
assertEquals(provider.getTokenMap().get("consentUrl"), SHORT_URL);
assertEquals(provider.getTemplateRevision().getDocumentContent(), revision.getDocumentContent());
}
use of org.sagebionetworks.bridge.models.templates.TemplateRevision in project BridgeServer2 by Sage-Bionetworks.
the class TemplateRevisionValidatorTest method valid.
@Test
public void valid() {
TemplateRevision revision = createValidTemplate();
Validate.entityThrowingException(INSTANCE, revision);
}
use of org.sagebionetworks.bridge.models.templates.TemplateRevision in project BridgeServer2 by Sage-Bionetworks.
the class TemplateRevisionValidatorTest method validateStoragePath.
@Test
public void validateStoragePath() {
TemplateRevision revision = createValidTemplate();
revision.setStoragePath(null);
assertValidatorMessage(INSTANCE, revision, "storagePath", "cannot be blank");
}
use of org.sagebionetworks.bridge.models.templates.TemplateRevision in project BridgeServer2 by Sage-Bionetworks.
the class TemplateRevisionValidatorTest method validateCreatedOn.
@Test
public void validateCreatedOn() {
TemplateRevision revision = createValidTemplate();
revision.setCreatedOn(null);
assertValidatorMessage(INSTANCE, revision, "createdOn", "cannot be null");
}
Aggregations