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

github-actions
2024-03-25 47b041183da2015711af7b7961c342cb1be9c947
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 }