use of org.candlepin.dto.api.v1.ContentDTO in project candlepin by candlepin.
the class OwnerContentResourceTest method createContent.
@Test
public void createContent() {
Owner owner = this.createOwner("test_owner");
ContentDTO cdto = TestUtil.createContentDTO("test_content");
cdto.setLabel("test-label");
cdto.setType("test-test");
cdto.setVendor("test-vendor");
assertNull(this.ownerContentCurator.getContentById(owner, cdto.getId()));
ContentDTO output = this.ownerContentResource.createContent(owner.getKey(), cdto);
assertNotNull(output);
assertEquals(cdto.getId(), output.getId());
Content entity = this.ownerContentCurator.getContentById(owner, cdto.getId());
assertNotNull(entity);
assertEquals(cdto.getName(), entity.getName());
assertEquals(cdto.getLabel(), entity.getLabel());
assertEquals(cdto.getType(), entity.getType());
assertEquals(cdto.getVendor(), entity.getVendor());
}
use of org.candlepin.dto.api.v1.ContentDTO in project candlepin by candlepin.
the class OwnerContentResourceTest method listContent.
@Test
public void listContent() throws Exception {
Owner owner = this.createOwner("test_owner");
Content content = this.createContent("test_content", "test_content", owner);
ContentDTO cdto = this.modelTranslator.translate(content, ContentDTO.class);
CandlepinQuery<ContentDTO> response = this.ownerContentResource.listContent(owner.getKey());
assertNotNull(response);
Collection<ContentDTO> received = response.list();
assertEquals(1, received.size());
assertTrue(received.contains(cdto));
}
use of org.candlepin.dto.api.v1.ContentDTO in project candlepin by candlepin.
the class OwnerContentResourceTest method updateLockedContent.
@Test(expected = ForbiddenException.class)
public void updateLockedContent() {
Owner owner = this.createOwner("test_owner");
Content content = this.createContent("test_content", "test_content", owner);
ContentDTO cdto = TestUtil.createContentDTO("test_content", "updated_name");
content.setLocked(true);
this.contentCurator.merge(content);
assertNotNull(this.ownerContentCurator.getContentById(owner, cdto.getId()));
try {
this.ownerContentResource.updateContent(owner.getKey(), cdto.getId(), cdto);
} catch (ForbiddenException e) {
Content entity = this.ownerContentCurator.getContentById(owner, cdto.getId());
assertNotNull(entity);
assertEquals(content, entity);
assertNotEquals(cdto.getName(), entity.getName());
throw e;
}
}
use of org.candlepin.dto.api.v1.ContentDTO in project candlepin by candlepin.
the class OwnerContentResourceTest method getContent.
@Test
public void getContent() {
Owner owner = this.createOwner("test_owner");
Content content = this.createContent("test_content", "test_content", owner);
ContentDTO output = this.ownerContentResource.getContent(owner.getKey(), content.getId());
assertNotNull(output);
assertEquals(content.getId(), output.getId());
}
use of org.candlepin.dto.api.v1.ContentDTO in project candlepin by candlepin.
the class OwnerContentResourceTest method createContentWhenContentAlreadyExistsAndLocked.
@Test(expected = ForbiddenException.class)
public void createContentWhenContentAlreadyExistsAndLocked() {
// 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");
content.setLocked(true);
this.contentCurator.merge(content);
assertNotNull(this.ownerContentCurator.getContentById(owner, cdto.getId()));
try {
ContentDTO output = this.ownerContentResource.createContent(owner.getKey(), cdto);
} catch (ForbiddenException e) {
Content entity = this.ownerContentCurator.getContentById(owner, cdto.getId());
assertNotNull(entity);
assertEquals(content, entity);
assertNotEquals(cdto.getName(), entity.getName());
throw e;
}
}
Aggregations