use of org.candlepin.dto.api.v1.ContentDTO in project candlepin by candlepin.
the class OwnerContentResourceTest method createContentWhenContentAlreadyExists.
@Test
public void createContentWhenContentAlreadyExists() {
// Note:
// The current behavior of createContent is to update content if content already exists
// with the given RHID. So, our expected behavior in this test is to trigger an update.
Owner owner = this.createOwner("test_owner");
Content content = this.createContent("test_content", "test_content", owner);
ContentDTO cdto = TestUtil.createContentDTO("test_content", "updated_name");
cdto.setLabel("test-label");
cdto.setType("test-test");
cdto.setVendor("test-vendor");
assertNotNull(this.ownerContentCurator.getContentById(owner, cdto.getId()));
ContentDTO output = this.ownerContentResource.createContent(owner.getKey(), cdto);
assertNotNull(output);
assertEquals(cdto.getId(), output.getId());
assertEquals(cdto.getName(), output.getName());
Content entity = this.ownerContentCurator.getContentById(owner, cdto.getId());
assertNotNull(entity);
assertEquals(cdto.getName(), entity.getName());
}
use of org.candlepin.dto.api.v1.ContentDTO in project candlepin by candlepin.
the class OwnerContentResourceTest method getContentNotFound.
@Test(expected = NotFoundException.class)
public void getContentNotFound() {
Owner owner = this.createOwner("test_owner");
ContentDTO output = this.ownerContentResource.getContent(owner.getKey(), "test_content");
}
use of org.candlepin.dto.api.v1.ContentDTO in project candlepin by candlepin.
the class OwnerContentResourceTest method testUpdateContentThrowsExceptionWhenOwnerDoesNotExist.
@Test(expected = NotFoundException.class)
public void testUpdateContentThrowsExceptionWhenOwnerDoesNotExist() {
ContentDTO cdto = TestUtil.createContentDTO("test_content");
this.ownerContentResource.updateContent("fake_owner_key", cdto.getId(), cdto);
}
use of org.candlepin.dto.api.v1.ContentDTO in project candlepin by candlepin.
the class OwnerContentResourceTest method updateContent.
@Test
public void updateContent() {
Owner owner = this.createOwner("test_owner");
Content content = this.createContent("test_content", "test_content", owner);
ContentDTO cdto = TestUtil.createContentDTO("test_content", "updated_name");
assertNotNull(this.ownerContentCurator.getContentById(owner, cdto.getId()));
ContentDTO output = this.ownerContentResource.updateContent(owner.getKey(), cdto.getId(), cdto);
assertNotNull(output);
assertEquals(cdto.getId(), output.getId());
assertEquals(cdto.getName(), output.getName());
Content entity = this.ownerContentCurator.getContentById(owner, cdto.getId());
assertNotNull(entity);
assertEquals(cdto.getName(), entity.getName());
}
use of org.candlepin.dto.api.v1.ContentDTO in project candlepin by candlepin.
the class ProductImporterTest method testVendorSetToUnknown.
@Test
public void testVendorSetToUnknown() throws Exception {
Product product = TestUtil.createProduct();
addNoVendorContentTo(product);
String json = getJsonForProduct(product);
Reader reader = new StringReader(json);
ProductDTO created = importer.createObject(mapper, reader, owner);
ContentDTO c = created.getProductContent().iterator().next().getContent();
assertEquals("unknown", c.getVendor());
}
Aggregations