Search in sources :

Example 1 with AnyTypeClassService

use of org.apache.syncope.common.rest.api.service.AnyTypeClassService in project syncope by apache.

the class RESTITCase method defaultContentType.

@Test
public void defaultContentType() {
    // manualy instantiate SyncopeClient so that media type can be set to */*
    SyncopeClientFactoryBean factory = new SyncopeClientFactoryBean().setAddress(ADDRESS);
    SyncopeClient client = new SyncopeClient(MediaType.WILDCARD_TYPE, factory.getRestClientFactoryBean(), factory.getExceptionMapper(), new BasicAuthenticationHandler(ADMIN_UNAME, ADMIN_PWD), false);
    // perform operation
    AnyTypeClassService service = client.getService(AnyTypeClassService.class);
    service.list();
    // check that */* was actually sent
    MultivaluedMap<String, String> requestHeaders = WebClient.client(service).getHeaders();
    assertEquals(MediaType.WILDCARD, requestHeaders.getFirst(HttpHeaders.ACCEPT));
    // check that application/json was received
    String contentType = WebClient.client(service).getResponse().getHeaderString(HttpHeaders.CONTENT_TYPE);
    assertTrue(contentType.startsWith(MediaType.APPLICATION_JSON));
}
Also used : AnyTypeClassService(org.apache.syncope.common.rest.api.service.AnyTypeClassService) SyncopeClientFactoryBean(org.apache.syncope.client.lib.SyncopeClientFactoryBean) BasicAuthenticationHandler(org.apache.syncope.client.lib.BasicAuthenticationHandler) SyncopeClient(org.apache.syncope.client.lib.SyncopeClient) Test(org.junit.jupiter.api.Test)

Aggregations

BasicAuthenticationHandler (org.apache.syncope.client.lib.BasicAuthenticationHandler)1 SyncopeClient (org.apache.syncope.client.lib.SyncopeClient)1 SyncopeClientFactoryBean (org.apache.syncope.client.lib.SyncopeClientFactoryBean)1 AnyTypeClassService (org.apache.syncope.common.rest.api.service.AnyTypeClassService)1 Test (org.junit.jupiter.api.Test)1