Package org.candlepin.model

Examples of org.candlepin.model.Consumer


            .size());
    }

    @Test
    public void testRegisterWithConsumerId() {
        Consumer toSubmit = new Consumer(CONSUMER_NAME, USER_NAME, null,
            standardSystemType);
        toSubmit.setUuid("1023131");
        toSubmit.getFacts().put(METADATA_NAME, METADATA_VALUE);

        Consumer submitted = consumerResource.create(
            toSubmit,
            TestUtil.createPrincipal(someuser.getUsername(), owner, Access.ALL),
            null, null, null);

        assertNotNull(submitted);
        assertEquals(toSubmit.getUuid(), submitted.getUuid());
        assertNotNull(consumerCurator.find(submitted.getId()));
        assertEquals(standardSystemType.getLabel(), submitted.getType()
            .getLabel());
        assertEquals(METADATA_VALUE, submitted.getFact(METADATA_NAME));

        // now pass in consumer type with null id just like the client would
        ConsumerType type = new ConsumerType(standardSystemType.getLabel());
        assertNull(type.getId());
        Consumer nulltypeid = new Consumer(CONSUMER_NAME, USER_NAME, null, type);
        submitted = consumerResource.create(
            nulltypeid,
            TestUtil.createPrincipal(someuser.getUsername(), owner, Access.ALL),
            null, null, null);
        assertNotNull(submitted);
        assertEquals(nulltypeid.getUuid(), submitted.getUuid());
        assertNotNull(submitted.getType().getId());
    }
View Full Code Here


        JsRunner jsRules = new JsRunnerProvider(rulesCurator).get();
        autobindRules = new AutobindRules(jsRules, productCache);

        owner = new Owner();
        consumer = new Consumer("test consumer", "test user", owner,
            new ConsumerType(ConsumerTypeEnum.SYSTEM));
        compliance = new ComplianceStatus();
        activeGuestAttrs = new HashMap<String, String>();
        activeGuestAttrs.put("virtWhoType", "libvirt");
        activeGuestAttrs.put("active", "1");
View Full Code Here

        Locale locale = new Locale("en_US");
        I18n i18n = I18nFactory.getI18n(getClass(), "org.candlepin.i18n.Messages", locale,
            I18nFactory.FALLBACK);
        generator = new StatusReasonMessageGenerator(i18n);
        owner = new Owner("test");
        consumer = new Consumer();
        consumer.setType(new ConsumerType(ConsumerType.ConsumerTypeEnum.SYSTEM));
        ent1 = mockEntitlement(consumer, "id1", "Nonstacked Product");
        ent1.setId("ent1");
        entStacked1 = mockBaseStackedEntitlement(consumer, "stack",
            "Stacked Product", "Stack Subscription One");
View Full Code Here

        consumerResource.bind(consumer.getUuid(), pool.getId().toString(),
            null, 1, null, null, false, null, null);
        consumerResource.bind(consumer.getUuid(), pool.getId().toString(),
            null, 1, null, null, false, null, null);

        Consumer evilConsumer = TestUtil.createConsumer(standardSystemType,
            owner);
        consumerCurator.create(evilConsumer);
        setupPrincipal(new ConsumerPrincipal(evilConsumer));

        securityInterceptor.enable();
View Full Code Here

                null).size());
    }

    @Test(expected = NotFoundException.class)
    public void canNotDeleteConsumerOtherThanSelf() {
        Consumer evilConsumer = TestUtil.createConsumer(standardSystemType,
            owner);
        consumerCurator.create(evilConsumer);
        setupPrincipal(new ConsumerPrincipal(evilConsumer));

        securityInterceptor.enable();
View Full Code Here

    }

    @Test
    public void consumerCanDeleteSelf() throws GeneralSecurityException,
        IOException {
        Consumer toSubmit = new Consumer(CONSUMER_NAME, USER_NAME, owner,
            standardSystemType);

        toSubmit.getFacts().put(METADATA_NAME, METADATA_VALUE);
        Consumer c = consumerCurator.create(toSubmit);

        IdentityCertServiceAdapter icsa = injector
            .getInstance(IdentityCertServiceAdapter.class);
        IdentityCertificate idCert = icsa.generateIdentityCert(c);
        c.setIdCert(idCert);
        setupPrincipal(new ConsumerPrincipal(c));
        consumerResource.deleteConsumer(c.getUuid(), principal);
    }
View Full Code Here

                null).size());
    }

    @Test(expected = NotFoundException.class)
    public void testCannotGetAnotherOwnersConsumersCerts() {
        Consumer evilConsumer = TestUtil.createConsumer(standardSystemType,
            owner);
        consumerCurator.create(evilConsumer);

        Owner evilOwner = ownerCurator.create(new Owner("another-owner"));
        ownerCurator.create(evilOwner);
View Full Code Here

        consumerResource.list(null, null, null, new ArrayList<String>(), null, null, null);
    }

    @Test(expected = BadRequestException.class)
    public void testConsumerCannotListWithUuidsAndOtherParameters() {
        Consumer consumer = TestUtil.createConsumer(standardSystemType, owner);
        consumerCurator.create(consumer);

        setupAdminPrincipal("admin");
        securityInterceptor.enable();
        List<String> uuidList = new ArrayList<String>();
        uuidList.add(consumer.getUuid());
        consumerResource.list("username", toSet("typeLabel"), owner.getKey(), uuidList,
            null, null, new PageRequest());
    }
View Full Code Here

        final int currentMembers, final int maxMembers, Date expiry) {
        Pool p = createPoolAndSub(theOwner, product,
            Long.valueOf(maxMembers), new Date(), expiry);

        for (int i = 0; i < currentMembers; i++) {
            Consumer c = createConsumer(theOwner);
            Entitlement e = createEntitlement(theOwner, c, p, null);
            e.setQuantity(1);
            entitlementCurator.create(e);
            p.getEntitlements().add(e);
            poolCurator.merge(p);
View Full Code Here

*/
public class ManifestEntitlementRulesTest extends EntitlementRulesTestFixture {

    @Test
    public void postEntitlement() {
        Consumer c = mock(Consumer.class);
        PoolHelper ph = mock(PoolHelper.class);
        Entitlement e = mock(Entitlement.class);
        ConsumerType type = mock(ConsumerType.class);
        Pool pool = mock(Pool.class);
        Product product = mock(Product.class);

        when(e.getPool()).thenReturn(pool);
        when(e.getConsumer()).thenReturn(c);
        when(c.getType()).thenReturn(type);
        when(type.isManifest()).thenReturn(true);
        when(pool.getProductId()).thenReturn("testProd");
        when(prodAdapter.getProductById(eq("testProd"))).thenReturn(product);
        when(product.getAttributes()).thenReturn(new HashSet<ProductAttribute>());
        when(pool.getAttributes()).thenReturn(new HashSet<PoolAttribute>());
View Full Code Here

TOP

Related Classes of org.candlepin.model.Consumer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.