@ApplicationScoped
@Transactional(SUPPORTS)
public class FightService {
@Inject
@RestClient
HeroService heroService;
@Inject
@RestClient
VillainService villainService;
public Fighters getRandomFighters() {
Hero hero = heroService.findRandomHero();
Villain villain = villainService.findRandomVillain();
Fighters fighters = new Fighters();
fighters.setHero(hero);
fighters.setVillain(villain);
return fighters;
}
@Path("/api/villains")
@Produces(MediaType.APPLICATION_JSON)
@RegisterRestClient
public interface HeroService {
@GET
@Path("/random")
Hero findRandomHero();
}
@Mock
@ApplicationScoped
public class MockHeroService implements HeroService {
@Override
public Hero findRandomHero() {
Hero hero = new Hero();
hero.setName(DEFAULT_HERO_NAME);
hero.setPicture(DEFAULT_HERO_PICTURE);
hero.setPowers(DEFAULT_HERO_POWERS);
hero.setLevel(DEFAULT_HERO_LEVEL);
return hero;
}
}
org.junit.jupiter.api.extension.TestInstantiationException: TestInstanceFactory [io.quarkus.test.junit.QuarkusTestExtension] failed to instantiate test class [io.quarkus.workshop.superheroes.fight.FightResourceTest]: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: Found 2 deployment problems:
[1] Unsatisfied dependency for type io.quarkus.workshop.superheroes.fight.client.HeroService and qualifiers [@RestClient]
- java member: io.quarkus.workshop.superheroes.fight.FightService#heroService
- declared on CLASS bean [types=[java.lang.Object, io.quarkus.workshop.superheroes.fight.FightService], qualifiers=[@Default, @Any], target=io.quarkus.workshop.superheroes.fight.FightService]
[2] Unsatisfied dependency for type io.quarkus.workshop.superheroes.fight.client.VillainService and qualifiers [@RestClient]
- java member: io.quarkus.workshop.superheroes.fight.FightService#villainService
- declared on CLASS bean [types=[java.lang.Object, io.quarkus.workshop.superheroes.fight.FightService], qualifiers=[@Default, @Any], target=io.quarkus.workshop.superheroes.fight.FightService]