### Question:
SSOUtils { @SuppressWarnings("unchecked") public static Map<String, Object> generateRelayState(Request request) { Map<String, Object> relayStateContent = new HashMap<>(); Optional.ofNullable(request) .ifPresent(requestObject -> { relayStateContent.put(Constants.REQUEST_URL, requestObject.getRequestURI()); relayStateContent.put(Constants.REQUEST_QUERY_STRING, requestObject.getQueryString()); relayStateContent.put(Constants.REQUEST_PARAMETERS, requestObject.getParameterMap()); }); Optional.ofNullable(request.getAttribute(Constants.RELAY_STATE)) .ifPresent(content -> ((Map<String, Object>) content) .forEach(relayStateContent::put)); return relayStateContent; } private  SSOUtils(); static String createID(); static Optional<String> constructApplicationServerURL(Request request); static Map<String, String[]> getSplitQueryParameters(String queryParameterString); @SuppressWarnings("unchecked") static Map<String, Object> generateRelayState(Request request); static Optional<String> generateIssuerID(String contextPath, String hostAppBase); static Optional<String> generateConsumerURL(String contextPath, String acsBase, String acsPostfix); static Optional generateKeyStore(); static void sendCharacterData(HttpServletResponse response, String htmlPayload); static void doBootstrap(); static RequestAbstractType setSignature(RequestAbstractType request, String signatureAlgorithm,
                                                   X509Credential credential); static String encodeRequestMessage(RequestAbstractType requestMessage, String binding); static String marshall(XMLObject xmlObject); static Optional<XMLObject> unmarshall(String xmlString); static Assertion decryptAssertion(SSOX509Credential ssoAgentX509Credential,
                                             EncryptedAssertion encryptedAssertion); static Map<String, List<String>> getAssertionStatements(Assertion assertion); static void addDeflateSignatureToHTTPQueryString(StringBuilder httpQueryString, X509Credential credential);  }### Answer:
@Test(description = "Tests the generation of relay state") @SuppressWarnings("unchecked") public void testGeneratingRelayState() { Request request = mock(Request.class); when(request.getRequestURI()).thenReturn("/" + TestConstants.FOO_CONTEXT); when(request.getQueryString()).thenReturn(TestConstants.DEFAULT_QUERY_PARAMS); when(request.getParameterMap()).thenReturn(getQueryParams()); Map<String, Object> additionalParams = new HashMap<>(); additionalParams.put("Company", "WSO2"); when(request.getAttribute(Constants.RELAY_STATE)).thenReturn(additionalParams); Map<String, Object> actual = SSOUtils.generateRelayState(request); boolean uriMatches = request.getRequestURI().equals(actual.get(Constants.REQUEST_URL)); boolean queryStringMatches = request.getQueryString().equals(actual.get(Constants.REQUEST_QUERY_STRING)); boolean paramMapMatches = equalMaps(getQueryParams(), (Map<String, String[]>) actual.get(Constants.REQUEST_PARAMETERS)); boolean additionalParamMatches = actual.get("Company").equals("WSO2"); Assert.assertTrue(uriMatches && queryStringMatches && paramMapMatches && additionalParamMatches); }