Search in sources :

Example 6 with ActivationKeyDTO

use of org.candlepin.dto.api.v1.ActivationKeyDTO in project candlepin by candlepin.

the class OwnerResourceTest method testActivationKeyTooLongRelease.

@Test(expected = BadRequestException.class)
public void testActivationKeyTooLongRelease() {
    OwnerCurator oc = mock(OwnerCurator.class);
    ProductCurator pc = mock(ProductCurator.class);
    Owner o = new Owner();
    o.setKey("owner-key");
    OwnerResource ownerres = new OwnerResource(oc, pc, null, null, i18n, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, this.modelTranslator);
    when(oc.lookupByKey(anyString())).thenReturn(o);
    ActivationKeyDTO key = new ActivationKeyDTO();
    key.setReleaseVersion(TestUtil.getStringOfSize(256));
    key = ownerres.createActivationKey(owner.getKey(), key);
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) ActivationKeyDTO(org.candlepin.dto.api.v1.ActivationKeyDTO) ProductCurator(org.candlepin.model.ProductCurator) Test(org.junit.Test)

Example 7 with ActivationKeyDTO

use of org.candlepin.dto.api.v1.ActivationKeyDTO in project candlepin by candlepin.

the class OwnerResourceTest method testActivationKeyCreateRead.

@Test
public void testActivationKeyCreateRead() {
    ActivationKeyDTO key = new ActivationKeyDTO();
    key.setName("dd");
    key.setReleaseVersion("release1");
    key = ownerResource.createActivationKey(owner.getKey(), key);
    assertNotNull(key.getId());
    assertEquals(key.getOwner().getId(), owner.getId());
    assertEquals(key.getReleaseVersion(), "release1");
    CandlepinQuery<ActivationKeyDTO> result = ownerResource.ownerActivationKeys(owner.getKey(), null);
    assertNotNull(result);
    List<ActivationKeyDTO> keys = result.list();
    assertEquals(1, keys.size());
}
Also used : ActivationKeyDTO(org.candlepin.dto.api.v1.ActivationKeyDTO) Test(org.junit.Test)

Example 8 with ActivationKeyDTO

use of org.candlepin.dto.api.v1.ActivationKeyDTO in project candlepin by candlepin.

the class ActivationKeyResourceTest method testUpdateTooLongRelease.

@Test(expected = BadRequestException.class)
public void testUpdateTooLongRelease() {
    ActivationKey key = new ActivationKey();
    OwnerDTO ownerDto = new OwnerDTO();
    key.setOwner(owner);
    key.setName("dd");
    key.setServiceLevel("level1");
    key.setReleaseVer(new Release("release1"));
    activationKeyCurator.create(key);
    ActivationKeyDTO update = new ActivationKeyDTO();
    update.setOwner(ownerDto);
    update.setName("dd");
    update.setServiceLevel("level1");
    update.setReleaseVersion(TestUtil.getStringOfSize(256));
    activationKeyResource.updateActivationKey(key.getId(), update);
}
Also used : ActivationKeyDTO(org.candlepin.dto.api.v1.ActivationKeyDTO) OwnerDTO(org.candlepin.dto.api.v1.OwnerDTO) ActivationKey(org.candlepin.model.activationkeys.ActivationKey) Release(org.candlepin.model.Release) Test(org.junit.Test)

Aggregations

ActivationKeyDTO (org.candlepin.dto.api.v1.ActivationKeyDTO)8 Test (org.junit.Test)7 Owner (org.candlepin.model.Owner)3 OwnerCurator (org.candlepin.model.OwnerCurator)3 ProductCurator (org.candlepin.model.ProductCurator)3 Release (org.candlepin.model.Release)3 ActivationKey (org.candlepin.model.activationkeys.ActivationKey)3 OwnerDTO (org.candlepin.dto.api.v1.OwnerDTO)1 Pool (org.candlepin.model.Pool)1 Product (org.candlepin.model.Product)1 ActivationKeyContentOverride (org.candlepin.model.activationkeys.ActivationKeyContentOverride)1 ActivationKeyCurator (org.candlepin.model.activationkeys.ActivationKeyCurator)1