Package org.candlepin.model

Examples of org.candlepin.model.Rules


    private String FAKE_RULES = "//Version: 2.0\nHELLO WORLD";

    @Test
    public void testMetaExporter() throws IOException {
        RulesCurator rulesCurator = mock(RulesCurator.class);
        when(rulesCurator.getRules()).thenReturn(new Rules(FAKE_RULES));
        RulesExporter exporter = new RulesExporter(rulesCurator);
        StringWriter writer = new StringWriter();
        exporter.export(writer);
        assertEquals(FAKE_RULES, writer.toString());
    }
View Full Code Here


    @Test
    public void testUpload() {
        String rulesBuffer = new String(Base64.encodeBase64String((
            TestUtil.createRulesBlob(10000).getBytes())));
        rulesResource.upload(rulesBuffer);
        Rules rules = rulesCurator.getRules();
        String expected = "" + RulesCurator.RULES_API_VERSION + "." + 10000;
        assertEquals(expected, rules.getVersion());
    }
View Full Code Here

            100);
        this.productCache = new ProductCache(config, this.prodAdapter);

        InputStream is = this.getClass().getResourceAsStream(
            RulesCurator.DEFAULT_RULES_FILE);
        Rules rules = new Rules(Util.readFile(is));

        when(rulesCurator.getRules()).thenReturn(rules);
        when(rulesCurator.getUpdated()).thenReturn(
            TestDateUtil.date(2010, 1, 1));
View Full Code Here

    public void setUp() {

        // 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);

        exportRules = new ExportRules();
View Full Code Here

        this.expectedVersion = expectedVersion;
    }

    @Test
    public void ensureWorking() {
        Rules rules = null;
        try {
            rules = new Rules(version);
            if (!expectedToBeValid) {
                throw new RuntimeException("Expected rule parsing to have failed.");
            }
            assertEquals(expectedVersion, rules.getVersion());
        }
        catch (RuleParseException e) {
            if (expectedToBeValid) {
                throw e;
            }
View Full Code Here

    @Before
    public void setUp() {
        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(configMock.getInt(eq(ConfigProperties.PRODUCT_CACHE_MAX))).thenReturn(100);
View Full Code Here

        while ((line = reader.readLine()) != null) {
            builder.append(line + "\n");
        }
        reader.close();

        Rules rules = mock(Rules.class);
        when(rules.getRules()).thenReturn(builder.toString());
        when(rulesCurator.getRules()).thenReturn(rules);
        when(rulesCurator.getUpdated()).thenReturn(TestDateUtil.date(2010, 1, 1));

        JsRunner jsRules = new JsRunnerProvider(rulesCurator).get();
View Full Code Here

        Consumer consumer = mock(Consumer.class);
        Entitlement ent = mock(Entitlement.class);
        ProvidedProduct pp = mock(ProvidedProduct.class);
        DerivedProvidedProduct spp = mock(DerivedProvidedProduct.class);
        Pool pool = mock(Pool.class);
        Rules mrules = mock(Rules.class);
        Principal principal = mock(Principal.class);
        IdentityCertificate idcert = new IdentityCertificate();

        Set<ProvidedProduct> ppset = new HashSet<ProvidedProduct>();
        ppset.add(pp);

        Set<DerivedProvidedProduct> sppSet = new HashSet<DerivedProvidedProduct>();
        sppSet.add(spp);

        Set<Entitlement> entitlements = new HashSet<Entitlement>();
        entitlements.add(ent);

        Product prod = new Product("12345", "RHEL Product");
        prod.setMultiplier(1L);
        prod.setCreated(new Date());
        prod.setUpdated(new Date());
        prod.setHref("http://localhost");
        prod.setAttributes(Collections.EMPTY_SET);

        Product prod1 = new Product("MKT-prod", "RHEL Product");
        prod1.setMultiplier(1L);
        prod1.setCreated(new Date());
        prod1.setUpdated(new Date());
        prod1.setHref("http://localhost");
        prod1.setAttributes(Collections.EMPTY_SET);

        Product subProduct = new Product("MKT-sub-prod", "Sub Product");
        subProduct.setMultiplier(1L);
        subProduct.setCreated(new Date());
        subProduct.setUpdated(new Date());
        subProduct.setHref("http://localhost");
        subProduct.setAttributes(Collections.EMPTY_SET);

        Product subProvidedProduct = new Product("332211", "Sub Product");
        subProvidedProduct.setMultiplier(1L);
        subProvidedProduct.setCreated(new Date());
        subProvidedProduct.setUpdated(new Date());
        subProvidedProduct.setHref("http://localhost");
        subProvidedProduct.setAttributes(Collections.EMPTY_SET);

        ProductCertificate pcert = new ProductCertificate();
        pcert.setKey("euh0876puhapodifbvj094");
        pcert.setCert("hpj-08ha-w4gpoknpon*)&^%#");
        pcert.setCreated(new Date());
        pcert.setUpdated(new Date());

        when(pp.getProductId()).thenReturn("12345");
        when(pool.getProvidedProducts()).thenReturn(ppset);
        when(pool.getProductId()).thenReturn("MKT-prod");

        when(pool.getDerivedProvidedProducts()).thenReturn(sppSet);
        when(pool.getDerivedProductId()).thenReturn(subProduct.getId());
        when(spp.getProductId()).thenReturn(subProvidedProduct.getId());

        when(ent.getPool()).thenReturn(pool);
        when(mrules.getRules()).thenReturn("foobar");
        when(pki.getSHA256WithRSAHash(any(InputStream.class))).thenReturn(
            "signature".getBytes());
        when(rc.getRules()).thenReturn(mrules);
        when(consumer.getEntitlements()).thenReturn(entitlements);
        when(psa.getProductById("12345")).thenReturn(prod);
View Full Code Here

    @Test
    public void exportMetadata() throws ExportCreationException, IOException {
        config.setProperty(ConfigProperties.SYNC_WORK_DIR, "/tmp/");
        Date start = new Date();
        Rules mrules = mock(Rules.class);
        Consumer consumer = mock(Consumer.class);
        Principal principal = mock(Principal.class);
        IdentityCertificate idcert = new IdentityCertificate();

        when(mrules.getRules()).thenReturn("foobar");
        when(pki.getSHA256WithRSAHash(any(InputStream.class))).thenReturn(
            "signature".getBytes());
        when(rc.getRules()).thenReturn(mrules);
        when(pprov.get()).thenReturn(principal);
        when(principal.getUsername()).thenReturn("testUser");
View Full Code Here

    }

    @Test
    public void exportIdentityCertificate() throws Exception {
        config.setProperty(ConfigProperties.SYNC_WORK_DIR, "/tmp/");
        Rules mrules = mock(Rules.class);
        Consumer consumer = mock(Consumer.class);
        Principal principal = mock(Principal.class);

        when(mrules.getRules()).thenReturn("foobar");
        when(pki.getSHA256WithRSAHash(any(InputStream.class))).thenReturn(
            "signature".getBytes());
        when(rc.getRules()).thenReturn(mrules);
        when(pprov.get()).thenReturn(principal);
        when(principal.getUsername()).thenReturn("testUser");
View Full Code Here

TOP

Related Classes of org.candlepin.model.Rules

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.