### Question:
AuthorizationServer { public static String [] getBasicAuthorizationClientCredentials(HttpRequest req) { String authHeader = req.headers().get(HttpHeaders.Names.AUTHORIZATION); String [] clientCredentials = new String [2]; if (authHeader != null && authHeader.contains(BASIC)) { String value = authHeader.replace(BASIC, ""); Base64 decoder = new Base64(); byte[] decodedBytes = decoder.decode(value); String decoded = new String(decodedBytes, Charset.forName("UTF-8")); String[] str = decoded.split(":"); if (str.length == 2) { clientCredentials [0] = str[0]; clientCredentials [1] = str[1]; } } return clientCredentials; }  ClientCredentials issueClientCredentials(HttpRequest req); String issueAuthorizationCode(HttpRequest req); AccessToken issueAccessToken(HttpRequest req); static String [] getBasicAuthorizationClientCredentials(HttpRequest req); AccessToken isValidToken(String token); ApplicationInfo getApplicationInfo(String clientId); boolean revokeUserAccessTokens(HttpRequest req); boolean revokeToken(HttpRequest req); boolean updateClientApp(HttpRequest req, String clientId);  }### Answer:
@Test public void when_get_clientId_from_Basic_Auth_call_get_Header_method() throws Exception { HttpRequest req = mock(HttpRequest.class); HttpHeaders headers = mock(HttpHeaders.class); willReturn("token").given(headers).get(anyString()); willReturn(headers).given(req).headers(); AuthorizationServer.getBasicAuthorizationClientCredentials(req); verify(req.headers()).get(HttpHeaders.Names.AUTHORIZATION); }
@Test public void when_Basic_Auth_header_empty_return_null() throws Exception { HttpRequest req = mock(HttpRequest.class); HttpHeaders headers = mock(HttpHeaders.class); willReturn("token").given(headers).get(HttpHeaders.Names.AUTHORIZATION); willReturn(headers).given(req).headers(); String [] clientCreds = AuthorizationServer.getBasicAuthorizationClientCredentials(req); assertNull(clientCreds[0]); assertNull(clientCreds[1]); }
@Test public void when_Basic_Auth_header_return_clientId() throws Exception { HttpRequest req = mock(HttpRequest.class); String clientId = "740503633355700"; String clientSecret = "7405036333557004234394sadasd214124"; String basic = clientId + ":" + clientSecret; String headerValue = AuthorizationServer.BASIC + Base64.encodeBase64String(basic.getBytes()); HttpHeaders headers = mock(HttpHeaders.class); willReturn(headerValue).given(headers).get(HttpHeaders.Names.AUTHORIZATION); willReturn(headers).given(req).headers(); willReturn(true).given(authServer.db).validClient(clientId, clientSecret); String [] result = AuthorizationServer.getBasicAuthorizationClientCredentials(req); assertEquals(result [0], clientId); assertEquals(result [1], clientSecret); }