use of org.candlepin.test.DateSourceForTesting in project candlepin by candlepin.
the class EnforcerTest method createEnforcer.
@Before
public void createEnforcer() throws Exception {
MockitoAnnotations.initMocks(this);
when(config.getInt(eq(ConfigProperties.PRODUCT_CACHE_MAX))).thenReturn(100);
owner = createOwner();
ownerCurator.create(owner);
consumer = this.createConsumer(owner);
BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/rules/test-rules.js")));
StringBuilder builder = new StringBuilder();
String line = null;
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));
when(cacheProvider.get()).thenReturn(cache);
JsRunner jsRules = new JsRunnerProvider(rulesCurator, cacheProvider).get();
translator = new StandardTranslator(consumerTypeCurator, mockEnvironmentCurator, mockOwnerCurator);
enforcer = new EntitlementRules(new DateSourceForTesting(2010, 1, 1), jsRules, i18n, config, consumerCurator, consumerTypeCurator, mockProductCurator, new RulesObjectMapper(new ProductCachedSerializationModule(mockProductCurator)), mockOwnerCurator, mockOwnerProductCurator, mockProductShareCurator, mockProductManager, mockEventSink, mockEventFactory, translator);
}
Aggregations