/*
 * European Variation Archive (EVA) - Open-access database of all types of genetic
 * variation data from all species
 *
 * Copyright 2019 EMBL - European Bioinformatics Institute
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package uk.ac.ebi.eva.server.test;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.hateoas.hal.Jackson2HalModule;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;

@Configuration
public class TestRestConfiguration {

    @Bean
    public RestTemplateBuilder restTemplateBuilder() {
        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        mapper.registerModule(new Jackson2HalModule());
        MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
        converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));
        converter.setObjectMapper(mapper);

        RestTemplateBuilder restTemplateBuilder = new RestTemplateBuilder();
        return restTemplateBuilder.additionalMessageConverters(converter);
    }
}

@@ -902,57 +902,309 @@
 org.
-springframework.boot.web.client.RestTemplateBuild
+apache.commons.collections.CollectionUtils;%0Aimport org.springframework.beans.factory.ObjectProvider;%0Aimport org.springframework.boot.autoconfigure.web.HttpMessageConverters;%0Aimport org.springframework.boot.web.client.RestTemplateBuilder;%0Aimport org.springframework.boot.web.client.RestTemplateCustomiz
 er;%0A
@@ -1316,16 +1316,91 @@
 ration;%0A
+import org.springframework.core.annotation.AnnotationAwareOrderComparator;%0A
 import o
@@ -1577,16 +1577,68 @@
 erter;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.List;%0A%0A
 @Configu
@@ -1743,16 +1743,166 @@
 Builder(
+%0A            ObjectProvider%3CHttpMessageConverters%3E messageConverters,%0A            ObjectProvider%3CList%3CRestTemplateCustomizer%3E%3E restTemplateCustomizers
 ) %7B%0A    
@@ -2400,24 +2400,25 @@
 lder();%0A
+%0A
         
 return r
@@ -2413,74 +2413,697 @@
     
-return restTemplateBuilder.additionalMessageConverters(converter);
+HttpMessageConverters converters = (HttpMessageConverters) messageConverters.getIfUnique();%0A        restTemplateBuilder.additionalMessageConverters(converter);%0A        if (converters != null) %7B%0A            restTemplateBuilder.additionalMessageConverters(converters.getConverters());%0A        %7D%0A        List%3CRestTemplateCustomizer%3E customizers = (List) restTemplateCustomizers.getIfAvailable();%0A        if (!CollectionUtils.isEmpty(customizers)) %7B%0A            customizers = new ArrayList(customizers);%0A            AnnotationAwareOrderComparator.sort(customizers);%0A            restTemplateBuilder = restTemplateBuilder.customizers(customizers);%0A        %7D%0A%0A        return restTemplateBuilder;%0A
 %0A   

change in config