Package org.candlepin.model.activationkeys

Examples of org.candlepin.model.activationkeys.ActivationKey


        pool.setId("id-string");
        List<String> poolIds = new ArrayList<String>();
        poolIds.add(pool.getId());

        List<ActivationKey> keys = new ArrayList<ActivationKey>();
        ActivationKey key1 = new ActivationKey("key1", owner);
        keys.add(key1);
        key1.addPool(pool, 0L);
        key1.setAutoAttach(true);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        Set<ConsumerInstalledProduct> cips = new HashSet<ConsumerInstalledProduct>();
        ConsumerInstalledProduct cip = new ConsumerInstalledProduct(prod.getId(), prod.getName());
        cips.add(cip);
View Full Code Here


    public void registerWithKeyWithInstalledProductsAutoAttach() {
        Product prod = TestUtil.createProduct();
        String[] prodIds = new String[]{prod.getId()};

        List<ActivationKey> keys = new ArrayList<ActivationKey>();
        ActivationKey key1 = new ActivationKey("key1", owner);
        keys.add(key1);
        key1.setAutoAttach(true);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        Set<ConsumerInstalledProduct> cips = new HashSet<ConsumerInstalledProduct>();
        ConsumerInstalledProduct cip = new ConsumerInstalledProduct(prod.getId(), prod.getName());
        cips.add(cip);
View Full Code Here

        // key product
        Product prod2 = TestUtil.createProduct();
        String[] prodIds = new String[]{prod1.getId(), prod2.getId()};

        List<ActivationKey> keys = new ArrayList<ActivationKey>();
        ActivationKey key1 = new ActivationKey("key1", owner);
        keys.add(key1);
        key1.addProduct(prod2);
        key1.setAutoAttach(true);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        Set<ConsumerInstalledProduct> cips = new HashSet<ConsumerInstalledProduct>();
        ConsumerInstalledProduct cip = new ConsumerInstalledProduct(prod1.getId(), prod1.getName());
        cips.add(cip);
View Full Code Here

    }

    @Test(expected = BadRequestException.class)
    public void registerFailWithKeyServiceLevelNotExist() {
        List<ActivationKey> keys = new ArrayList<ActivationKey>();
        ActivationKey key1 = new ActivationKey("key1", owner);
        keys.add(key1);
        key1.setServiceLevel("I don't exist");

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        doThrow(new BadRequestException("exception")).when(serviceLevelValidator)
            .validate(eq(owner), eq(key1.getServiceLevel()));
        consumerBindUtil.handleActivationKeys(consumer, keys);
    }
View Full Code Here

    }

    @Test
    public void registerPassWithKeyServiceLevelNotExistOtherKeysSucceed() {
        List<ActivationKey> keys = mockActivationKeys();
        ActivationKey key1 = new ActivationKey("key1", owner);
        keys.add(key1);
        key1.setServiceLevel("I don't exist");

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        doThrow(new BadRequestException("exception")).when(serviceLevelValidator)
            .validate(eq(owner), eq(key1.getServiceLevel()));
        consumerBindUtil.handleActivationKeys(consumer, keys);
    }
View Full Code Here

    }

    @Test(expected = BadRequestException.class)
    public void registerFailWithNoGoodKeyPool() {
        List<ActivationKey> keys = new ArrayList<ActivationKey>();
        ActivationKey key1 = new ActivationKey("key1", owner);
        keys.add(key1);

        Product prod1 = TestUtil.createProduct();
        Pool ghost = TestUtil.createPool(owner, prod1, 5);
        ghost.setId("ghost-pool");
        key1.addPool(ghost, 10L);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        when(entitler.bindByPool(eq(ghost.getId()), eq(consumer), eq(10)))
            .thenThrow(new ForbiddenException("fail"));
        consumerBindUtil.handleActivationKeys(consumer, keys);
View Full Code Here

    }

    @Test
    public void registerPassWithOneGoodKeyPool() {
        List<ActivationKey> keys = new ArrayList<ActivationKey>();
        ActivationKey key1 = new ActivationKey("key1", owner);
        keys.add(key1);

        Product prod1 = TestUtil.createProduct();
        Pool pool1 = TestUtil.createPool(owner, prod1, 5);
        pool1.setId("pool1");
        key1.addPool(pool1, 10L);
        Product prod2 = TestUtil.createProduct();
        Pool pool2 = TestUtil.createPool(owner, prod2, 5);
        pool2.setId("pool2");
        key1.addPool(pool2, 10L);
        Product prod3 = TestUtil.createProduct();
        Pool pool3 = TestUtil.createPool(owner, prod3, 5);
        pool3.setId("pool3");
        key1.addPool(pool3, 5L);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        when(entitler.bindByPool(eq(pool1.getId()), eq(consumer), eq(10)))
            .thenThrow(new ForbiddenException("fail"));
        when(entitler.bindByPool(eq(pool2.getId()), eq(consumer), eq(10)))
View Full Code Here

    }

    @Test
    public void registerPassWithOneGoodKey() {
        List<ActivationKey> keys = new ArrayList<ActivationKey>();
        ActivationKey key1 = new ActivationKey("key1", owner);
        ActivationKey key2 = new ActivationKey("key2", owner);
        keys.add(key1);
        keys.add(key2);

        Product prod1 = TestUtil.createProduct();
        Pool pool1 = TestUtil.createPool(owner, prod1, 5);
        pool1.setId("pool1");
        key1.addPool(pool1, 10L);
        Product prod2 = TestUtil.createProduct();
        Pool pool2 = TestUtil.createPool(owner, prod2, 5);
        pool2.setId("pool2");
        key1.addPool(pool2, 10L);
        Product prod3 = TestUtil.createProduct();
        Pool pool3 = TestUtil.createPool(owner, prod3, 5);
        pool3.setId("pool3");
        key2.addPool(pool3, 5L);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        when(entitler.bindByPool(eq(pool1.getId()), eq(consumer), eq(10)))
            .thenThrow(new ForbiddenException("fail"));
        when(entitler.bindByPool(eq(pool2.getId()), eq(consumer), eq(10)))
View Full Code Here

    }

    @Test
    public void emptyKeyShouldEmitSuccessfully()
        throws Exception {
        ActivationKey key = TestUtil.createActivationKey(new Owner("deadbeef"), null);
        eventSinkImpl.emitActivationKeyCreated(key);
        eventSinkImpl.sendEvents();
        verify(mockClientProducer).send(any(ClientMessage.class));
    }
View Full Code Here

    public void keyWithPoolsShouldEmitSuccessfully()
        throws Exception {
        ArrayList<Pool> pools = new ArrayList<Pool>();
        pools.add(TestUtil.createPool(TestUtil.createProduct()));
        pools.add(TestUtil.createPool(TestUtil.createProduct()));
        ActivationKey key = TestUtil.createActivationKey(new Owner("deadbeef"), pools);
        eventSinkImpl.emitActivationKeyCreated(key);
        eventSinkImpl.sendEvents();
        verify(mockClientProducer).send(any(ClientMessage.class));
    }
View Full Code Here

TOP

Related Classes of org.candlepin.model.activationkeys.ActivationKey

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.