CrmWebserviceEndpoint { @WebMethod public List<ContactDto> getContracts(@WebParam(name = "from") int from, @WebParam(name = "limit") int limit) { ContactQuery contactQuery = new ContactQuery(); contactQuery.setFirstResult(from); contactQuery.setMaxResults(limit); List<Contact> databaseContacts = contactDao.list(contactQuery, new HashMap<String, Object>()); List<ContactDto> deliveredContacts = new ArrayList<ContactDto>(); for (Contact contact : databaseContacts) { ContactDto contactDto = new ContactDto(); obtainContactMapper().mapContactWithoutHistory(contact, contactDto); deliveredContacts.add(contactDto); } return deliveredContacts; } CrmWebserviceEndpoint();  CrmWebserviceEndpoint(ContactDao contactDao); @Inject @WebMethod(exclude = true) void setContactDao(ContactDaoEjb contactDao); @WebMethod List<ContactDto> getContracts(@WebParam(name = "from") int from, @WebParam(name = "limit") int limit); @WebMethod ContactDto getContactIncludingHistory(@WebParam(name = "id") long id); @WebMethod ContactDto addContact(@WebParam(name = "contactDto") ContactDto contactDto); @WebMethod ContactDto updateContact(@WebParam(name = "contactDto") ContactDto contactDto); @WebMethod ContactDto addHistoryToContact(@WebParam(name = "contactDto") ContactDto contactDto, @WebParam(name = "historyDto") HistoryDto historyDto,
			@WebParam(name = "returnHistory") boolean returnHistory);  }
@SuppressWarnings("unchecked") @Test public void testGetContracts() { when(contactDao.list(any(ContactQuery.class), anyMap())).thenReturn(Collections.singletonList(contactRef)); List<ContactDto> res = webservice.getContracts(2, 1); verify(contactDao).list(argThat(new BaseMatcher<ContactQuery>() { @Override public boolean matches(Object arg0) { return arg0 != null && (arg0 instanceof ContactQuery) && ((ContactQuery) arg0).getFirstResult() == 2 && ((ContactQuery) arg0).getMaxResults() == 1; } @Override public void describeTo(Description arg0) { arg0.appendText("ContactQuery 2-1"); } }), anyMap()); assertEquals(1, res.size()); assertEquals("Hans Hummel", res.get(0).getName()); assertEquals(0, res.get(0).getHistory().size()); }