'Junit how to import file properties to service in test

I am writting unit test and have some values from application.yaml property file. In my test before i can go into service method values are imported from test/resources, but when go into service im getting null value properties here is some code : test :

@ActiveProfiles("test")
@SpringBootTest
@TestPropertySource("classpath:application-test.yaml")
public class AmadeusClientUnitTest {

    @Value("${clientId}")
    public String clientId;

    @Value("${clientSecret}")
    public String clientSecret;

    @Spy
    @InjectMocks
    private AmadeusClient amadeusClient;

    @Test
    void shouldGetAmadeusObj() {
        amadeusClient.getAmadeusObj();

        verify(Amadeus.builder(any(), any()).build());
    }

application-test.yaml :

spring:
  config:
    activate:
      on-profile: test
clientId: "clientId"
clientSecret: "secret"

and here is service :

@Service
public class AmadeusClient {

    private final static Logger LOGGER = Logger.getLogger(AmadeusClient.class.getName());

    @Value("${clientId}")
    private String clientId;
    @Value("${clientSecret}")
    private String clientSecret;

    public Amadeus getAmadeusObj() {
        return Amadeus.builder(clientId, clientSecret).setLogger(LOGGER).build();
    }
}

debug

debug

I put some imgs from debugging test. Am I missing any properties ? Thanks for any help i feel like i am missing "dot" somewhere. Appreciate for any tip here. Have a nice day



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source