[#26] Renamed Should to def and added should in the name of test
[#26] Renamed Should to def and added should in the name of test

package com.ofg.infrastructure.web.exception
import com.ofg.infrastructure.base.BaseConfiguration
import com.ofg.infrastructure.base.ConfigurationWithoutServiceDiscovery
import com.ofg.infrastructure.base.MvcIntegrationSpec
import org.springframework.boot.test.SpringApplicationContextLoader
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.test.context.ContextConfiguration

import static org.springframework.http.HttpStatus.SERVICE_UNAVAILABLE
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status

@ContextConfiguration(classes = [Config, BaseConfiguration, ConfigurationWithoutServiceDiscovery], loader = SpringApplicationContextLoader)
class CustomControllerAdviceMvcSpec extends MvcIntegrationSpec {

    def "should apply custom logic when application uses its own @ControllerAdvice"() {
        expect:
            mockMvc.perform(get("/testLowestPrecedence"))
                .andExpect(status().is(SERVICE_UNAVAILABLE.value()))
                .andExpect(header().string("Retry-After", "1000"))
    }

    @Configuration
    static class Config {
        @Bean
        TestController testController() {
            return new TestController()
        }

        @Bean
        CustomControllerAdvice customControllerAdvice() {
            return new CustomControllerAdvice()
        }
    }

}

package com.ofg.infrastructure.web.exception

import com.ofg.infrastructure.base.BaseConfiguration
import com.ofg.infrastructure.base.ConfigurationWithoutServiceDiscovery
import com.ofg.infrastructure.base.MvcIntegrationSpec
import org.springframework.boot.test.SpringApplicationContextLoader
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.test.context.ContextConfiguration

import static org.springframework.http.HttpStatus.SERVICE_UNAVAILABLE
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
import java.lang.Void as Should

@ContextConfiguration(classes = [Config, BaseConfiguration, ConfigurationWithoutServiceDiscovery], loader = SpringApplicationContextLoader)
class CustomControllerAdviceMvcSpec extends MvcIntegrationSpec {

    Should "apply custom logic when application uses its own @ControllerAdvice"() {
        expect:
            mockMvc.perform(get("/testLowestPrecedence"))
                .andExpect(status().is(SERVICE_UNAVAILABLE.value()))
                .andExpect(header().string("Retry-After", "1000"))
    }

    @Configuration
    static class Config {
        @Bean
        TestController testController() {
            return new TestController()
        }

        @Bean
        CustomControllerAdvice customControllerAdvice() {
            return new CustomControllerAdvice()
        }
    }

}
