Search in sources :

Example 91 with Owner

use of org.candlepin.model.Owner in project candlepin by candlepin.

the class ConsumerCuratorPermissionsTest method setUpTestObjects.

@Before
public void setUpTestObjects() {
    owner = new Owner("Example Corporation");
    ownerCurator.create(owner);
    consumerType = new ConsumerType(CONSUMER_TYPE_NAME);
    consumerTypeCurator.create(consumerType);
}
Also used : Owner(org.candlepin.model.Owner) ConsumerType(org.candlepin.model.ConsumerType) Before(org.junit.Before)

Example 92 with Owner

use of org.candlepin.model.Owner in project candlepin by candlepin.

the class UsernameConsumersPermissionTest method blocksConsumersInOtherOrgDespiteSameUsername.

@Test
public void blocksConsumersInOtherOrgDespiteSameUsername() {
    Owner other = new Owner("ownerkey2", "My Org 2");
    other.setId(TestUtil.randomString());
    Consumer c = new Consumer("consumer", username, other, null);
    assertFalse(perm.canAccess(c, SubResource.NONE, Access.READ_ONLY));
    assertFalse(perm.canAccess(c, SubResource.NONE, Access.ALL));
}
Also used : Owner(org.candlepin.model.Owner) Consumer(org.candlepin.model.Consumer) Test(org.junit.Test)

Example 93 with Owner

use of org.candlepin.model.Owner in project candlepin by candlepin.

the class ContentManagerTest method testCreateContentThatAlreadyExists.

@Test(expected = IllegalStateException.class)
public void testCreateContentThatAlreadyExists() {
    Owner owner = this.createOwner("test-owner", "Test Owner");
    ContentDTO dto = TestUtil.createContentDTO("c1", "content-1");
    dto.setLabel("test-label");
    dto.setType("test-test");
    dto.setVendor("test-vendor");
    Content output = this.contentManager.createContent(dto, owner);
    // Verify the creation worked
    assertNotNull(output);
    assertEquals(output, this.ownerContentCurator.getContentById(owner, dto.getId()));
    // This should fail, since it already exists
    this.contentManager.createContent(dto, owner);
}
Also used : ContentDTO(org.candlepin.dto.api.v1.ContentDTO) Owner(org.candlepin.model.Owner) Content(org.candlepin.model.Content) Test(org.junit.Test)

Example 94 with Owner

use of org.candlepin.model.Owner in project candlepin by candlepin.

the class ContentManagerTest method testCreateContentMergeWithExisting.

@Test
public void testCreateContentMergeWithExisting() {
    Owner owner1 = this.createOwner("test-owner-1", "Test Owner 1");
    Owner owner2 = this.createOwner("test-owner-2", "Test Owner 2");
    Content content1 = TestUtil.createContent("c1", "content-1");
    Content content2 = this.createContent("c1", "content-1", owner2);
    ContentDTO cdto = this.modelTranslator.translate(content1, ContentDTO.class);
    Content output = this.contentManager.createContent(cdto, owner1);
    assertEquals(content2.getUuid(), output.getUuid());
    assertEquals(content2, output);
    assertTrue(this.ownerContentCurator.isContentMappedToOwner(output, owner1));
    assertTrue(this.ownerContentCurator.isContentMappedToOwner(output, owner2));
}
Also used : ContentDTO(org.candlepin.dto.api.v1.ContentDTO) Owner(org.candlepin.model.Owner) Content(org.candlepin.model.Content) Test(org.junit.Test)

Example 95 with Owner

use of org.candlepin.model.Owner in project candlepin by candlepin.

the class ContentManagerTest method testUpdateContentDivergeFromExisting.

@Test
@Parameters({ "false", "true" })
public void testUpdateContentDivergeFromExisting(boolean regenCerts) {
    Owner owner1 = this.createOwner("test-owner-1", "Test Owner 1");
    Owner owner2 = this.createOwner("test-owner-2", "Test Owner 2");
    Product product = this.createProduct("p1", "product-1", owner1);
    Content content = this.createContent("c1", "content-1", owner1, owner2);
    ContentDTO update = TestUtil.createContentDTO("c1", "updated content");
    product.addContent(content, true);
    product = this.productCurator.merge(product);
    assertTrue(this.ownerContentCurator.isContentMappedToOwner(content, owner1));
    assertTrue(this.ownerContentCurator.isContentMappedToOwner(content, owner2));
    Content output = this.contentManager.updateContent(update, owner1, regenCerts);
    assertNotEquals(output.getUuid(), content.getUuid());
    assertTrue(this.ownerContentCurator.isContentMappedToOwner(output, owner1));
    assertFalse(this.ownerContentCurator.isContentMappedToOwner(output, owner2));
    assertFalse(this.ownerContentCurator.isContentMappedToOwner(content, owner1));
    assertTrue(this.ownerContentCurator.isContentMappedToOwner(content, owner2));
    if (regenCerts) {
        verify(this.mockEntCertGenerator, times(1)).regenerateCertificatesOf(eq(Arrays.asList(owner1)), anyCollectionOf(Product.class), anyBoolean());
    } else {
        verifyZeroInteractions(this.mockEntCertGenerator);
    }
}
Also used : ContentDTO(org.candlepin.dto.api.v1.ContentDTO) Owner(org.candlepin.model.Owner) Content(org.candlepin.model.Content) Product(org.candlepin.model.Product) Parameters(junitparams.Parameters) Test(org.junit.Test)

Aggregations

Owner (org.candlepin.model.Owner)405 Test (org.junit.Test)254 Product (org.candlepin.model.Product)153 Consumer (org.candlepin.model.Consumer)127 Pool (org.candlepin.model.Pool)79 Date (java.util.Date)72 ConsumerInstalledProduct (org.candlepin.model.ConsumerInstalledProduct)71 ArrayList (java.util.ArrayList)58 Produces (javax.ws.rs.Produces)52 ConsumerType (org.candlepin.model.ConsumerType)52 ApiOperation (io.swagger.annotations.ApiOperation)50 HashSet (java.util.HashSet)44 Entitlement (org.candlepin.model.Entitlement)44 Path (javax.ws.rs.Path)42 HashMap (java.util.HashMap)41 ApiResponses (io.swagger.annotations.ApiResponses)40 Content (org.candlepin.model.Content)39 BadRequestException (org.candlepin.common.exceptions.BadRequestException)37 Subscription (org.candlepin.model.dto.Subscription)32 List (java.util.List)29