### Question:
AISController implements AISApi { @Override public ResponseEntity<ConsentAuthorizeResponse> startConsentAuth(String encryptedConsentId, String authorisationId, String consentAndAccessTokenCookieString, AisConsentTO aisConsent) { String psuId = AuthUtils.psuId(middlewareAuth); ConsentWorkflow workflow; List<AccountDetailsTO> listOfAccounts; try { String consentCookie = responseUtils.consentCookie(consentAndAccessTokenCookieString); workflow = redirectConsentService.identifyConsent(encryptedConsentId, authorisationId, false, consentCookie, middlewareAuth.getBearerToken()); listOfAccounts = listOfAccounts(workflow); redirectConsentService.startConsent(workflow, aisConsent, listOfAccounts); redirectConsentService.updateScaStatusConsentStatusConsentData(psuId, workflow); } catch (ConsentAuthorizeException e) { return e.getError(); } return resolveResponseByScaStatus(workflow, false); }  @Override @ApiOperation(value = "Entry point for authenticating ais consent requests.") ResponseEntity<AuthorizeResponse> aisAuth(String redirectId, String encryptedConsentId, String token); @Override ResponseEntity<ConsentAuthorizeResponse> login(String encryptedConsentId, String authorisationId, String login, String pin, String consentCookieString); @Override ResponseEntity<ConsentAuthorizeResponse> startConsentAuth(String encryptedConsentId, String authorisationId, String consentAndAccessTokenCookieString, AisConsentTO aisConsent); @Override ResponseEntity<ConsentAuthorizeResponse> authrizedConsent(String encryptedConsentId, String authorisationId, String consentAndAccessTokenCookieString, String authCode); @Override ResponseEntity<ConsentAuthorizeResponse> selectMethod(String encryptedConsentId, String authorisationId, String scaMethodId, String consentAndAccessTokenCookieString); @Override ResponseEntity<List<AccountDetailsTO>> getListOfAccounts(String accessTokenCookieString); @Override ResponseEntity<ConsentAuthorizeResponse> aisDone(String encryptedConsentId, String authorisationId, String cookie, boolean isOauth2Integrated, String authConfirmationCode); @Override ResponseEntity<ConsentAuthorizeResponse> revokeConsent(@NotNull String encryptedConsentId, @NotNull String authorisationId, String cookieString);  }### Answer:
@Test void startConsentAuth() throws NoSuchFieldException { FieldSetter.setField(controller, controller.getClass().getDeclaredField("middlewareAuth"), new ObaMiddlewareAuthentication(null, new BearerTokenTO(TOKEN, null, 999, null, getAccessTokenTO()))); when(responseUtils.consentCookie(any())).thenReturn(COOKIE); when(redirectConsentService.identifyConsent(anyString(), anyString(), anyBoolean(), anyString(), any())).thenReturn(getConsentWorkflow(PSUIDENTIFIED, ConsentStatus.RECEIVED)); when(accountRestClient.getListOfAccounts()).thenReturn(ResponseEntity.ok(new ArrayList<>())); ResponseEntity<ConsentAuthorizeResponse> result = controller.startConsentAuth(ENCRYPTED_ID, AUTH_ID, COOKIE, getAisConsentTO(false)); assertEquals(ResponseEntity.ok(getConsentAuthorizeResponse(true, true, false, PSUIDENTIFIED)), result); }
@Test void startConsentAuth_fail() throws NoSuchFieldException { FieldSetter.setField(controller, controller.getClass().getDeclaredField("middlewareAuth"), new ObaMiddlewareAuthentication(null, new BearerTokenTO(TOKEN, null, 999, null, getAccessTokenTO()))); when(responseUtils.consentCookie(any())).thenReturn(COOKIE); when(redirectConsentService.identifyConsent(anyString(), anyString(), anyBoolean(), anyString(), any())).thenThrow(new ConsentAuthorizeException(ResponseEntity.badRequest().build())); ResponseEntity<ConsentAuthorizeResponse> result = controller.startConsentAuth(ENCRYPTED_ID, AUTH_ID, COOKIE, getAisConsentTO(false)); assertEquals(ResponseEntity.badRequest().build(), result); }