0

Quarkus legacy RestEasy gives error of "unsatisfied dependency" when @RestClient annotation is used on gateway to inject in service layer and Mock of that same gateway is also implemented at the same time.

The gateway is like below

@RegisterRestClient(configKey = "gateway")
public interface FlightGateway
{
  @Path("/esb/flight/bookflight/v1")
  @POST
  public BookFlightResp bookFlight(BookFlightReq req);
}

My service class

public class FlightServiceImpl implements FlightService {
@RestClient
FlightGateway flightGateway;
@Override
public BookFlightRply flightBooking(BookFlight req) {
    
    BookFlightRply rply = flightGateway.bookFlight(req);

    return rply;
}

The problem happens below when I implement FlightGateway in mock class i get unsatisfied dependency error. If I remove "implements FlightGateway" on below mock class, application works perfectly. This problem doesnt happen in RestEasy reactive but only in legacy RestEasy.

public class FlightMock implements FlightGateway {

@Override
public BookFlightResp bookFlight(BookFlightReq req) {

    //Mock code here
    return resp;
}

}

The error is below

[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type com.as.flight.integration.gateway.FlightGateway and qualifiers [@RestClient]

  • java member: com.as.flight.service.FlightServiceImpl#FlightGateway [[1;31mERROR[m] - declared on CLASS bean [types=[com.as.flight.service.FlightServiceImpl, java.lang.Object, com.as.flight.service.FlightService], qualifiers=[@Default, @Any], target=com.as.flight.service.FlightServiceImpl]
topgun
  • 43
  • 1
  • 10

0 Answers0