Search in sources :

Example 1 with NotificationRegistration

use of org.sagebionetworks.bridge.models.notifications.NotificationRegistration in project BridgeServer2 by Sage-Bionetworks.

the class TestUtils method getNotificationRegistration.

public static NotificationRegistration getNotificationRegistration() {
    NotificationRegistration registration = NotificationRegistration.create();
    registration.setDeviceId("deviceId");
    registration.setEndpoint("endpoint");
    registration.setGuid("registrationGuid");
    registration.setHealthCode("healthCode");
    registration.setOsName("osName");
    registration.setCreatedOn(1484173675648L);
    return registration;
}
Also used : NotificationRegistration(org.sagebionetworks.bridge.models.notifications.NotificationRegistration)

Example 2 with NotificationRegistration

use of org.sagebionetworks.bridge.models.notifications.NotificationRegistration in project BridgeServer2 by Sage-Bionetworks.

the class NotificationsServiceTest method serviceFixesSynonymOsNamesOnCreate.

@Test
public void serviceFixesSynonymOsNamesOnCreate() {
    NotificationRegistration registration = getNotificationRegistration();
    registration.setOsName("iOS");
    doReturn(registration).when(mockRegistrationDao).createPushNotificationRegistration(PLATFORM_ARN, registration);
    NotificationRegistration result = service.createRegistration(TEST_APP_ID, DUMMY_CONTEXT, registration);
    assertEquals(result.getOsName(), OperatingSystem.IOS);
}
Also used : NotificationRegistration(org.sagebionetworks.bridge.models.notifications.NotificationRegistration) TestUtils.getNotificationRegistration(org.sagebionetworks.bridge.TestUtils.getNotificationRegistration) Test(org.testng.annotations.Test)

Example 3 with NotificationRegistration

use of org.sagebionetworks.bridge.models.notifications.NotificationRegistration in project BridgeServer2 by Sage-Bionetworks.

the class NotificationsServiceTest method createRegistration_PushNotification.

@Test
public void createRegistration_PushNotification() {
    // Mock registration DAO.
    NotificationRegistration registration = getNotificationRegistration();
    registration.setHealthCode(HEALTH_CODE);
    registration.setOsName(OS_NAME);
    doReturn(registration).when(mockRegistrationDao).createPushNotificationRegistration(PLATFORM_ARN, registration);
    // Execute and validate.
    NotificationRegistration result = service.createRegistration(TEST_APP_ID, DUMMY_CONTEXT, registration);
    verify(mockRegistrationDao).createPushNotificationRegistration(PLATFORM_ARN, registration);
    assertEquals(result, registration);
    // We also manage criteria-based topics.
    verify(mockNotificationTopicService).manageCriteriaBasedSubscriptions(TEST_APP_ID, DUMMY_CONTEXT, HEALTH_CODE);
}
Also used : NotificationRegistration(org.sagebionetworks.bridge.models.notifications.NotificationRegistration) TestUtils.getNotificationRegistration(org.sagebionetworks.bridge.TestUtils.getNotificationRegistration) Test(org.testng.annotations.Test)

Example 4 with NotificationRegistration

use of org.sagebionetworks.bridge.models.notifications.NotificationRegistration in project BridgeServer2 by Sage-Bionetworks.

the class NotificationsServiceTest method updateRegistration.

@Test
public void updateRegistration() {
    NotificationRegistration registration = getNotificationRegistration();
    registration.setOsName(OS_NAME);
    doReturn(registration).when(mockRegistrationDao).updateRegistration(registration);
    NotificationRegistration result = service.updateRegistration(TEST_APP_ID, registration);
    verify(mockRegistrationDao).updateRegistration(registration);
    assertEquals(result, registration);
}
Also used : NotificationRegistration(org.sagebionetworks.bridge.models.notifications.NotificationRegistration) TestUtils.getNotificationRegistration(org.sagebionetworks.bridge.TestUtils.getNotificationRegistration) Test(org.testng.annotations.Test)

Example 5 with NotificationRegistration

use of org.sagebionetworks.bridge.models.notifications.NotificationRegistration in project BridgeServer2 by Sage-Bionetworks.

the class NotificationsServiceTest method throwsUnimplementedExceptionIfPlatformHasNoARN.

@Test(expectedExceptions = NotImplementedException.class)
public void throwsUnimplementedExceptionIfPlatformHasNoARN() {
    NotificationRegistration registration = getNotificationRegistration();
    registration.setOsName(OperatingSystem.ANDROID);
    service.createRegistration(TEST_APP_ID, DUMMY_CONTEXT, registration);
}
Also used : NotificationRegistration(org.sagebionetworks.bridge.models.notifications.NotificationRegistration) TestUtils.getNotificationRegistration(org.sagebionetworks.bridge.TestUtils.getNotificationRegistration) Test(org.testng.annotations.Test)

Aggregations

NotificationRegistration (org.sagebionetworks.bridge.models.notifications.NotificationRegistration)61 Test (org.testng.annotations.Test)39 TestUtils.getNotificationRegistration (org.sagebionetworks.bridge.TestUtils.getNotificationRegistration)32 NotificationTopic (org.sagebionetworks.bridge.models.notifications.NotificationTopic)11 AmazonServiceException (com.amazonaws.AmazonServiceException)7 TestUtils.getNotificationTopic (org.sagebionetworks.bridge.TestUtils.getNotificationTopic)7 PublishRequest (com.amazonaws.services.sns.model.PublishRequest)4 Mockito.anyString (org.mockito.Mockito.anyString)4 GuidHolder (org.sagebionetworks.bridge.models.GuidHolder)4 StudyParticipant (org.sagebionetworks.bridge.models.accounts.StudyParticipant)4 UserSession (org.sagebionetworks.bridge.models.accounts.UserSession)4 NotificationMessage (org.sagebionetworks.bridge.models.notifications.NotificationMessage)4 TopicSubscription (org.sagebionetworks.bridge.models.notifications.TopicSubscription)4 SubscribeRequest (com.amazonaws.services.sns.model.SubscribeRequest)3 TestUtils.getNotificationMessage (org.sagebionetworks.bridge.TestUtils.getNotificationMessage)3 BadRequestException (org.sagebionetworks.bridge.exceptions.BadRequestException)3 CriteriaContext (org.sagebionetworks.bridge.models.CriteriaContext)3 ResourceList (org.sagebionetworks.bridge.models.ResourceList)3 App (org.sagebionetworks.bridge.models.apps.App)3 AmazonSNSClient (com.amazonaws.services.sns.AmazonSNSClient)2