vendredi 28 février 2020

@QuarkusTest - implementing an interface with annotation @RegisterRestClient, in test - fails the test

I'm using Quarkus 1.2.0.Final.

I have the following REST client:

@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@RegisterRestClient(configKey = "<some key>")
public interface SomeClient {

    @POST
    @Path("<some path>")
    SomeResponse someMethod(SomeRequest request);

}

This bean is used in my other beans as a dependency.

And I have the following test case:

@QuarkusTest
class SomeTest {
    @Test
    void testGetTransactions() { }
}

class SomeClientImpl implements SomeClient {

    @Override
    public SomeResponse someMethod(SomeRequest request) {
        // <the implementation doesn't matter>
        return null;
    }
}

The test is failing with the following exception:

Suppressed: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type com.example.client.SomeClient and qualifiers [@RestClient]
...

Why the test is failing? If I remove the class class SomeClientImpl implements SomeClient {...} the test is passing. So implementing an interface leads to test failing, which is weird.


Update 1:

I tried the next code and I'm getting the same exception:

@QuarkusTest
class TransactionServiceImplTest {

    @Test
    void testGetTransactions() {
        new SomeClient() {

            @Override
            public SomeResponse someMethod(SomeRequest request) {
                // <the implementation doesn't matter>
                return null;
            }
        };
    }
}

Aucun commentaire:

Enregistrer un commentaire