I am using Quarkus with Hibernate-ORM PanacheRepository and I need to mock the PanacheQuery. I have the following classes:
- Label(JPA Entity)
- LabelRepository (implements PanacheRepository< Label > {})
In my test class I need to mock the labelRepository.find("name", name). This method return a PanacheQuery but I don't know how I can create a new PanacheQuery mock.
@QuarkusTest
class LabelResourceTest {
@Inject LabelResource labelResource;
@InjectMock LabelRepository labelRepository;
private Label label;
private List<Label> labels;
@BeforeEach
void setUp() {
label = new Label();
label.setId(1L);
label.setName("LABEL#01");
label.setInheritable(true);
labels = new ArrayList<>();
labels.add(label);
}
@Test
void getNameTest() {
when(labelRepository.find("name", "LABEL#01")).thenReturn(......);
.....
}
}
Thank you.