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 26 public class TestResults { 27 28 private String uri; 29 private int testNumber; 30 private boolean error; 32 private boolean testPassed = true; 34 private List diffResults; 36 37 public TestResults( int testNumber, final String uri ) { 38 this( testNumber, uri, false, true ); 39 } 40 41 public TestResults( int testNumber, String uri, boolean error, boolean testPassed ) { 42 this.uri = uri; 43 this.testNumber = testNumber; 44 this.error = error; 45 this.testPassed = testPassed; 46 } 47 48 public String getUri() { 49 return uri; 50 } 51 52 public int getTestNumber() { 53 return testNumber; 54 } 55 56 public String getStatus() { 57 if ( error ) { 58 return Constants.ERROR; 59 } 60 if ( testPassed ) { 61 return Constants.PASS; 62 } 63 return Constants.FAIL; 64 } 65 66 public boolean isError() { 67 return error; 68 } 69 70 public boolean isTestPassed() { 71 if ( isError() ) { 72 return false; 73 } 74 return testPassed; 75 } 76 77 public void addDiffResult( String result ) { 78 addDiffResult( result, false ); 79 } 80 81 public void addDiffResult( String result, final boolean error ) { 82 if ( error ) { 83 this.error = true; 84 } 85 testPassed = false; 86 if ( diffResults == null ) { 87 diffResults = new ArrayList (); 88 } 89 diffResults.add( result ); 90 } 91 92 public List getDiffResults() { 94 if ( diffResults == null ) { 95 return null; 96 } 97 return Collections.unmodifiableList( diffResults ); 98 } 99 100 public String toString() { 101 StringBuffer sb = new StringBuffer ( 16 ); 102 sb.append( "[ " ); 103 sb.append( ", status( " + getStatus() + " )" ); 104 sb.append( ", diffResults( " + 105 ( ( diffResults == null ) ? "null" : 106 Util.toString( diffResults.iterator(), diffResults.size() ) ) + " )" ); 107 sb.append( " ]" ); 108 return sb.toString(); 109 } 110 111 } 112 | Popular Tags |