use of org.sagebionetworks.bridge.models.GuidHolder in project BridgeServer2 by Sage-Bionetworks.
the class NotificationRegistrationControllerTest method createRegistration.
@Test
public void createRegistration() throws Exception {
// Mock service.
doReturn(createRegList().get(0)).when(mockNotificationService).createRegistration(any(), any(), any());
// Mock Play context.
String json = TestUtils.createJson("{'deviceId':'" + DEVICE_ID + "','osName':'" + OS_NAME + "'}");
mockRequestBody(mockRequest, json);
// Execute and validate.
GuidHolder result = controller.createRegistration();
assertEquals(result.getGuid(), GUID);
// Verify service.
verify(mockNotificationService).createRegistration(eq(TEST_APP_ID), any(), registrationCaptor.capture());
NotificationRegistration registration = registrationCaptor.getValue();
assertEquals(registration.getDeviceId(), DEVICE_ID);
assertEquals(registration.getOsName(), OS_NAME);
assertEquals(registration.getHealthCode(), HEALTH_CODE);
}
use of org.sagebionetworks.bridge.models.GuidHolder in project BridgeServer2 by Sage-Bionetworks.
the class NotificationRegistrationControllerTest method updateRegistration.
@Test
public void updateRegistration() throws Exception {
doReturn(createRegList().get(0)).when(mockNotificationService).updateRegistration(any(), any());
String json = TestUtils.createJson("{'guid':'guidWeIgnore','deviceId':'NEW_DEVICE_ID','osName':'" + OS_NAME + "'}");
mockRequestBody(mockRequest, json);
GuidHolder result = controller.updateRegistration(GUID);
assertEquals(result.getGuid(), GUID);
verify(mockNotificationService).updateRegistration(eq(TEST_APP_ID), registrationCaptor.capture());
NotificationRegistration registration = registrationCaptor.getValue();
assertEquals(registration.getDeviceId(), "NEW_DEVICE_ID");
assertEquals(registration.getOsName(), OS_NAME);
assertEquals(registration.getHealthCode(), HEALTH_CODE);
assertEquals(registration.getGuid(), GUID);
}
use of org.sagebionetworks.bridge.models.GuidHolder in project BridgeServer2 by Sage-Bionetworks.
the class NotificationTopicControllerTest method createTopic.
@Test
public void createTopic() throws Exception {
doReturn(mockUserSession).when(controller).getAuthenticatedSession(DEVELOPER);
NotificationTopic topic = getNotificationTopic();
mockRequestBody(mockRequest, topic);
doReturn(topic).when(mockTopicService).createTopic(any());
GuidHolder result = controller.createTopic();
assertEquals(result.getGuid(), GUID);
verify(mockTopicService).createTopic(topicCaptor.capture());
NotificationTopic captured = topicCaptor.getValue();
assertEquals(captured.getName(), topic.getName());
}
use of org.sagebionetworks.bridge.models.GuidHolder in project BridgeServer2 by Sage-Bionetworks.
the class NotificationTopicController method createTopic.
@PostMapping("/v3/topics")
@ResponseStatus(HttpStatus.CREATED)
public GuidHolder createTopic() {
UserSession session = getAuthenticatedSession(DEVELOPER);
NotificationTopic topic = parseJson(NotificationTopic.class);
topic.setAppId(session.getAppId());
NotificationTopic saved = topicService.createTopic(topic);
return new GuidHolder(saved.getGuid());
}
use of org.sagebionetworks.bridge.models.GuidHolder in project BridgeServer2 by Sage-Bionetworks.
the class NotificationTopicControllerTest method updateTopic.
@Test
public void updateTopic() throws Exception {
doReturn(mockUserSession).when(controller).getAuthenticatedSession(DEVELOPER);
NotificationTopic topic = getNotificationTopic();
doReturn(topic).when(mockTopicService).updateTopic(any());
mockRequestBody(mockRequest, topic);
GuidHolder result = controller.updateTopic(GUID);
assertEquals(result.getGuid(), GUID);
verify(mockTopicService).updateTopic(topicCaptor.capture());
NotificationTopic returned = topicCaptor.getValue();
assertEquals(returned.getName(), topic.getName());
assertEquals(returned.getGuid(), GUID);
}
Aggregations