001/** 002 * //////////////////////////////////////////////////////////////////////////////// 003 * // 004 * // D SOFTWARE INCORPORATED 005 * // Copyright 2007-2014 D Software Incorporated 006 * // All Rights Reserved. 007 * // 008 * // NOTICE: D Software permits you to use, modify, and distribute this file 009 * // in accordance with the terms of the license agreement accompanying it. 010 * // 011 * // Unless required by applicable law or agreed to in writing, software 012 * // distributed under the License is distributed on an "AS IS" BASIS, 013 * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * // 015 * //////////////////////////////////////////////////////////////////////////////// 016 */ 017package com.thed.model; 018 019import java.util.Date; 020import java.util.List; 021 022/** 023 * Value Object that contains batch information 024 * 025 * @author zephyrDev 026 */ 027public class TestcaseBatchExecution { 028 029 /*---------------------------------------------------------- 030 * ATTRIBUTES 031 *----------------------------------------------------------*/ 032 033 public static final int STATUS_CREATED = 1; 034 public static final int STATUS_ASSIGNED = 2; 035 public static final int STATUS_WIP = 3; 036 public static final int STATUS_COMPLETED = 4; 037 038 /* id */ 039 private Long id ; 040 041 /* creation time, used in deletion of old objects */ 042 private Date createDate ; 043 044 /* user id who created the batch */ 045 private Long userId; 046 047 /* agent identifier */ 048 private String agentToken ; 049 050 /* one-to-many relationship to TestcaseExeuction */ 051 private List<TestcaseExecution> testcaseExecutionList ; 052 053 /* before execution of testcase, ZBot will update testcase status to this value. 054 * -1 indicates don't update */ 055 private int updateTestcaseStatus ; 056 057 /** 058 * This flag determines whether ZBot will update the testcases to PASS/FAIL after the 059 * script has been executed and parsing has not been selected. 060 * TRUE - Update with PASS/FAIL status 061 * FALSE - No update 062 */ 063 private Boolean updateTestcaseStatusFromScript; 064 065 /* status of this batch 066 * 1: created, not assigned (just created by flex client) 067 * 2: assigned to a zbot (servlet's checkPayload() method updates this status) 068 * 3: work-in-progress. this status is set in ZBot process. this is not synced back to server. 069 * Server status is still 2, recognizing which, task is not assigned to any other zbot. 070 * 4: execution completed. This status is set withing ZBot process. 071 * ZBot's sendResponse() sends this value to server. 072 * (actually it serializes entire TestcaseBatchExecution object and transmits to server) 073 */ 074 private int status = 1 ; 075 076 private String scriptPath; 077 078 private String parameter; 079 080 private Long jobId; 081 082 /* TODO:other attributes related to scheduling */ 083 084 085 /*---------------------------------------------------------- 086 * END OF ATTRIBUTES 087 *----------------------------------------------------------*/ 088 089 /*---------------------------------------------------------- 090 * GETTER AND SETTER 091 *----------------------------------------------------------*/ 092 093 public Long getId() { 094 return id; 095 } 096 097 public void setId(Long id) { 098 this.id = id; 099 } 100 101 public Date getCreateDate() { 102 return createDate; 103 } 104 105 public void setCreateDate(Date createDate) { 106 this.createDate = createDate; 107 } 108 109 public Long getUserId() { 110 return userId; 111 } 112 113 public void setUserId(Long userId) { 114 this.userId = userId; 115 } 116 117 public String getAgentToken() { 118 return agentToken; 119 } 120 121 public void setAgentToken(String agentToken) { 122 this.agentToken = agentToken; 123 } 124 125 public List<TestcaseExecution> getTestcaseExecutionList() { 126 return testcaseExecutionList; 127 } 128 129 public void setTestcaseExecutionList( 130 List<TestcaseExecution> testcaseExecutionList) { 131 this.testcaseExecutionList = testcaseExecutionList; 132 } 133 134 public int getUpdateTestcaseStatus() { 135 return updateTestcaseStatus; 136 } 137 138 public void setUpdateTestcaseStatus(int updateTestcaseStatus) { 139 this.updateTestcaseStatus = updateTestcaseStatus; 140 } 141 142 public Boolean getUpdateTestcaseStatusFromScript() { 143 return updateTestcaseStatusFromScript; 144 } 145 146 public void setUpdateTestcaseStatusFromScript(Boolean updateTestcaseStatusFromScript) { 147 this.updateTestcaseStatusFromScript = updateTestcaseStatusFromScript; 148 } 149 150 public int getStatus() { 151 return status; 152 } 153 154 public void setStatus(int status) { 155 this.status = status; 156 } 157 158 public Long getJobId() { 159 return jobId; 160 } 161 162 public void setJobId(Long jobId) { 163 this.jobId = jobId; 164 } 165 166 public String getScriptPath() { 167 return scriptPath; 168 } 169 170 public void setScriptPath(String scriptPath) { 171 this.scriptPath = scriptPath; 172 } 173 174 public String getParameter() { 175 return parameter; 176 } 177 178 public void setParameter(String parameter) { 179 this.parameter = parameter; 180 } 181 182 /*---------------------------------------------------------- 183 * END OF GETTER AND SETTER 184 *----------------------------------------------------------*/ 185 186 /*---------------------------------------------------------- 187 * OVERRIDDEN METHODS 188 *----------------------------------------------------------*/ 189 190 191 @Override 192 public String toString() { 193 return "TestcaseBatchExecution: id: %s, agentId: %s".formatted(id, agentToken); 194 } 195 196 @Override 197 public int hashCode() { 198 final int prime = 31; 199 int result = 1; 200 result = prime * result + ((id == null) ? 0 : id.hashCode()); 201 return result; 202 } 203 204 @Override 205 public boolean equals(Object obj) { 206 if (this == obj) 207 return true; 208 if (obj == null) 209 return false; 210 if (getClass() != obj.getClass()) 211 return false; 212 TestcaseBatchExecution other = (TestcaseBatchExecution) obj; 213 if (id == null) { 214 if (other.id != null) 215 return false; 216 } else if (!id.equals(other.id)) 217 return false; 218 return true; 219 } 220 221 222 223 /*---------------------------------------------------------- 224 * END OF sOVERRIDDEN METHODS 225 *----------------------------------------------------------*/ 226 227 228}