use of org.candlepin.model.Content 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;
}
}
use of org.candlepin.model.Content 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.model.Content 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.model.Content in project candlepin by candlepin.
the class DefaultEntitlementCertServiceAdapterTest method testSpecificLargeContent.
@Test
public void testSpecificLargeContent() throws IOException {
Set<Product> products = new HashSet<>();
products.add(largeContentProduct);
largeContentProduct.setProductContent(null);
for (Content content : largeContent) {
largeContentProduct.addContent(content, false);
}
consumer.setFact("system.certificate_version", "3.3");
Set<X509ByteExtensionWrapper> byteExtensions = certServiceAdapter.prepareV3ByteExtensions(product, getProductModels(product, products, "prefix", largeContentEntitlement), "prefix", null);
Map<String, X509ByteExtensionWrapper> byteMap = new HashMap<>();
for (X509ByteExtensionWrapper ext : byteExtensions) {
byteMap.put(ext.getOid(), ext);
}
assertTrue(byteMap.containsKey("1.3.6.1.4.1.2312.9.7"));
List<String> contentSetList = new ArrayList<>();
try {
contentSetList = v3extensionUtil.hydrateContentPackage(byteMap.get("1.3.6.1.4.1.2312.9.7").getValue());
} catch (Exception e) {
throw new RuntimeException(e);
}
assertEquals(largeContent.size(), contentSetList.size());
for (String url : largeTestUrls) {
assertTrue(contentSetList.contains("/prefix" + url));
}
List<String> testList = Arrays.asList(largeTestUrls);
for (String url : contentSetList) {
assertTrue(testList.contains(url.substring(7)));
}
}
use of org.candlepin.model.Content in project candlepin by candlepin.
the class DatabaseTestFixture method createContent.
protected Content createContent(String id, String name, Owner... owners) {
Content content = TestUtil.createContent(id, name);
content = this.contentCurator.create(content);
this.ownerContentCurator.mapContentToOwners(content, owners);
return content;
}
Aggregations