use of org.sagebionetworks.bridge.services.SessionUpdateService in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantControllerTest method before.
@BeforeMethod
public void before() throws Exception {
MockitoAnnotations.initMocks(this);
app = new DynamoApp();
app.setUserProfileAttributes(Sets.newHashSet("foo", "baz"));
app.setIdentifier(TEST_APP_ID);
participant = new StudyParticipant.Builder().withRoles(CALLER_ROLES).withStudyIds(CALLER_STUDIES).withId(TEST_USER_ID).build();
session = new UserSession(participant);
session.setAuthenticated(true);
session.setAppId(TEST_APP_ID);
doAnswer((ans) -> {
RequestContext.updateFromSession(session, mockSponsorService);
return session;
}).when(controller).getSessionIfItExists();
when(mockAppService.getApp(TEST_APP_ID)).thenReturn(app);
List<AccountSummary> summaries = ImmutableList.of(SUMMARY1, SUMMARY1, SUMMARY1);
PagedResourceList<AccountSummary> page = new PagedResourceList<>(summaries, 30).withRequestParam("offsetBy", 10).withRequestParam("pageSize", 20).withRequestParam("startTime", START_TIME).withRequestParam("endTime", END_TIME).withRequestParam("emailFilter", "foo");
when(mockParticipantService.getPagedAccountSummaries(eq(app), any())).thenReturn(page);
SessionUpdateService sessionUpdateService = new SessionUpdateService();
sessionUpdateService.setCacheProvider(mockCacheProvider);
sessionUpdateService.setConsentService(mockConsentService);
sessionUpdateService.setNotificationTopicService(mock(NotificationTopicService.class));
controller.setSessionUpdateService(sessionUpdateService);
doReturn(mockRequest).when(controller).request();
doReturn(mockResponse).when(controller).response();
}
use of org.sagebionetworks.bridge.services.SessionUpdateService in project BridgeServer2 by Sage-Bionetworks.
the class UserProfileControllerTest method before.
@BeforeMethod
public void before() {
MockitoAnnotations.initMocks(this);
app = new DynamoApp();
app.setIdentifier(TEST_APP_ID);
app.setDataGroups(USER_DATA_GROUPS);
app.setUserProfileAttributes(TEST_STUDY_ATTRIBUTES);
when(mockConsentService.getConsentStatuses(any())).thenReturn(CONSENT_STATUSES_MAP);
when(mockAppService.getApp((String) any())).thenReturn(app);
ViewCache viewCache = new ViewCache();
viewCache.setCachePeriod(BRIDGE_VIEW_EXPIRE_IN_SECONDS);
viewCache.setObjectMapper(BridgeObjectMapper.get());
viewCache.setCacheProvider(mockCacheProvider);
controller.setViewCache(viewCache);
SessionUpdateService sessionUpdateService = new SessionUpdateService();
sessionUpdateService.setCacheProvider(mockCacheProvider);
sessionUpdateService.setConsentService(mockConsentService);
sessionUpdateService.setNotificationTopicService(mockNotificationTopicService);
controller.setSessionUpdateService(sessionUpdateService);
session = new UserSession(new StudyParticipant.Builder().withHealthCode(HEALTH_CODE).withId(TEST_USER_ID).build());
session.setAppId(TEST_APP_ID);
doReturn(session).when(controller).getAuthenticatedSession();
doReturn(mockRequest).when(controller).request();
doReturn(mockResponse).when(controller).response();
}
use of org.sagebionetworks.bridge.services.SessionUpdateService in project BridgeServer2 by Sage-Bionetworks.
the class AccountsControllerTest method beforeMethod.
@BeforeMethod
public void beforeMethod() {
MockitoAnnotations.initMocks(this);
doReturn(mockRequest).when(controller).request();
SessionUpdateService sessionUpdateService = new SessionUpdateService();
sessionUpdateService.setCacheProvider(mockCacheProvider);
sessionUpdateService.setConsentService(mock(ConsentService.class));
sessionUpdateService.setNotificationTopicService(mock(NotificationTopicService.class));
controller.setSessionUpdateService(sessionUpdateService);
app = App.create();
when(mockAppService.getApp(TEST_APP_ID)).thenReturn(app);
account = Account.create();
session = new UserSession();
session.setAppId(TEST_APP_ID);
session.setParticipant(new StudyParticipant.Builder().withOrgMembership(TEST_ORG_ID).build());
}
use of org.sagebionetworks.bridge.services.SessionUpdateService in project BridgeServer2 by Sage-Bionetworks.
the class UserManagementControllerTest method before.
@BeforeMethod
public void before() throws Exception {
MockitoAnnotations.initMocks(this);
StudyParticipant participant = new StudyParticipant.Builder().withHealthCode(HEALTH_CODE).withId(TEST_USER_ID).withRoles(ImmutableSet.of(SUPERADMIN)).withEmail(EMAIL).build();
session = new UserSession(participant);
session.setAppId(TEST_APP_ID);
session.setAuthenticated(true);
sessionUpdateService = new SessionUpdateService();
sessionUpdateService.setCacheProvider(mockCacheProvider);
controller.setSessionUpdateService(sessionUpdateService);
doReturn(session).when(mockUserAdminService).createUser(any(), any(), any(), anyBoolean(), anyBoolean());
doReturn(session).when(mockAuthService).getSession(any(String.class));
doReturn(mockApp).when(mockAppService).getApp(TEST_APP_ID);
when(mockApp.getIdentifier()).thenReturn(TEST_APP_ID);
doReturn(null).when(controller).getMetrics();
doReturn(mockRequest).when(controller).request();
doReturn(mockResponse).when(controller).response();
}
Aggregations