title: Quarkus Panache active pattern unit test mocking
body: <p>I'm trying to unit test service bean and mock persistence unit inside of the service. For persistence unit I'm using active record pattern is this even possible with this pattern? I couldn't find solution that would work also tried with repository pattern and couldn't inject mocked repository into service bean.</p>
  <p>Service bean:</p>
  <pre><code>public List&lt;HolidayDto&gt; findAllByYear(int year, Boolean isWorkday) {
      // DAO
      List&lt;Holiday&gt; holidays = Holiday.listAll();
      return holidays.stream()
              .map(x -&gt; buildHolidayDto(x, year))
              .filter(x -&gt; {
                  if (isWorkday != null) {
                      return x.getIsWorkday().equals(isWorkday) ? true : false;
                  } else {
                      return true;
                  }
              })
              .collect(Collectors.toList());
  }
  </code></pre>
  <p>Actual unit test:</p>
  <pre><code>@QuarkusTest
  public class HolidayServiceTest {
  
  @InjectMock
  HolidayService holidayService;
  
  @BeforeEach
  void setup() {
      List&lt;PanacheEntityBase&gt; holidays = new ArrayList&lt;&gt;();
      Holiday holiday1 = new Holiday();
      holiday1.setId(4L);
      holiday1.setName(&quot;Easter Sunday&quot;);
      holiday1.setLocalName(&quot;velikonočna nedelja&quot;);
      holiday1.setType(&quot;CHRISTIAN&quot;);
      holiday1.setWorkday(false);
      holiday1.setRecurring(true);
      holiday1.setCountry(&quot;SL&quot;);
      holiday1.setDescription(&quot;easter&quot;);
      holidays.add(holiday1);
      PanacheMock.mock(Holiday.class);
      Mockito.when(Holiday.listAll()).thenReturn(holidays);
  }
  
  @Test
  public void testHolidayService() {
      Assertions.assertEquals(1, holidayService.findAllByYear(2022, false).stream().count());
  }
  }
  </code></pre>