Search in sources :

Example 1 with ProductCurator

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

the class OwnerResourceTest method testCreateUeberCertificateFromScratch.

@Test
public void testCreateUeberCertificateFromScratch() {
    Principal principal = setupPrincipal(owner, Access.ALL);
    Owner owner = TestUtil.createOwner();
    UeberCertificate entCert = mock(UeberCertificate.class);
    OwnerCurator oc = mock(OwnerCurator.class);
    ProductCurator pc = mock(ProductCurator.class);
    ConsumerCurator cc = mock(ConsumerCurator.class);
    EntitlementCurator ec = mock(EntitlementCurator.class);
    CandlepinPoolManager cpm = mock(CandlepinPoolManager.class);
    EntitlementCertificateCurator ecc = mock(EntitlementCertificateCurator.class);
    UeberCertificateCurator uc = mock(UeberCertificateCurator.class);
    UeberCertificateGenerator ucg = mock(UeberCertificateGenerator.class);
    OwnerResource resource = new OwnerResource(oc, pc, null, cc, i18n, null, null, null, null, null, cpm, null, null, null, null, null, ecc, ec, uc, ucg, null, null, null, null, null, null, null, null, null, this.modelTranslator);
    when(oc.lookupByKey(eq("admin"))).thenReturn(owner);
    when(ucg.generate(eq(owner.getKey()), eq(principal))).thenReturn(entCert);
    UeberCertificate result = resource.createUeberCertificate(principal, owner.getKey());
    assertEquals(entCert, result);
}
Also used : EntitlementCurator(org.candlepin.model.EntitlementCurator) OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) UeberCertificate(org.candlepin.model.UeberCertificate) ProductCurator(org.candlepin.model.ProductCurator) UeberCertificateCurator(org.candlepin.model.UeberCertificateCurator) EntitlementCertificateCurator(org.candlepin.model.EntitlementCertificateCurator) UeberCertificateGenerator(org.candlepin.model.UeberCertificateGenerator) ConsumerPrincipal(org.candlepin.auth.ConsumerPrincipal) UserPrincipal(org.candlepin.auth.UserPrincipal) Principal(org.candlepin.auth.Principal) ConsumerCurator(org.candlepin.model.ConsumerCurator) CandlepinPoolManager(org.candlepin.controller.CandlepinPoolManager) Test(org.junit.Test)

Example 2 with ProductCurator

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

the class OwnerResourceTest method testActivationKeyRequiresName.

@Test(expected = BadRequestException.class)
public void testActivationKeyRequiresName() {
    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 = 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 3 with ProductCurator

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

the class OwnerResourceTest method getEntitlementsForNonExistantOwner.

@Test(expected = NotFoundException.class)
public void getEntitlementsForNonExistantOwner() {
    PageRequest req = new PageRequest();
    req.setPage(1);
    req.setPerPage(10);
    OwnerCurator oc = mock(OwnerCurator.class);
    ProductCurator pc = mock(ProductCurator.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, null, null, null, null, null, null, null, this.modelTranslator);
    ownerres.ownerEntitlements("Taylor Swift", null, null, null, req);
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) PageRequest(org.candlepin.common.paging.PageRequest) ProductCurator(org.candlepin.model.ProductCurator) Test(org.junit.Test)

Example 4 with ProductCurator

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

the class TestSyncUtils method getTestSyncUtils.

public static ObjectMapper getTestSyncUtils(Configuration config) {
    ProductCurator mockProductCurator = Mockito.mock(ProductCurator.class);
    ProductCachedSerializationModule productCachedModule = new ProductCachedSerializationModule(mockProductCurator);
    return new SyncUtils(config, productCachedModule).getObjectMapper();
}
Also used : ProductCachedSerializationModule(org.candlepin.jackson.ProductCachedSerializationModule) ProductCurator(org.candlepin.model.ProductCurator)

Example 5 with ProductCurator

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

the class ActivationKeyRulesTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    Locale locale = new Locale("en_US");
    i18n = I18nFactory.getI18n(getClass(), "org.candlepin.i18n.Messages", locale, I18nFactory.FALLBACK);
    // Load the default production rules:
    InputStream is = this.getClass().getResourceAsStream(RulesCurator.DEFAULT_RULES_FILE);
    Rules rules = new Rules(Util.readFile(is));
    when(rulesCuratorMock.getUpdated()).thenReturn(new Date());
    when(rulesCuratorMock.getRules()).thenReturn(rules);
    when(cacheProvider.get()).thenReturn(cache);
    provider = new JsRunnerProvider(rulesCuratorMock, cacheProvider);
    ProductCurator productCurator = mock(ProductCurator.class);
    translator = new StandardTranslator(mockConsumerTypeCurator, environmentCurator, mockOwnerCurator);
    actKeyRules = new ActivationKeyRules(provider.get(), i18n, new RulesObjectMapper(new ProductCachedSerializationModule(productCurator)), translator);
}
Also used : Locale(java.util.Locale) ProductCachedSerializationModule(org.candlepin.jackson.ProductCachedSerializationModule) InputStream(java.io.InputStream) ProductCurator(org.candlepin.model.ProductCurator) JsRunnerProvider(org.candlepin.policy.js.JsRunnerProvider) RulesObjectMapper(org.candlepin.policy.js.RulesObjectMapper) Rules(org.candlepin.model.Rules) StandardTranslator(org.candlepin.dto.StandardTranslator) Date(java.util.Date) Before(org.junit.Before)

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