<commit_before>package com.neoteric.starter.test.restassured;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.restassured.RestAssured;
import com.jayway.restassured.config.ObjectMapperConfig;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.TestContext;
import org.springframework.test.context.support.AbstractTestExecutionListener;

import static com.neoteric.starter.test.StarterTestConstants.JACKSON_OBJECT_MAPPER_BEAN;
import static com.neoteric.starter.test.StarterTestConstants.LOCAL_SERVER_PORT;

public class RestAssuredListener extends AbstractTestExecutionListener {

    @Override
    public void beforeTestClass(TestContext testContext) throws Exception {
        if (testContext.getTestClass().getAnnotation(ContainerIntegrationTest.class) == null) {
            return;
        }
        ApplicationContext applicationContext = testContext.getApplicationContext();
        String property = applicationContext.getEnvironment().getProperty(LOCAL_SERVER_PORT);
        RestAssured.port = Integer.parseInt(property);

        ObjectMapper objectMapper = applicationContext.getBean(JACKSON_OBJECT_MAPPER_BEAN, ObjectMapper.class);

        RestAssured.config = RestAssured.config().objectMapperConfig(<commit_msg>Make RestAssuredListener find ContainerIntegrationtest annotation, as it does not need to be explicitly set on Test class<commit_after>package com.neoteric.starter.test.restassured;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.restassured.RestAssured;
import com.jayway.restassured.config.ObjectMapperConfig;
import org.springframework.context.ApplicationContext;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.test.context.TestContext;
import org.springframework.test.context.support.AbstractTestExecutionListener;

import static com.neoteric.starter.test.StarterTestConstants.JACKSON_OBJECT_MAPPER_BEAN;
import static com.neoteric.starter.test.StarterTestConstants.LOCAL_SERVER_PORT;

public class RestAssuredListener extends AbstractTestExecutionListener {

    @Override
    public void beforeTestClass(TestContext testContext) throws Exception {
        if (AnnotationUtils.findAnnotation(testContext.getTestClass(), ContainerIntegrationTest.class) == null) {
            return;
        }
        ApplicationContext applicationContext = testContext.getApplicationContext();
        String property = applicationContext.getEnvironment().getProperty(LOCAL_SERVER_PORT);
        RestAssured.port = Integer.parseInt(property);

        ObjectMapper objectMapper = applicationContext.getBean(JACKSON_OBJECT_MAPPER_BEAN, ObjectMapper.class);

        RestAssured.config = RestAssured.config().objectMapperConfig(
{'fraction_non_alphanumeric': 0.07545126353790614, 'fraction_numerical': 0.0, 'mean_word_length': 5.825123152709359, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2566803', 'n_tokens_mistral': 719, 'n_tokens_neox': 694, 'n_words': 118}