Search in sources :

Example 6 with ProductCurator

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

the class RulesObjectMapperTest method begin.

@Before
public void begin() {
    context = new HashMap<>();
    owner = new Owner("test");
    ProductCurator productCurator = Mockito.mock(ProductCurator.class);
    objMapper = new RulesObjectMapper(new ProductCachedSerializationModule(productCurator));
}
Also used : ProductCachedSerializationModule(org.candlepin.jackson.ProductCachedSerializationModule) Owner(org.candlepin.model.Owner) ProductCurator(org.candlepin.model.ProductCurator) Before(org.junit.Before)

Example 7 with ProductCurator

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

the class ContentResourceTest method init.

@Before
public void init() {
    i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
    cc = mock(ContentCurator.class);
    envContentCurator = mock(EnvironmentContentCurator.class);
    poolManager = mock(PoolManager.class);
    oc = mock(OwnerCurator.class);
    productCurator = mock(ProductCurator.class);
    this.modelTranslator = new SimpleModelTranslator();
    this.modelTranslator.registerTranslator(new ContentTranslator(), Content.class, ContentDTO.class);
    cr = new ContentResource(cc, i18n, new DefaultUniqueIdGenerator(), envContentCurator, poolManager, productCurator, oc, this.modelTranslator);
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) ContentTranslator(org.candlepin.dto.api.v1.ContentTranslator) SimpleModelTranslator(org.candlepin.dto.SimpleModelTranslator) EnvironmentContentCurator(org.candlepin.model.EnvironmentContentCurator) ContentCurator(org.candlepin.model.ContentCurator) ProductCurator(org.candlepin.model.ProductCurator) DefaultUniqueIdGenerator(org.candlepin.service.impl.DefaultUniqueIdGenerator) EnvironmentContentCurator(org.candlepin.model.EnvironmentContentCurator) PoolManager(org.candlepin.controller.PoolManager) Before(org.junit.Before)

Example 8 with ProductCurator

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

the class OwnerResourceTest method testActivationKeyNameUnique.

@Test(expected = BadRequestException.class)
public void testActivationKeyNameUnique() {
    ActivationKeyDTO ak = mock(ActivationKeyDTO.class);
    ActivationKey akOld = mock(ActivationKey.class);
    ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
    Owner o = mock(Owner.class);
    OwnerCurator oc = mock(OwnerCurator.class);
    ProductCurator pc = mock(ProductCurator.class);
    when(ak.getName()).thenReturn("testKey");
    when(akc.lookupForOwner(eq("testKey"), eq(o))).thenReturn(akOld);
    when(oc.lookupByKey(eq("testOwner"))).thenReturn(o);
    OwnerResource ownerres = new OwnerResource(oc, pc, akc, null, i18n, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, contentOverrideValidator, null, null, null, null, null, null, this.modelTranslator);
    ownerres.createActivationKey("testOwner", ak);
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) ActivationKeyDTO(org.candlepin.dto.api.v1.ActivationKeyDTO) ActivationKeyCurator(org.candlepin.model.activationkeys.ActivationKeyCurator) ProductCurator(org.candlepin.model.ProductCurator) ActivationKey(org.candlepin.model.activationkeys.ActivationKey) Test(org.junit.Test)

Example 9 with ProductCurator

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

the class OwnerResourceTest method upstreamConsumers.

@Test
public void upstreamConsumers() {
    Principal p = mock(Principal.class);
    OwnerCurator oc = mock(OwnerCurator.class);
    ProductCurator pc = mock(ProductCurator.class);
    UpstreamConsumer upstream = mock(UpstreamConsumer.class);
    Owner owner = mock(Owner.class);
    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, contentOverrideValidator, serviceLevelValidator, null, null, null, null, null, this.modelTranslator);
    when(oc.lookupByKey(eq("admin"))).thenReturn(owner);
    when(owner.getUpstreamConsumer()).thenReturn(upstream);
    List<UpstreamConsumerDTO> results = ownerres.getUpstreamConsumers(p, "admin");
    assertNotNull(results);
    assertEquals(1, results.size());
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) UpstreamConsumerDTO(org.candlepin.dto.api.v1.UpstreamConsumerDTO) ProductCurator(org.candlepin.model.ProductCurator) UpstreamConsumer(org.candlepin.model.UpstreamConsumer) ConsumerPrincipal(org.candlepin.auth.ConsumerPrincipal) UserPrincipal(org.candlepin.auth.UserPrincipal) Principal(org.candlepin.auth.Principal) Test(org.junit.Test)

Example 10 with ProductCurator

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

the class ProductResourceTest method testDeleteProductWithSubscriptions.

@Test(expected = BadRequestException.class)
public void testDeleteProductWithSubscriptions() {
    ProductCurator pc = mock(ProductCurator.class);
    I18n i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
    ProductResource pr = new ProductResource(pc, null, null, config, i18n, this.modelTranslator);
    Owner o = mock(Owner.class);
    Product p = mock(Product.class);
    // when(pc.lookupById(eq(o), eq("10"))).thenReturn(p);
    Set<Subscription> subs = new HashSet<>();
    Subscription s = mock(Subscription.class);
    subs.add(s);
    when(pc.productHasSubscriptions(eq(o), eq(p))).thenReturn(true);
    pr.deleteProduct("10");
}
Also used : Owner(org.candlepin.model.Owner) ProductCurator(org.candlepin.model.ProductCurator) Product(org.candlepin.model.Product) Subscription(org.candlepin.model.dto.Subscription) I18n(org.xnap.commons.i18n.I18n) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

ProductCurator (org.candlepin.model.ProductCurator)15 Owner (org.candlepin.model.Owner)10 OwnerCurator (org.candlepin.model.OwnerCurator)10 Test (org.junit.Test)10 Before (org.junit.Before)4 ConsumerPrincipal (org.candlepin.auth.ConsumerPrincipal)3 Principal (org.candlepin.auth.Principal)3 UserPrincipal (org.candlepin.auth.UserPrincipal)3 ActivationKeyDTO (org.candlepin.dto.api.v1.ActivationKeyDTO)3 ProductCachedSerializationModule (org.candlepin.jackson.ProductCachedSerializationModule)3 HashSet (java.util.HashSet)2 CandlepinPoolManager (org.candlepin.controller.CandlepinPoolManager)2 PoolManager (org.candlepin.controller.PoolManager)2 ConsumerCurator (org.candlepin.model.ConsumerCurator)2 EntitlementCertificateCurator (org.candlepin.model.EntitlementCertificateCurator)2 EntitlementCurator (org.candlepin.model.EntitlementCurator)2 Product (org.candlepin.model.Product)2 UeberCertificate (org.candlepin.model.UeberCertificate)2 UeberCertificateCurator (org.candlepin.model.UeberCertificateCurator)2 UeberCertificateGenerator (org.candlepin.model.UeberCertificateGenerator)2