RestAuthCallbackHandlerManagerTest.java revision 5c9e2d2d0705bb9ddebf7911e9f79ac24445d70a
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2013 ForgeRock Inc.
*/
public class RestAuthCallbackHandlerManagerTest {
public void setUp() {
restAuthCallbackHandlerManager = new RestAuthCallbackHandlerManager(restAuthCallbackHandlerFactory);
}
@Test
public void shouldHandleCallbacksIntoJson() throws JSONException {
//Given
callback1)).willReturn(false);
callback2)).willReturn(false);
//When
JSONArray jsonCallbacks = restAuthCallbackHandlerManager.handleCallbacks(headers, request, response,
//Then
verify(restAuthCallbackHandler2, never()).updateCallbackFromRequest(headers, request, response, callback2);
}
@Test
public void shouldHandleCallbacksInternally() throws JSONException {
//Given
given(restAuthCallbackHandlerFactory.getRestAuthCallbackHandler(Matchers.<Class<? extends Callback>>anyObject())).willReturn(
callback1)).willReturn(true);
callback2)).willReturn(true);
//When
JSONArray jsonCallbacks = restAuthCallbackHandlerManager.handleCallbacks(headers, request, response,
//Then
}
@Test
public void shouldHandleCallbacksIntoJsonIfAtLeastOneCannotBeDoneInternally() throws JSONException {
//Given
callback1)).willReturn(true);
callback2)).willReturn(false);
//When
JSONArray jsonCallbacks = restAuthCallbackHandlerManager.handleCallbacks(headers, request, response,
//Then
}
@Test
public void shouldHandleJsonCallbacks() throws JSONException {
//Given
//When
Callback[] originalCallbacks = restAuthCallbackHandlerManager.handleJsonCallbacks(callbacks, jsonCallbacks);
//Then
}
@Test
public void shouldHandleJsonCallbacksMixedUp() throws JSONException {
//Given
//When
Callback[] originalCallbacks = restAuthCallbackHandlerManager.handleJsonCallbacks(callbacks, jsonCallbacks);
//Then
}
public void shouldFailToHandleJsonCallbacksWithMissinJSONCallback() throws JSONException {
//Given
//When
//Then
fail();
}
}