1 18 19 package org.apache.beehive.netui.tools.testrecorder.shared; 20 21 import java.util.List ; 22 import java.util.ArrayList ; 23 import java.util.Collections ; 24 25 30 public class PlaybackSessionBean extends RecordSessionBean { 31 32 private static final Logger log = Logger.getInstance( PlaybackSessionBean.class ); 33 34 private int recordedTestCount = -1; 35 private int passedCount = 0; 36 private int failedCount = 0; 37 private List testResults; 38 39 public PlaybackSessionBean( String sessionName ) { 40 this( sessionName, false ); 41 } 42 43 public PlaybackSessionBean( String sessionName, boolean error ) { 44 super( sessionName ); 45 setError( error ); 46 testResults = new ArrayList (); 47 } 48 49 public int getRecordedTestCount() { 50 return recordedTestCount; 51 } 52 53 public void setRecordedTestCount( int recordedTestCount ) { 54 this.recordedTestCount = recordedTestCount; 55 } 56 57 public int getTestCount() { 58 return testResults.size(); 59 } 60 61 public TestResults getTestResults( int index ) { 62 return (TestResults) testResults.get( index ); 63 } 64 65 public List getTestResults() { 66 return Collections.unmodifiableList( testResults ); 67 } 68 69 public void addTestResults( TestResults results ) { 70 if ( results.isTestPassed() ) { 71 incrementPassedCount(); 72 } 73 else { 74 incrementFailedCount(); 75 } 76 testResults.add( results ); 77 } 78 79 public boolean isError() { 80 if ( error ) { 81 return error; 82 } 83 return isErrorInternal(); 84 } 85 86 private boolean isErrorInternal() { 87 boolean rtnVal = false; 88 if ( getRecordedTestCount() < 1 ) { 89 if ( log.isDebugEnabled() ) { 90 log.debug( "Invalid recorded test count(" + getRecordedTestCount() + ")" ); 91 } 92 rtnVal = true; 93 } 94 else if ( ( getTestCount() ) != getRecordedTestCount() ) { 95 if ( log.isDebugEnabled() ) { 96 log.debug( "executed count(" + getTestCount() + ") does not equal recorded test count(" + 97 getRecordedTestCount() + ")" ); 98 } 99 rtnVal = true; 100 } 101 return rtnVal; 102 } 103 104 public String getStatus() { 105 if ( isError() ) { 106 return Constants.ERROR; 107 } 108 if ( isSessionPassed() ) { 109 return Constants.PASS; 110 } 111 return Constants.FAIL; 112 } 113 114 public boolean isSessionPassed() { 115 if ( isError() ) { 116 return false; 117 } 118 if ( passedCount != getRecordedTestCount() ) { 119 return false; 120 } 121 return true; 122 } 123 124 public int incrementPassedCount() { 125 return ++passedCount; 126 } 127 128 public int getPassedCount() { 129 return passedCount; 130 } 131 132 public int incrementFailedCount() { 133 return ++failedCount; 134 } 135 136 public int getFailedCount() { 137 return failedCount; 138 } 139 140 } 141 | Popular Tags |