Package org.candlepin.policy

Examples of org.candlepin.policy.ValidationResult


        ActivationKey key = new ActivationKey();
        key.addPool(genHostRestricted("host1"), 1L);

        Pool pool = genHostRestricted("host2");

        ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(1));
        assertTrue(result.getWarnings().isEmpty());
        assertEquals(1, result.getErrors().size());
        String expected = "rulefailed.multiple.host.restrictions";
        assertEquals(expected, result.getErrors().get(0).getResourceKey());
    }
View Full Code Here


    public void testDoesAllowSameHostRequires() {
        ActivationKey key = new ActivationKey();
        key.addPool(genHostRestricted("host1"), 1L);

        Pool pool = genHostRestricted("host1");
        ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(1));
        assertTrue(result.getWarnings().isEmpty());
        assertTrue(result.getErrors().isEmpty());
    }
View Full Code Here

    @Test
    public void testNonMultientOne() {
        ActivationKey key = new ActivationKey();

        Pool pool = genNonMultiEnt();
        ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(1));
        assertTrue(result.getWarnings().isEmpty());
        assertTrue(result.getErrors().isEmpty());
    }
View Full Code Here

    @Test
    public void testNonMultientMultipleQuantity() {
        ActivationKey key = new ActivationKey();

        Pool pool = genNonMultiEnt();
        ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(2));
        assertTrue(result.getWarnings().isEmpty());
        assertEquals(1, result.getErrors().size());
        String expected = "rulefailed.invalid.nonmultient.quantity";
        assertEquals(expected, result.getErrors().get(0).getResourceKey());
    }
View Full Code Here

    public void testNonMultientOneTwice() {
        ActivationKey key = new ActivationKey();
        Pool pool = genNonMultiEnt();
        key.addPool(pool, 1L);

        ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(1));
        assertTrue(result.getWarnings().isEmpty());
        assertEquals(1, result.getErrors().size());
        String expected = "rulefailed.already.exists";
        assertEquals(expected, result.getErrors().get(0).getResourceKey());
    }
View Full Code Here

    @Test
    public void testNullQuantityInstanceAndPhysicalOnly() {
        ActivationKey key = new ActivationKey();
        key.addPool(genInstanceBased(), null);

        ValidationResult result = actKeyRules.runPreActKey(key, genPhysOnlyPool(), new Long(1));
        assertTrue(result.getWarnings().isEmpty());
        assertTrue(result.getErrors().isEmpty());
    }
View Full Code Here

        when(entitlementCurator.listByConsumer(eq(c))).thenReturn(entitlementList);
        when(mockPoolCurator.lockAndLoad(any(Pool.class))).thenReturn(pool);

        PreUnbindHelper preHelper =  mock(PreUnbindHelper.class);
        ValidationResult result = new ValidationResult();
        when(preHelper.getResult()).thenReturn(result);

        int total = manager.revokeAllEntitlements(c);

        assertEquals(2, total);
View Full Code Here

        Entitlement e = new Entitlement(pool, TestUtil.createConsumer(o),
            1);
        List<Pool> poolsWithSource = createPoolsWithSourceEntitlement(e, product);
        when(mockPoolCurator.listBySourceEntitlement(e)).thenReturn(poolsWithSource);
        PreUnbindHelper preHelper =  mock(PreUnbindHelper.class);
        ValidationResult result = new ValidationResult();
        when(preHelper.getResult()).thenReturn(result);
        when(mockConfig.getBoolean(ConfigProperties.STANDALONE)).thenReturn(true);

        when(mockPoolCurator.lockAndLoad(any(Pool.class))).thenReturn(pool);
View Full Code Here

        Pool pool2 = TestUtil.createPool(product);
        pools.add(pool2);
        Date now = new Date();


        ValidationResult result = mock(ValidationResult.class);
        Page page = mock(Page.class);

        when(page.getPageData()).thenReturn(pools);
        when(mockPoolCurator.listAvailableEntitlementPools(any(Consumer.class),
            any(Owner.class), any(String.class), eq(now), anyBoolean(),
            any(PoolFilterBuilder.class), any(PageRequest.class),
            anyBoolean())).thenReturn(page);

        when(mockPoolCurator.lockAndLoad(any(Pool.class))).thenReturn(pool1);
        when(enforcerMock.preEntitlement(any(Consumer.class), any(Pool.class), anyInt(),
            any(CallerType.class))).thenReturn(result);

        when(result.isSuccessful()).thenReturn(true);

        List<PoolQuantity> bestPools = new ArrayList<PoolQuantity>();
        bestPools.add(new PoolQuantity(pool1, 1));
        when(autobindRules.selectBestPools(any(Consumer.class), any(String[].class),
            any(List.class), any(ComplianceStatus.class), any(String.class),
View Full Code Here

        ent.setQuantity(1);
        poolEntitlements.add(ent);

        when(mockPoolCurator.entitlementsIn(eq(p))).thenReturn(poolEntitlements);

        ValidationResult result = new ValidationResult();
        when(preHelper.getResult()).thenReturn(result);

        this.manager.getRefresher().add(sub.getOwner()).run();

        verify(mockSubAdapter).deleteSubscription(eq(sub));
View Full Code Here

TOP

Related Classes of org.candlepin.policy.ValidationResult

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.