Search in sources :

Example 1 with ComplianceOp

use of org.candlepin.bind.ComplianceOp in project candlepin by candlepin.

the class PoolManagerTest method setupBindChain.

private void setupBindChain() {
    final HandleEntitlementsOp entitlementsOp = new HandleEntitlementsOp(mockPoolCurator, entitlementCurator);
    final PostBindBonusPoolsOp postBindBonusPoolsOp = new PostBindBonusPoolsOp(manager);
    final HandleCertificatesOp certificatesOp = new HandleCertificatesOp(mockECGenerator, certCuratorMock, entitlementCurator);
    final ComplianceOp complianceOp = new ComplianceOp(complianceRules);
    when(mockPreEntitlementRulesCheckFactory.create(any(CallerType.class))).thenAnswer(new Answer<PreEntitlementRulesCheckOp>() {

        @Override
        public PreEntitlementRulesCheckOp answer(InvocationOnMock invocation) throws Throwable {
            Object[] args = invocation.getArguments();
            CallerType type = (CallerType) args[0];
            return new PreEntitlementRulesCheckOp(enforcerMock, type);
        }
    });
    when(mockBindContextFactory.create(any(Consumer.class), anyMapOf(String.class, Integer.class))).thenAnswer(new Answer<BindContext>() {

        @Override
        public BindContext answer(InvocationOnMock invocation) throws Throwable {
            Object[] args = invocation.getArguments();
            Consumer consumer = (Consumer) args[0];
            Map<String, Integer> pQ = (Map<String, Integer>) args[1];
            return new BindContext(mockPoolCurator, consumerCuratorMock, consumerTypeCuratorMock, mockOwnerCurator, i18n, consumer, pQ);
        }
    });
    when(mockBindChainFactory.create(any(Consumer.class), anyMapOf(String.class, Integer.class), any(CallerType.class))).thenAnswer(new Answer<BindChain>() {

        @Override
        public BindChain answer(InvocationOnMock invocation) throws Throwable {
            Object[] args = invocation.getArguments();
            Consumer consumer = (Consumer) args[0];
            Map<String, Integer> pQ = (Map<String, Integer>) args[1];
            CallerType type = (CallerType) args[2];
            return new BindChain(mockBindContextFactory, mockPreEntitlementRulesCheckFactory, entitlementsOp, postBindBonusPoolsOp, certificatesOp, complianceOp, consumer, pQ, type);
        }
    });
}
Also used : CallerType(org.candlepin.policy.js.entitlement.Enforcer.CallerType) Matchers.anyString(org.mockito.Matchers.anyString) PreEntitlementRulesCheckOp(org.candlepin.bind.PreEntitlementRulesCheckOp) BindContext(org.candlepin.bind.BindContext) PostBindBonusPoolsOp(org.candlepin.bind.PostBindBonusPoolsOp) ComplianceOp(org.candlepin.bind.ComplianceOp) Consumer(org.candlepin.model.Consumer) HandleEntitlementsOp(org.candlepin.bind.HandleEntitlementsOp) InvocationOnMock(org.mockito.invocation.InvocationOnMock) HandleCertificatesOp(org.candlepin.bind.HandleCertificatesOp) BindChain(org.candlepin.bind.BindChain) Map(java.util.Map) Matchers.anyMap(org.mockito.Matchers.anyMap) HashMap(java.util.HashMap)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 BindChain (org.candlepin.bind.BindChain)1 BindContext (org.candlepin.bind.BindContext)1 ComplianceOp (org.candlepin.bind.ComplianceOp)1 HandleCertificatesOp (org.candlepin.bind.HandleCertificatesOp)1 HandleEntitlementsOp (org.candlepin.bind.HandleEntitlementsOp)1 PostBindBonusPoolsOp (org.candlepin.bind.PostBindBonusPoolsOp)1 PreEntitlementRulesCheckOp (org.candlepin.bind.PreEntitlementRulesCheckOp)1 Consumer (org.candlepin.model.Consumer)1 CallerType (org.candlepin.policy.js.entitlement.Enforcer.CallerType)1 Matchers.anyMap (org.mockito.Matchers.anyMap)1 Matchers.anyString (org.mockito.Matchers.anyString)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1