Source:
<code><START> public void testprocessTokenResponse_Wrong_CorrelationId() throws IllegalArgumentException, <END> IllegalAccessException, InvocationTargetException, ClassNotFoundException, NoSuchMethodException, InstantiationException { Object request = createAuthenticationRequest("authority", "resource", "client", "redirect", "loginhint", null, null, UUID.randomUUID()); Object oauth = createOAuthInstance(request); Method m = ReflectionUtils.getTestMethod(oauth, "processTokenResponse", Class.forName("com.microsoft.aad.adal.HttpWebResponse")); String json = "{\"access_token\":\"sometokenhere2343=\",\"token_type\":\"Bearer\",\"expires_in\":\"28799\",\"expires_on\":\"1368768616\",\"refresh_token\":\"refreshfasdfsdf435=\",\"scope\":\"*\"}"; List<String> listOfHeaders = new ArrayList<String>(); listOfHeaders.add(UUID.randomUUID().toString()); HashMap<String, List<String>> headers = new HashMap<String, List<String>>(); headers.put(AuthenticationConstants.AAD.CLIENT_REQUEST_ID, listOfHeaders); HttpWebResponse mockResponse = new HttpWebResponse(200, json.getBytes(Charset .defaultCharset()), headers); TestLogResponse logResponse = new TestLogResponse(); logResponse.listenForLogMessage("CorrelationId is not matching", null); AuthenticationResult result = (AuthenticationResult)m.invoke(oauth, mockResponse); assertEquals("Same token in parsed result", "sometokenhere2343=", result.getAccessToken()); assertTrue("Log response has message", logResponse.errorCode .equals(ADALError.CORRELATION_ID_NOT_MATCHING_REQUEST_RESPONSE)); }</code><technical_language>try a non-UUID passed a correlation id? production code throw illegal argument exception, desired outcome</technical_language>

Target:
public void testprocessTokenResponse_Wrong_CorrelationId() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, NoSuchMethodException, InstantiationException { Object request = createAuthenticationRequest("authority", "resource", "client", "redirect", "loginhint", null, null, UUID.randomUUID()); Object oauth = createOAuthInstance(request); Method m = ReflectionUtils.getTestMethod(oauth, "processTokenResponse", Class.forName("com.microsoft.aad.adal.HttpWebResponse")); String json = "{\"access_token\":\"sometokenhere2343=\",\"token_type\":\"Bearer\",\"expires_in\":\"28799\",\"expires_on\":\"1368768616\",\"refresh_token\":\"refreshfasdfsdf435=\",\"scope\":\"*\"}"; List<String> listOfHeaders = new ArrayList<String>(); listOfHeaders.add(UUID.randomUUID().toString()); HashMap<String, List<String>> headers = new HashMap<String, List<String>>(); headers.put(AuthenticationConstants.AAD.CLIENT_REQUEST_ID, listOfHeaders); HttpWebResponse mockResponse = new HttpWebResponse(200, json.getBytes(Charset .defaultCharset()), headers); TestLogResponse logResponse = new TestLogResponse(); logResponse.listenForLogMessage("CorrelationId is not matching", null); AuthenticationResult result = (AuthenticationResult)m.invoke(oauth, mockResponse); assertEquals("Same token in parsed result", "sometokenhere2343=", result.getAccessToken()); assertTrue("Log response has message", logResponse.errorCode .equals(ADALError.CORRELATION_ID_NOT_MATCHING_REQUEST_RESPONSE)); List<String> invalidHeaders = new ArrayList<String>(); invalidHeaders.add("invalid-UUID"); headers.put(AuthenticationConstants.AAD.CLIENT_REQUEST_ID, invalidHeaders); mockResponse = new HttpWebResponse(200, json.getBytes(Charset.defaultCharset()), headers); TestLogResponse logResponse2 = new TestLogResponse(); logResponse2.listenLogForMessageSegments(null, "Wrong format of the correlation ID:"); m.invoke(oauth, mockResponse); assertTrue("Log response has message", logResponse2.errorCode.equals(ADALError.CORRELATION_ID_FORMAT)); }