Source:
private void signInNewSession(boolean isConsented, Roles role) throws Exception { doReturn(null).when(controller).getSessionToken(); doReturn(TEST_CONTEXT).when(controller).getCriteriaContext(any(StudyIdentifier.class)); String requestJsonString = "{\n" + " \"email\":\"" + TEST_EMAIL + "\",\n" + " \"password\":\"" + TEST_PASSWORD + "\",\n" + " \"study\":\"" + TEST_STUDY_ID_STRING + "\"\n" + "}"; response = TestUtils.mockPlayContextWithJson(requestJsonString); ConsentStatus consentStatus = (isConsented) ? TestConstants.REQUIRED_SIGNED_CURRENT : null; UserSession session = createSession(consentStatus, role); ArgumentCaptor<SignIn> signInCaptor = ArgumentCaptor.forClass(SignIn.class); when(authenticationService.signIn(same(study), any(), signInCaptor.capture())).thenReturn(session); Result result = controller.signInV3(); assertSessionInPlayResult(result); Http.Response mockResponse = controller.response(); verify(cacheProvider).updateRequestInfo(requestInfoCaptor.capture()); verify(mockResponse).setCookie(BridgeConstants.SESSION_TOKEN_HEADER, session.getSessionToken(), BridgeConstants.BRIDGE_SESSION_EXPIRE_IN_SECONDS, "/", BridgeConfigFactory.getConfig().get("webservices.url"), false, false); RequestInfo requestInfo = requestInfoCaptor.getValue(); assertEquals("spId", requestInfo.getUserId()); assertEquals(TEST_STUDY_ID, requestInfo.getStudyIdentifier()); assertTrue(requestInfo.getSignedInOn() != null); assertEquals(TestConstants.USER_DATA_GROUPS, requestInfo.getUserDataGroups()); assertNotNull(requestInfo.getSignedInOn()); verifyCommonLoggingForSignIns(); SignIn signIn = signInCaptor.getValue(); assertEquals(TEST_EMAIL, signIn.getEmail()); assertEquals(TEST_PASSWORD, signIn.getPassword()); }

Target:
private void signInNewSession(boolean isConsented, Roles role) throws Exception { doReturn(null).when(controller).getSessionToken(); doReturn(TEST_CONTEXT).when(controller).getCriteriaContext(any(StudyIdentifier.class)); String requestJsonString = "{\n" + " \"email\":\"" + TEST_EMAIL + "\",\n" + " \"password\":\"" + TEST_PASSWORD + "\",\n" + " \"study\":\"" + TEST_STUDY_ID_STRING + "\"\n" + "}"; response = TestUtils.mockPlayContextWithJson(requestJsonString); ConsentStatus consentStatus = (isConsented) ? TestConstants.REQUIRED_SIGNED_CURRENT : null; UserSession session = createSession(consentStatus, role); ArgumentCaptor<SignIn> signInCaptor = ArgumentCaptor.forClass(SignIn.class); when(authenticationService.signIn(same(study), any(), signInCaptor.capture())).thenReturn(session); Result result = controller.signInV3(); assertSessionInPlayResult(result); Http.Response mockResponse = controller.response(); verify(cacheProvider).updateRequestInfo(requestInfoCaptor.capture()); RequestInfo requestInfo = requestInfoCaptor.getValue(); assertEquals("spId", requestInfo.getUserId()); assertEquals(TEST_STUDY_ID, requestInfo.getStudyIdentifier()); assertTrue(requestInfo.getSignedInOn() != null); assertEquals(TestConstants.USER_DATA_GROUPS, requestInfo.getUserDataGroups()); assertNotNull(requestInfo.getSignedInOn()); verifyCommonLoggingForSignIns(); SignIn signIn = signInCaptor.getValue(); assertEquals(TEST_EMAIL, signIn.getEmail()); assertEquals(TEST_PASSWORD, signIn.getPassword()); }