Package org.candlepin.model

Examples of org.candlepin.model.Rules


        rulesCurator.getRules();
    }

    @Test
    public void uploadRules() {
        Rules rules = new Rules("// Version: 5.1000\n//these are the new rules");
        rulesCurator.update(rules);
        Rules updateRules = rulesCurator.getRules();
        assertEquals(rules.getRules(), updateRules.getRules());
    }
View Full Code Here


        assertEquals(rules.getRules(), updateRules.getRules());
    }

    @Test
    public void uploadMultipleRules() {
        Rules rules = new Rules("// Version: 5.1000\n// rules1 ");
        rulesCurator.update(rules);
        Rules rules2 = new Rules("// Version: 5.1001\n// rules2 ");
        rulesCurator.update(rules2);
        Rules updateRules = rulesCurator.getRules();
        assertEquals(rules2.getRules(), updateRules.getRules());
    }
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);

        when(configMock.getInt(eq(ConfigProperties.PRODUCT_CACHE_MAX))).thenReturn(100);
View Full Code Here

        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);
        provider = new JsRunnerProvider(rulesCuratorMock);
        when(eventSinkProvider.get()).thenReturn(eventSink);
        compliance = new ComplianceRules(provider.get(),
View Full Code Here

        when(config.getInt(eq(ConfigProperties.PRODUCT_CACHE_MAX))).thenReturn(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);

        when(configMock.getInt(eq(ConfigProperties.PRODUCT_CACHE_MAX))).thenReturn(100);
View Full Code Here

    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);
        when(rulesCurator.listAll()).thenReturn(new ArrayList<Rules>());
        when(rulesCurator.getRules()).thenReturn(new Rules("// Version: 2.0\nBLAH"));
    }
View Full Code Here

        this.curator = curator;
        this.sink = sink;
    }

    public void importObject(Reader reader) throws IOException {
        Rules existingRules = curator.getRules();
        Rules newRules = new Rules(StringFromReader.asString(reader));

        // Only import if rules version is greater than what we currently have now:
        if (VersionUtil.getRulesVersionCompatibility(existingRules.getVersion(),
            newRules.getVersion())) {
            log.info("Importing new rules from manifest, current version: " +
                existingRules.getVersion() + " new version: " + newRules.getVersion());
            curator.update(newRules);
            sink.emitRulesModified(existingRules, newRules);
        }
        else {
            log.info("Ignoring older rules in manifest, current version: " +
                existingRules.getVersion() + " new version: " + newRules.getVersion());
        }
    }
View Full Code Here

        if (rulesBuffer == null || "".equals(rulesBuffer)) {
            throw new WebApplicationException(Response.Status.BAD_REQUEST);
        }

        Rules rules = null;
        try {
            String decoded = new String(Base64.decodeBase64(rulesBuffer));
            rules = new Rules(decoded);
        }
        catch (Throwable t) {
            log.error("Exception in rules upload", t);
            throw new BadRequestException(
                i18n.tr("Error decoding the rules. The text should be base 64 encoded"));
        }
        Rules oldRules = rulesCurator.getRules();
        rulesCurator.update(rules);
        sink.emitRulesModified(oldRules, rules);
        return rulesBuffer;
    }
View Full Code Here

     * @httpcode 200
     */
    @DELETE
    @Produces(MediaType.APPLICATION_JSON)
    public void delete() {
        Rules deleteRules = rulesCurator.getRules();
        rulesCurator.delete(deleteRules);
        sink.emitRulesDeleted(deleteRules);
    }
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.