Exemplo n.º 1
0
 @Test
 public void testCombineWithPermit() throws EvaluationException {
   DecisionRule r1 = c.createMock(DecisionRule.class);
   DecisionRule r2 = c.createMock(DecisionRule.class);
   decisions.add(r1);
   decisions.add(r2);
   expect(r1.createContext(context)).andReturn(context);
   expect(r1.evaluate(context)).andReturn(Decision.PERMIT);
   expect(r2.createContext(context)).andReturn(context);
   expect(r2.evaluate(context)).andReturn(Decision.PERMIT);
   c.replay();
   assertEquals(Decision.PERMIT, algorithm.combine(context, decisions));
   c.verify();
 }
Exemplo n.º 2
0
 @Test
 public void testCombineWithAllNotApplicable() throws EvaluationException {
   DecisionRule r1 = c.createMock(DecisionRule.class);
   DecisionRule r2 = c.createMock(DecisionRule.class);
   DecisionRule r3 = c.createMock(DecisionRule.class);
   decisions = new LinkedList<DecisionRule>();
   decisions.add(r1);
   decisions.add(r2);
   decisions.add(r3);
   expect(r1.createContext(context)).andReturn(context);
   expect(r1.evaluate(context)).andReturn(Decision.NOT_APPLICABLE);
   expect(r2.createContext(context)).andReturn(context);
   expect(r2.evaluate(context)).andReturn(Decision.NOT_APPLICABLE);
   expect(r3.createContext(context)).andReturn(context);
   expect(r3.evaluate(context)).andReturn(Decision.NOT_APPLICABLE);
   c.replay();
   assertEquals(Decision.NOT_APPLICABLE, algorithm.combine(context, decisions));
   c.verify();
 }
Exemplo n.º 3
0
 @Test
 public void testCombineWithInderterminate() throws EvaluationException {
   DecisionRule r1 = c.createMock(DecisionRule.class);
   decisions.add(r1);
   expect(r1.createContext(context)).andReturn(context);
   expect(r1.evaluate(context)).andReturn(Decision.INDETERMINATE);
   c.replay();
   assertEquals(Decision.INDETERMINATE_DP, algorithm.combine(context, decisions));
   c.verify();
 }
Exemplo n.º 4
0
 @Test
 public void testAnyDecisionDenyResultIsDeny() throws EvaluationException {
   DecisionRule r1 = c.createMock(DecisionRule.class);
   DecisionRule r2 = c.createMock(DecisionRule.class);
   decisions = new LinkedList<DecisionRule>();
   decisions.add(r1);
   decisions.add(r2);
   expect(r1.createContext(context)).andReturn(context);
   expect(r1.evaluate(context)).andReturn(Decision.DENY);
   c.replay();
   assertEquals(Decision.DENY, algorithm.combine(context, decisions));
   c.verify();
 }