### Question:
BrowserAuthenticationApi { @NonNull Result getAuthenticationResultFrom(@NonNull Intent resultIntent) { Uri resultDataUri = resultIntent.getData(); if (resultDataUri == null) { return Result.createAsInternalError( "Illegal redirection from external application."); } String sentState = authenticationStatus.getOAuthState(); String receivedState = resultDataUri.getQueryParameter("state"); if (sentState == null || !sentState.equals(receivedState)) { return Result.createAsInternalError( "Illegal parameter value of 'state'."); } String requestToken = resultDataUri.getQueryParameter("code"); String friendshipStatusChangedStr = resultDataUri.getQueryParameter("friendship_status_changed"); Boolean friendshipStatusChanged = null; if (!TextUtils.isEmpty(friendshipStatusChangedStr)) { friendshipStatusChanged = Boolean.parseBoolean(friendshipStatusChangedStr); } return !TextUtils.isEmpty(requestToken) ? Result.createAsSuccess(requestToken, friendshipStatusChanged) : Result.createAsAuthenticationAgentError( resultDataUri.getQueryParameter("error"), resultDataUri.getQueryParameter("error_description")); } BrowserAuthenticationApi(@NonNull LineAuthenticationStatus authenticationStatus);   }### Answer:
@Test public void getResultFrom() throws Exception { BrowserAuthenticationApi.Result result; Intent nullDataIntent = new Intent(); result = target.getAuthenticationResultFrom(nullDataIntent); assertFalse(result.isSuccess()); assertFalse(result.isAuthenticationAgentError()); assertNotNull(result.getLineApiError().getMessage()); Intent illegalUriIntent = new Intent(); illegalUriIntent.setData(Uri.parse( "lineauth: result = target.getAuthenticationResultFrom(nullDataIntent); assertFalse(result.isSuccess()); assertFalse(result.isAuthenticationAgentError()); assertNotNull(result.getLineApiError().getMessage()); Intent emptyStateIntent = new Intent(); emptyStateIntent.setData(Uri.parse( "lineauth: result = target.getAuthenticationResultFrom(nullDataIntent); assertFalse(result.isSuccess()); assertFalse(result.isAuthenticationAgentError()); assertNotNull(result.getLineApiError().getMessage()); Intent illegalStateIntent = new Intent(); illegalStateIntent.setData(Uri.parse( "lineauth: result = target.getAuthenticationResultFrom(nullDataIntent); assertFalse(result.isSuccess()); assertFalse(result.isAuthenticationAgentError()); assertNotNull(result.getLineApiError().getMessage()); authenticationStatus.setOAuthState(STATE); Intent correctUriIntent = new Intent(); correctUriIntent.setData(Uri.parse( "lineauth: result = target.getAuthenticationResultFrom(correctUriIntent); assertTrue(result.isSuccess()); assertFalse(result.isAuthenticationAgentError()); assertEquals("testCode", result.getRequestToken()); Intent serverErrorIntent = new Intent(); serverErrorIntent.setData(Uri.parse( "lineauth: result = target.getAuthenticationResultFrom(serverErrorIntent); assertFalse(result.isSuccess()); assertTrue(result.isAuthenticationAgentError()); assertEquals( new JSONObject() .put("error", "testError") .put("error_description", "testErrorDescription") .toString(), result.getLineApiError().getMessage()); }