01 /*
02 * Created on Aug 29, 2007
03 */
04 package com.x8ing.mc.bp.develop;
05
06 import java.util.Iterator;
07 import java.util.List;
08
09 import com.x8ing.lsm4j.Condition;
10 import com.x8ing.lsm4j.state.ProcessableState;
11 import com.x8ing.mc.bp.AbstractBusinessAction;
12 import com.x8ing.mc.bp.BalanceAccount;
13 import com.x8ing.mc.bp.Bug;
14 import com.x8ing.mc.bp.BusinessContext;
15 import com.x8ing.mc.distribution.RandomDistribution;
16 import com.x8ing.mc.distribution.RandomDistributionConstant;
17
18 /**
19 * @author Patrick Heusser
20 */
21 public class TestingAction extends AbstractBusinessAction {
22
23 private RandomDistribution testingSucess = new RandomDistributionConstant(0, 100);
24
25 /**
26 * @see com.x8ing.mc.bp.AbstractBusinessAction#execute(com.x8ing.lsm4j.state.ProcessableState,
27 * com.x8ing.mc.bp.BusinessContext, com.x8ing.lsm4j.Condition, java.util.List)
28 */
29 public void execute(ProcessableState currentState, BusinessContext businessContext, Condition previousCondition,
30 List lastVisitedStatesHistory) {
31
32 addLogBookEntry("Started testing");
33
34 // book costs for testing
35 addBalanceSheetTransaction("Testing costs", -businessContext.getConfiguration().getCostActionTesting(),
36 BalanceAccount.TESTING);
37
38 // check if fix was successful
39 for (Iterator it = businessContext.getBugs().getBugsWithStateFixed().iterator(); it.hasNext();) {
40
41 Bug bug = (Bug) it.next();
42
43 boolean bugFixedWithSucess = (testingSucess.getNextRandomNumber() < businessContext.getConfiguration()
44 .getChanceTestingBugWithSuccess() ? true : false);
45
46 if (bugFixedWithSucess) {
47
48 addLogBookEntry("testing of bug (id=" + bug.getBugID() + ") sucessful.");
49 bug.setBugState(Bug.BugState.STATE_BUG_TEST_SUCESS);
50
51 } else {
52
53 addLogBookEntry("testing of bug (id=" + bug.getBugID() + ") failed. Return bug to developers.");
54 bug.setBugState(Bug.BugState.STATE_BUG_TEST_FAILED);
55 }
56
57 }
58
59 }
60
61 protected void lazyInit() {
62 // empty
63 }
64
65 }
|