new HashSet<DerivedProvidedProduct>();
subProvidedProducts.add(subProvided1);
Pool pool = TestUtil.createPool(owner, parentProduct, provided, subProduct.getId(),
subProvidedProducts, 3);
EntitlementCertificate cert = createEntitlementCertificate("my-test-key",
"my-cert");
Entitlement ent = TestUtil.createEntitlement(owner, consumer, pool, cert);
ent.setQuantity(3);
Reader reader = mock(Reader.class);
when(om.readValue(reader, Entitlement.class)).thenReturn(ent);
// Create our expected products
Map<String, Product> productsById = new HashMap<String, Product>();
productsById.put(parentProduct.getId(), parentProduct);
productsById.put(pp1.getProductId(),
TestUtil.createProduct(pp1.getProductId(), pp1.getProductName()));
productsById.put(subProduct.getId(), subProduct);
productsById.put(subProvided1.getProductId(), TestUtil.createProduct(
subProvided1.getProductId(), subProvided1.getProductName()));
Meta meta = new Meta();
meta.setCdnLabel("test-cdn");
Cdn testCdn = new Cdn("test-cdn",
"Test CDN", "https://test.url.com");
when(cdnCurator.lookupByLabel("test-cdn")).thenReturn(testCdn);
Subscription sub = importer.importObject(om, reader, owner,
productsById, consumerDto, meta);
assertEquals(pool.getId(), sub.getUpstreamPoolId());
assertEquals(consumer.getUuid(), sub.getUpstreamConsumerId());
assertEquals(ent.getId(), sub.getUpstreamEntitlementId());
assertEquals(owner, sub.getOwner());
assertEquals(ent.getStartDate(), sub.getStartDate());
assertEquals(ent.getEndDate(), sub.getEndDate());
assertEquals(pool.getAccountNumber(), sub.getAccountNumber());
assertEquals(pool.getContractNumber(), sub.getContractNumber());
assertEquals(pool.getOrderNumber(), sub.getOrderNumber());
assertEquals(ent.getQuantity().intValue(), sub.getQuantity().intValue());
assertEquals(parentProduct, sub.getProduct());
assertEquals(provided.size(), sub.getProvidedProducts().size());
assertEquals(pp1.getProductId(), sub.getProvidedProducts().
iterator().next().getId());
assertEquals(subProduct, sub.getDerivedProduct());
assertEquals(1, sub.getDerivedProvidedProducts().size());
assertEquals(subProvided1.getProductId(), sub.getDerivedProvidedProducts().
iterator().next().getId());
assertNotNull(sub.getCertificate());
CertificateSerial serial = sub.getCertificate().getSerial();
assertEquals(cert.getSerial().isCollected(), serial.isCollected());
assertEquals(cert.getSerial().getExpiration(), serial.getExpiration());
assertEquals(cert.getSerial().getCreated(), serial.getCreated());
assertEquals(cert.getSerial().getUpdated(), serial.getUpdated());
assertEquals(sub.getCdn().getLabel(), meta.getCdnLabel());
}