cdx.scorebot.scoring
Class ScoringRuleset

java.lang.Object
  extended by cdx.scorebot.scoring.ScoringRuleset
All Implemented Interfaces:
java.io.Serializable

public class ScoringRuleset
extends java.lang.Object
implements java.io.Serializable

Describes how to score the service a TestSuite is testing. It also defines threshold ranges of and initial scores.

Author:
David Underhill
See Also:
Serialized Form

Constructor Summary
ScoringRuleset()
          default constructor
 
Method Summary
 void addScoringRule(ScoringRule rule)
          Adds a ScoringRule to be evaluated.
 boolean equals(java.lang.Object o)
           
 int getInitialPoints()
          Deprecated. TestSuites no longer contain an initial score -- this is contained by the NetworkTestPackage now.
 int getMaxGain()
          gets the maximum number points which may be awarded
 int getMaxLoss()
          gets the maximum number points which may be lost
 java.util.Vector<ScoringRule> getRules()
          gets list of rules which define how to score test(s)
 ScoringRule getScoringRule(int index)
          Gets the specified ScoringRule
 java.util.Vector<TestScoreEvent> processTestEvent(TestSuite suite, TestEvent e)
          Give each rule a chance to process the TestEvent.
 void removeScoringRule(int index)
          Removes the ScoringRule from this ScoringRuleset
 void setInitialPoints(int initialPoints)
          Deprecated. TestSuites no longer contain an initial score -- this is contained by the NetworkTestPackage now.
 void setMaxGain(int maxPoints)
          sets the maximum number points which may be awarded (absolute value)
 void setMaxLoss(int minPoints)
          sets the maximum number points which may be awarded (negative absolute value)
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScoringRuleset

public ScoringRuleset()
default constructor

Method Detail

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

processTestEvent

public java.util.Vector<TestScoreEvent> processTestEvent(TestSuite suite,
                                                         TestEvent e)
                                                  throws LogicException
Give each rule a chance to process the TestEvent. If the TestEvent does not apply to a rule, it will ignore it. Otherwise, the rule will update its scoring logic with the TestEvent and return a ScoreEvent if the new TestEvent triggered a score change. Since multiple rules may fire, multiple ScoreEvents may be generated.

Parameters:
suite - the suite which score events generated by this context refer to
e - the next TestEvent to process (ScoringRule's are STATEFUL, so order matters!)
Returns:
TestScoreEvents generated by rule(s) which fired as a result of specified TestEvent
Throws:
LogicException - occurs if a runtime error occurs in the scoring language

getMaxLoss

public int getMaxLoss()
gets the maximum number points which may be lost


setMaxLoss

public void setMaxLoss(int minPoints)
sets the maximum number points which may be awarded (negative absolute value)


getMaxGain

public int getMaxGain()
gets the maximum number points which may be awarded


setMaxGain

public void setMaxGain(int maxPoints)
sets the maximum number points which may be awarded (absolute value)


getInitialPoints

public int getInitialPoints()
Deprecated. TestSuites no longer contain an initial score -- this is contained by the NetworkTestPackage now.

just returns 0

Returns:
0

setInitialPoints

public void setInitialPoints(int initialPoints)
                      throws IllegalArgValException
Deprecated. TestSuites no longer contain an initial score -- this is contained by the NetworkTestPackage now.

no longer does anything

Throws:
IllegalArgValException

addScoringRule

public void addScoringRule(ScoringRule rule)
Adds a ScoringRule to be evaluated.

Parameters:
rule - the ScoringRule to add to this ScoringRuleset

removeScoringRule

public void removeScoringRule(int index)
                       throws java.lang.ArrayIndexOutOfBoundsException
Removes the ScoringRule from this ScoringRuleset

Parameters:
index - remove the ScoringRule at the specified index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.

getScoringRule

public ScoringRule getScoringRule(int index)
                           throws java.lang.ArrayIndexOutOfBoundsException
Gets the specified ScoringRule

Returns:
the ScoringRule at the specified index in the ScoringRule vector
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.

getRules

public java.util.Vector<ScoringRule> getRules()
gets list of rules which define how to score test(s)