PoolHelper { public static Pool clonePool(Pool sourcePool, Product product, String quantity, Map<String, String> attributes, String subKey, OwnerProductCurator curator, Entitlement sourceEntitlement, Consumer sourceConsumer, ProductCurator productCurator) { Pool pool = createPool(product, sourcePool.getOwner(), quantity, sourcePool.getStartDate(), sourcePool.getEndDate(), sourcePool.getContractNumber(), sourcePool.getAccountNumber(), sourcePool.getOrderNumber(), new HashSet<>(), sourceEntitlement, sourceConsumer, sourcePool); SourceSubscription srcSub = sourcePool.getSourceSubscription(); if (srcSub != null && srcSub.getSubscriptionId() != null) { pool.setSourceSubscription(new SourceSubscription(srcSub.getSubscriptionId(), subKey)); } copyProvidedProducts(sourcePool, pool, curator, productCurator); for (Entry<String, String> entry : attributes.entrySet()) { pool.setAttribute(entry.getKey(), entry.getValue()); } if (sourcePool.isLocked()) { pool.setLocked(true); } pool.setUpstreamPoolId(sourcePool.getUpstreamPoolId()); pool.setUpstreamEntitlementId(sourcePool.getUpstreamEntitlementId()); pool.setUpstreamConsumerId(sourcePool.getUpstreamConsumerId()); return pool; } private  PoolHelper(); static Map<String, String> getFlattenedAttributes(Pool pool); static PoolOperationCallback createHostRestrictedPools(PoolManager poolManager, Consumer consumer,
        List<Pool> pools, Map<String, Entitlement> sourceEntitlements,
        Map<String, Map<String, String>> attributeMaps, ProductCurator productCurator); static Pool clonePool(Pool sourcePool, Product product, String quantity,
        Map<String, String> attributes, String subKey, OwnerProductCurator curator,
        Entitlement sourceEntitlement, Consumer sourceConsumer, ProductCurator productCurator); static boolean checkForOrderChanges(Pool existingPool, Pool pool);  }
@Test public void clonePoolTest() { Product product = TestUtil.createProduct(); Product product2 = TestUtil.createProduct(); Map<String, String> attributes = new HashMap<>(); for (int i = 0; i < 3; i++) { attributes.put("a" + i, "b" + i); } Branding branding = new Branding(null, "id", "name", "type"); product2.setBranding(Arrays.asList(branding)); Pool pool = TestUtil.createPool(owner, product); String quant = "unlimited"; Pool clone = PoolHelper.clonePool(pool, product2, quant, attributes, "TaylorSwift", null, ent, TestUtil.createConsumer(), productCurator); assertEquals(owner, clone.getOwner()); assertEquals(new Long(-1L), clone.getQuantity()); assertEquals(product2, clone.getProduct()); assertEquals(attributes.size() + 1, clone.getAttributes().size()); for (int i = 0; i < 3; i++) { assertEquals("b" + i, clone.getAttributeValue("a" + i)); } assertNotEquals(pool.getSourceSubscription(), clone); assertEquals(pool.getSourceSubscription().getSubscriptionId(), clone.getSubscriptionId()); assertEquals(pool.getSourceSubscription().getSubscriptionId(), clone.getSourceSubscription().getSubscriptionId()); assertEquals("TaylorSwift", clone.getSourceSubscription().getSubscriptionSubKey()); assertEquals(1, clone.getProduct().getBranding().size()); Branding brandingClone = clone.getProduct().getBranding().iterator().next(); assertEquals(branding, brandingClone); }