@SuppressWarnings("unchecked")
@Test
public void exportProducts() throws Exception {
config.setProperty(ConfigProperties.SYNC_WORK_DIR, "/tmp/");
Consumer consumer = mock(Consumer.class);
Entitlement ent = mock(Entitlement.class);
ProvidedProduct pp = mock(ProvidedProduct.class);
DerivedProvidedProduct spp = mock(DerivedProvidedProduct.class);
Pool pool = mock(Pool.class);
Rules mrules = mock(Rules.class);
Principal principal = mock(Principal.class);
IdentityCertificate idcert = new IdentityCertificate();
Set<ProvidedProduct> ppset = new HashSet<ProvidedProduct>();
ppset.add(pp);
Set<DerivedProvidedProduct> sppSet = new HashSet<DerivedProvidedProduct>();
sppSet.add(spp);
Set<Entitlement> entitlements = new HashSet<Entitlement>();
entitlements.add(ent);
Product prod = new Product("12345", "RHEL Product");
prod.setMultiplier(1L);
prod.setCreated(new Date());
prod.setUpdated(new Date());
prod.setHref("http://localhost");
prod.setAttributes(Collections.EMPTY_SET);
Product prod1 = new Product("MKT-prod", "RHEL Product");
prod1.setMultiplier(1L);
prod1.setCreated(new Date());
prod1.setUpdated(new Date());
prod1.setHref("http://localhost");
prod1.setAttributes(Collections.EMPTY_SET);
Product subProduct = new Product("MKT-sub-prod", "Sub Product");
subProduct.setMultiplier(1L);
subProduct.setCreated(new Date());
subProduct.setUpdated(new Date());
subProduct.setHref("http://localhost");
subProduct.setAttributes(Collections.EMPTY_SET);
Product subProvidedProduct = new Product("332211", "Sub Product");
subProvidedProduct.setMultiplier(1L);
subProvidedProduct.setCreated(new Date());
subProvidedProduct.setUpdated(new Date());
subProvidedProduct.setHref("http://localhost");
subProvidedProduct.setAttributes(Collections.EMPTY_SET);
ProductCertificate pcert = new ProductCertificate();
pcert.setKey("euh0876puhapodifbvj094");
pcert.setCert("hpj-08ha-w4gpoknpon*)&^%#");
pcert.setCreated(new Date());
pcert.setUpdated(new Date());
when(pp.getProductId()).thenReturn("12345");
when(pool.getProvidedProducts()).thenReturn(ppset);
when(pool.getProductId()).thenReturn("MKT-prod");
when(pool.getDerivedProvidedProducts()).thenReturn(sppSet);
when(pool.getDerivedProductId()).thenReturn(subProduct.getId());
when(spp.getProductId()).thenReturn(subProvidedProduct.getId());
when(ent.getPool()).thenReturn(pool);
when(mrules.getRules()).thenReturn("foobar");
when(pki.getSHA256WithRSAHash(any(InputStream.class))).thenReturn(
"signature".getBytes());
when(rc.getRules()).thenReturn(mrules);
when(consumer.getEntitlements()).thenReturn(entitlements);