PoolDTO extends TimestampedCandlepinDTO<PoolDTO> implements LinkableDTO { @JsonIgnore public boolean addProvidedProduct(ProvidedProductDTO providedProduct) { if (isNullOrIncomplete(providedProduct)) { throw new IllegalArgumentException("providedProduct is null or incomplete"); } if (this.providedProducts == null) { this.providedProducts = new HashSet<>(); } return this.providedProducts.add(providedProduct); } PoolDTO();  PoolDTO(PoolDTO source); @HateoasInclude String getId(); PoolDTO setId(String id); @JsonProperty String getType(); @JsonIgnore PoolDTO setType(String type); Boolean isLocked(); PoolDTO setLocked(Boolean locked); OwnerDTO getOwner(); PoolDTO setOwner(OwnerDTO owner); Boolean isActiveSubscription(); PoolDTO setActiveSubscription(Boolean activeSubscription); EntitlementDTO getSourceEntitlement(); PoolDTO setSourceEntitlement(EntitlementDTO sourceEntitlement); Long getQuantity(); PoolDTO setQuantity(Long quantity); Date getStartDate(); PoolDTO setStartDate(Date startDate); Date getEndDate(); PoolDTO setEndDate(Date endDate); @JsonSerialize(using = CandlepinLegacyAttributeSerializer.class) Map<String, String> getAttributes(); @JsonDeserialize(using = CandlepinAttributeDeserializer.class) PoolDTO setAttributes(Map<String, String> attributes); @JsonIgnore boolean hasAttribute(String key); @JsonIgnore boolean removeAttribute(String key); String getRestrictedToUsername(); PoolDTO setRestrictedToUsername(String restrictedToUsername); String getContractNumber(); PoolDTO setContractNumber(String contractNumber); String getAccountNumber(); PoolDTO setAccountNumber(String accountNumber); String getOrderNumber(); PoolDTO setOrderNumber(String orderNumber); Long getConsumed(); PoolDTO setConsumed(Long consumed); Long getExported(); PoolDTO setExported(Long exported); @JsonProperty Set<BrandingDTO> getBranding(); @JsonIgnore PoolDTO setBranding(Set<BrandingDTO> branding); @JsonIgnore boolean addBranding(BrandingDTO branding); Map<String, String> getCalculatedAttributes(); PoolDTO setCalculatedAttributes(Map<String, String> calculatedAttributes); String getUpstreamPoolId(); PoolDTO setUpstreamPoolId(String upstreamPoolId); String getUpstreamEntitlementId(); PoolDTO setUpstreamEntitlementId(String upstreamEntitlementId); String getUpstreamConsumerId(); PoolDTO setUpstreamConsumerId(String upstreamConsumerId); @JsonProperty @HateoasInclude String getProductName(); @JsonIgnore PoolDTO setProductName(String productName); @HateoasInclude String getProductId(); PoolDTO setProductId(String productId); @JsonSerialize(using = CandlepinLegacyAttributeSerializer.class) Map<String, String> getProductAttributes(); @JsonDeserialize(using = CandlepinAttributeDeserializer.class) PoolDTO setProductAttributes(Map<String, String> productAttributes); @JsonIgnore boolean hasProductAttribute(String key); @JsonProperty String getStackId(); @JsonIgnore PoolDTO setStackId(String stackId); @JsonProperty Boolean isStacked(); @JsonIgnore PoolDTO setStacked(Boolean stacked); @JsonProperty Boolean isDevelopmentPool(); @JsonIgnore PoolDTO setDevelopmentPool(Boolean developmentPool); @HateoasInclude @Override String getHref(); @JsonSerialize(using = CandlepinLegacyAttributeSerializer.class) Map<String, String> getDerivedProductAttributes(); @JsonDeserialize(using = CandlepinAttributeDeserializer.class) PoolDTO setDerivedProductAttributes(Map<String, String> derivedProductAttributes); String getDerivedProductId(); PoolDTO setDerivedProductId(String derivedProductId); @JsonProperty String getDerivedProductName(); @JsonIgnore PoolDTO setDerivedProductName(String derivedProductName); Set<ProvidedProductDTO> getProvidedProducts(); PoolDTO setProvidedProducts(Set<ProvidedProductDTO> providedProducts); @JsonIgnore boolean addProvidedProduct(ProvidedProductDTO providedProduct); Set<ProvidedProductDTO> getDerivedProvidedProducts(); PoolDTO setDerivedProvidedProducts(Set<ProvidedProductDTO> derivedProvidedProducts); @JsonIgnore boolean addDerivedProvidedProduct(ProvidedProductDTO derivedProvidedProduct); @JsonProperty String getSourceStackId(); @JsonIgnore PoolDTO setSourceStackId(String sourceStackId); String getSubscriptionSubKey(); PoolDTO setSubscriptionSubKey(String subscriptionSubKey); String getSubscriptionId(); PoolDTO setSubscriptionId(String subscriptionId); @JsonIgnore CertificateDTO getCertificate(); @JsonProperty PoolDTO setCertificate(CertificateDTO certificate); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); @Override PoolDTO clone(); @Override PoolDTO populate(PoolDTO source); static final long serialVersionUID; }
@Test public void testAddProvidedProductWithAbsentProvidedProduct() { PoolDTO dto = new PoolDTO(); PoolDTO.ProvidedProductDTO product = new PoolDTO.ProvidedProductDTO("test-id-provided-product-1", "test-name-provided-product-1"); assertTrue(dto.addProvidedProduct(product)); }
@Test public void testAddProvidedProductWithPresentProvidedProduct() { PoolDTO dto = new PoolDTO(); PoolDTO.ProvidedProductDTO product = new PoolDTO.ProvidedProductDTO("test-id-provided-product-2", "test-name-provided-product-2"); assertTrue(dto.addProvidedProduct(product)); PoolDTO.ProvidedProductDTO product2 = new PoolDTO.ProvidedProductDTO("test-id-provided-product-2", "test-name-provided-product-2"); assertFalse(dto.addProvidedProduct(product2)); }
@Test(expected = IllegalArgumentException.class) public void testAddProvidedProductWithNullInput() { PoolDTO dto = new PoolDTO(); dto.addProvidedProduct(null); }
@Test(expected = IllegalArgumentException.class) public void testAddProvidedProductWithEmptyId() { PoolDTO dto = new PoolDTO(); PoolDTO.ProvidedProductDTO product = new PoolDTO.ProvidedProductDTO("", "test-name-provided-product-3"); dto.addProvidedProduct(product); }