PoolDTO extends CandlepinDTO<PoolDTO> { @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); 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); Long getConsumed(); PoolDTO setConsumed(Long consumed); @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); String getDerivedProductId(); PoolDTO setDerivedProductId(String derivedProductId); 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); @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); }