### Question:
CertificateSubjectClientIdOauth2Service implements Oauth2Service { @Override public URI getAuthorizationRequestUri(Map<String, String> headers, Parameters parameters) throws IOException { return UriBuilder.fromUri(oauth2Service.getAuthorizationRequestUri(headers, parameters)) .queryParam(Parameters.CLIENT_ID, clientId(parameters)) .build(); } CertificateSubjectClientIdOauth2Service(Oauth2Service oauth2Service, Pkcs12KeyStore keyStore); @Override URI getAuthorizationRequestUri(Map<String, String> headers, Parameters parameters); @Override TokenResponse getToken(Map<String, String> headers, Parameters parameters);  }### Answer:
@Test void getAuthorizationRequestUri() throws IOException, KeyStoreException { String authorisationRequestUri = "https: "response_type=code&state=state&redirect_uri=https%3A%2F%2Fredirect"; URI expectedOutput = URI.create(authorisationRequestUri + "&" + Parameters.CLIENT_ID + "=" + organisationIdentifier); when(oauth2Service.getAuthorizationRequestUri(any(), any())).thenReturn(URI.create(authorisationRequestUri)); when(pkcs12KeyStore.getOrganizationIdentifier()).thenReturn(organisationIdentifier); URI actual = service.getAuthorizationRequestUri(null, parameters); verify(oauth2Service, times(1)).getAuthorizationRequestUri(any(), any()); verify(pkcs12KeyStore, times(1)).getOrganizationIdentifier(); assertEquals(actual, expectedOutput); }
@Test void getAuthorizationRequestUri_throwingException() throws IOException, KeyStoreException { when(oauth2Service.getAuthorizationRequestUri(any(), any())).thenReturn(URI.create("")); when(pkcs12KeyStore.getOrganizationIdentifier()).thenThrow(KeyStoreException.class); assertThrows(RuntimeException.class, () -> service.getAuthorizationRequestUri(null, parameters)); }