DistributorVersionDTO extends TimestampedCandlepinDTO<DistributorVersionDTO> { @JsonIgnore public boolean addCapability(DistributorVersionCapabilityDTO capability) { if (isNullOrIncomplete(capability)) { throw new IllegalArgumentException("capability is null or incomplete"); } if (this.capabilities == null) { this.capabilities = new HashSet<>(); } return this.capabilities.add(capability); } DistributorVersionDTO();  DistributorVersionDTO(DistributorVersionDTO source); String getId(); DistributorVersionDTO setId(String id); String getName(); DistributorVersionDTO setName(String name); String getDisplayName(); DistributorVersionDTO setDisplayName(String displayName); Set<DistributorVersionCapabilityDTO> getCapabilities(); DistributorVersionDTO setCapabilities(Set<DistributorVersionCapabilityDTO> capabilities); @JsonIgnore boolean addCapability(DistributorVersionCapabilityDTO capability); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); @Override DistributorVersionDTO clone(); @Override DistributorVersionDTO populate(DistributorVersionDTO source); static final long serialVersionUID; }
@Test public void testAddCapabilityWithAbsentCapability() { DistributorVersionDTO dto = new DistributorVersionDTO(); DistributorVersionDTO.DistributorVersionCapabilityDTO dvcDTO = new DistributorVersionDTO.DistributorVersionCapabilityDTO("dvc-id-1", "dvc-name-1"); assertTrue(dto.addCapability(dvcDTO)); }
@Test public void testAddCapabilityWithPresentCapability() { DistributorVersionDTO dto = new DistributorVersionDTO(); DistributorVersionDTO.DistributorVersionCapabilityDTO dvcDTO1 = new DistributorVersionDTO.DistributorVersionCapabilityDTO("dvc-id-2", "dvc-name-2"); assertTrue(dto.addCapability(dvcDTO1)); DistributorVersionDTO.DistributorVersionCapabilityDTO dvcDTO2 = new DistributorVersionDTO.DistributorVersionCapabilityDTO("dvc-id-2", "dvc-name-2"); assertFalse(dto.addCapability(dvcDTO2)); }
@Test(expected = IllegalArgumentException.class) public void testAddCapabilityWithNullInput() { DistributorVersionDTO dto = new DistributorVersionDTO(); dto.addCapability(null); }
@Test(expected = IllegalArgumentException.class) public void testAddCapabilityWithEmptyName() { DistributorVersionDTO dto = new DistributorVersionDTO(); DistributorVersionDTO.DistributorVersionCapabilityDTO dvcDTO = new DistributorVersionDTO.DistributorVersionCapabilityDTO("dvc-id-3", ""); dto.addCapability(dvcDTO); }