mirror of https://github.com/jacekkow/keycloak-protocol-cas

Jacek Kowalski
2024-03-04 33e5bcd2d66aeb6c47dbfb16df2ded8f42bf961f
commit | author | age
5ba0b0 1 package org.keycloak.protocol.cas;
MP 2
33e5bc 3 import jakarta.ws.rs.core.*;
5ba0b0 4 import org.junit.Test;
MP 5 import org.keycloak.protocol.cas.utils.ContentTypeHelper;
6
7 import static org.junit.Assert.assertEquals;
33e5bc 8 import static org.mockito.Mockito.*;
5ba0b0 9
MP 10 public class ContentTypeHelperTest {
11     @Test
33e5bc 12     public void test() {
JK 13         assertEquals(MediaType.APPLICATION_XML_TYPE, get("").selectResponseType());
14         assertEquals(MediaType.APPLICATION_JSON_TYPE, get("json").selectResponseType());
15         assertEquals(MediaType.APPLICATION_XML_TYPE, get("xml").selectResponseType());
16         assertEquals(MediaType.APPLICATION_JSON_TYPE, get("JSON").selectResponseType());
17         assertEquals(MediaType.APPLICATION_XML_TYPE, get("XML").selectResponseType());
5ba0b0 18     }
MP 19
33e5bc 20     private ContentTypeHelper get(String format) {
JK 21         MultivaluedHashMap<String,String> queryParams = mock(MultivaluedHashMap.class);
22         when(queryParams.getFirst(CASLoginProtocol.FORMAT_PARAM)).thenReturn(format);
23         UriInfo uriInfo = mock(UriInfo.class);
24         when(uriInfo.getQueryParameters()).thenReturn(queryParams);
25         return new ContentTypeHelper(uriInfo);
5ba0b0 26     }
MP 27 }