Search in sources :

Example 21 with Rules

use of org.candlepin.model.Rules in project candlepin by candlepin.

the class RulesImporterTest method importSkipsOlderRulesDifferentApi.

@Test
public void importSkipsOlderRulesDifferentApi() throws IOException {
    Rules currentRules = new Rules("// Version: 2.1");
    when(curator.getRules()).thenReturn(currentRules);
    importer.importObject(new StringReader("//Version: 1.0\n//rules"));
    verify(curator, never()).update(any(Rules.class));
}
Also used : StringReader(java.io.StringReader) Rules(org.candlepin.model.Rules) Test(org.junit.Test)

Example 22 with Rules

use of org.candlepin.model.Rules in project candlepin by candlepin.

the class ContentOverrideValidatorTest method setupTest.

@Before
public void setupTest() {
    InputStream is = this.getClass().getResourceAsStream(RulesCurator.DEFAULT_RULES_FILE);
    rulesCuratorMock = mock(RulesCurator.class);
    config = mock(Configuration.class);
    cacheProvider = mock(Provider.class);
    cache = mock(JsRunnerRequestCache.class);
    Rules rules = new Rules(Util.readFile(is));
    when(rulesCuratorMock.getUpdated()).thenReturn(new Date());
    when(rulesCuratorMock.getRules()).thenReturn(rules);
    when(cacheProvider.get()).thenReturn(cache);
    provider = new JsRunnerProvider(rulesCuratorMock, cacheProvider);
    overrideRules = new OverrideRules(provider.get(), config, new RulesObjectMapper(new ProductCachedSerializationModule(mockProductCurator)));
    validator = new ContentOverrideValidator(i18n, overrideRules);
}
Also used : ProductCachedSerializationModule(org.candlepin.jackson.ProductCachedSerializationModule) RulesCurator(org.candlepin.model.RulesCurator) Configuration(org.candlepin.common.config.Configuration) InputStream(java.io.InputStream) JsRunnerProvider(org.candlepin.policy.js.JsRunnerProvider) RulesObjectMapper(org.candlepin.policy.js.RulesObjectMapper) OverrideRules(org.candlepin.policy.js.override.OverrideRules) Rules(org.candlepin.model.Rules) OverrideRules(org.candlepin.policy.js.override.OverrideRules) Date(java.util.Date) Provider(com.google.inject.Provider) JsRunnerProvider(org.candlepin.policy.js.JsRunnerProvider) JsRunnerRequestCache(org.candlepin.policy.js.JsRunnerRequestCache) Before(org.junit.Before)

Example 23 with Rules

use of org.candlepin.model.Rules in project candlepin by candlepin.

the class EventSinkImplTest method rulesUpdatedShouldEmitSuccessfully.

@Test
public void rulesUpdatedShouldEmitSuccessfully() throws Exception {
    Rules oldRules = new Rules(TestUtil.createRulesBlob(1));
    Rules newRules = new Rules(TestUtil.createRulesBlob(2));
    eventSinkImpl.emitRulesModified(oldRules, newRules);
    eventSinkImpl.sendEvents();
    verify(mockClientProducer).send(any(ClientMessage.class));
}
Also used : ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) Rules(org.candlepin.model.Rules) Test(org.junit.Test)

Example 24 with Rules

use of org.candlepin.model.Rules in project candlepin by candlepin.

the class EventSinkImplTest method rulesDeletedShouldEmitSuccessfully.

@Test
public void rulesDeletedShouldEmitSuccessfully() throws Exception {
    Rules oldRules = new Rules(TestUtil.createRulesBlob(1));
    eventSinkImpl.emitRulesDeleted(oldRules);
    eventSinkImpl.sendEvents();
    verify(mockClientProducer).send(any(ClientMessage.class));
}
Also used : ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) Rules(org.candlepin.model.Rules) Test(org.junit.Test)

Example 25 with Rules

use of org.candlepin.model.Rules in project candlepin by candlepin.

the class VersionUtilTest method writeoutVersion.

public static void writeoutVersion(String version, String release) throws Exception {
    PrintStream ps = new PrintStream(new File(new Rules().getClass().getClassLoader().getResource("version.properties").toURI()));
    ps.println("version=" + version);
    ps.println("release=" + release);
    ps.close();
}
Also used : PrintStream(java.io.PrintStream) File(java.io.File) Rules(org.candlepin.model.Rules)

Aggregations

Rules (org.candlepin.model.Rules)34 InputStream (java.io.InputStream)18 Date (java.util.Date)18 Test (org.junit.Test)15 Before (org.junit.Before)14 ProductCachedSerializationModule (org.candlepin.jackson.ProductCachedSerializationModule)9 Consumer (org.candlepin.model.Consumer)9 JsRunnerProvider (org.candlepin.policy.js.JsRunnerProvider)9 RulesObjectMapper (org.candlepin.policy.js.RulesObjectMapper)9 CandlepinQuery (org.candlepin.model.CandlepinQuery)8 ConsumerType (org.candlepin.model.ConsumerType)8 File (java.io.File)7 StandardTranslator (org.candlepin.dto.StandardTranslator)7 ExportRules (org.candlepin.policy.js.export.ExportRules)7 FileInputStream (java.io.FileInputStream)6 ZipInputStream (java.util.zip.ZipInputStream)6 Principal (org.candlepin.auth.Principal)6 CertificateSerial (org.candlepin.model.CertificateSerial)6 IdentityCertificate (org.candlepin.model.IdentityCertificate)6 MockResultIterator (org.candlepin.test.MockResultIterator)6