use of org.candlepin.dto.api.v1.EntitlementDTO in project candlepin by candlepin.
the class EntitlementResourceTest method getAllEntitlementsForConsumer.
@Test
public void getAllEntitlementsForConsumer() {
PageRequest req = new PageRequest();
req.setPage(1);
req.setPerPage(10);
Owner owner = TestUtil.createOwner();
Consumer consumer = TestUtil.createConsumer(owner);
Pool pool = TestUtil.createPool(owner, TestUtil.createProduct());
Entitlement e = TestUtil.createEntitlement(owner, consumer, pool, null);
e.setId("getAllEntitlementsForConsumer");
List<Entitlement> entitlements = new ArrayList<>();
entitlements.add(e);
Page<List<Entitlement>> page = new Page<>();
page.setPageData(entitlements);
EntitlementDTO entitlementDTO = new EntitlementDTO();
entitlementDTO.setId("getAllEntitlementsForConsumer");
when(consumerCurator.findByUuid(eq(consumer.getUuid()))).thenReturn(consumer);
when(entitlementCurator.listByConsumer(isA(Consumer.class), anyString(), isA(EntitlementFilterBuilder.class), isA(PageRequest.class))).thenReturn(page);
when(modelTranslator.translate(isA(Entitlement.class), eq(EntitlementDTO.class))).thenReturn(entitlementDTO);
List<EntitlementDTO> result = entResource.listAllForConsumer(consumer.getUuid(), null, null, req);
assertEquals(1, result.size());
assertEquals("getAllEntitlementsForConsumer", result.get(0).getId());
}
Aggregations