Search in sources :

Example 1 with SessionUpdateService

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();
}
Also used : AccountSummary(org.sagebionetworks.bridge.models.accounts.AccountSummary) SessionUpdateService(org.sagebionetworks.bridge.services.SessionUpdateService) DynamoApp(org.sagebionetworks.bridge.dynamodb.DynamoApp) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) NotificationTopicService(org.sagebionetworks.bridge.services.NotificationTopicService) StudyParticipant(org.sagebionetworks.bridge.models.accounts.StudyParticipant) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with SessionUpdateService

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();
}
Also used : ViewCache(org.sagebionetworks.bridge.cache.ViewCache) SessionUpdateService(org.sagebionetworks.bridge.services.SessionUpdateService) DynamoApp(org.sagebionetworks.bridge.dynamodb.DynamoApp) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) StudyParticipant(org.sagebionetworks.bridge.models.accounts.StudyParticipant) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with SessionUpdateService

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());
}
Also used : SessionUpdateService(org.sagebionetworks.bridge.services.SessionUpdateService) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) ConsentService(org.sagebionetworks.bridge.services.ConsentService) NotificationTopicService(org.sagebionetworks.bridge.services.NotificationTopicService) StudyParticipant(org.sagebionetworks.bridge.models.accounts.StudyParticipant) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with SessionUpdateService

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();
}
Also used : SessionUpdateService(org.sagebionetworks.bridge.services.SessionUpdateService) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) StudyParticipant(org.sagebionetworks.bridge.models.accounts.StudyParticipant) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

StudyParticipant (org.sagebionetworks.bridge.models.accounts.StudyParticipant)4 UserSession (org.sagebionetworks.bridge.models.accounts.UserSession)4 SessionUpdateService (org.sagebionetworks.bridge.services.SessionUpdateService)4 BeforeMethod (org.testng.annotations.BeforeMethod)4 DynamoApp (org.sagebionetworks.bridge.dynamodb.DynamoApp)2 NotificationTopicService (org.sagebionetworks.bridge.services.NotificationTopicService)2 ViewCache (org.sagebionetworks.bridge.cache.ViewCache)1 AccountSummary (org.sagebionetworks.bridge.models.accounts.AccountSummary)1 ConsentService (org.sagebionetworks.bridge.services.ConsentService)1