mirror of
https://github.com/Fishwaldo/rundeck-api-java-client.git
synced 2025-07-09 06:28:44 +00:00
Add averageDuration for execution job info (v5)
This commit is contained in:
parent
1a810ac463
commit
90d9a46c89
4 changed files with 50 additions and 2 deletions
|
@ -37,6 +37,8 @@ public class RundeckJob implements Serializable {
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
private long averageDuration = -1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the fullname : group + name (exact format is : "group/name")
|
* @return the fullname : group + name (exact format is : "group/name")
|
||||||
*/
|
*/
|
||||||
|
@ -92,7 +94,7 @@ public class RundeckJob implements Serializable {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "RundeckJob [id=" + id + ", name=" + name + ", group=" + group + ", project=" + project
|
return "RundeckJob [id=" + id + ", name=" + name + ", group=" + group + ", project=" + project
|
||||||
+ ", description=" + description + "]";
|
+ ", description=" + description + ", averageDuration="+averageDuration+"]";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -104,6 +106,7 @@ public class RundeckJob implements Serializable {
|
||||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
result = prime * result + ((project == null) ? 0 : project.hashCode());
|
result = prime * result + ((project == null) ? 0 : project.hashCode());
|
||||||
|
result = prime * result + (int) (averageDuration ^ (averageDuration >>> 32));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +144,18 @@ public class RundeckJob implements Serializable {
|
||||||
return false;
|
return false;
|
||||||
} else if (!project.equals(other.project))
|
} else if (!project.equals(other.project))
|
||||||
return false;
|
return false;
|
||||||
|
if (averageDuration != other.averageDuration) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public long getAverageDuration() {
|
||||||
|
return averageDuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAverageDuration(long averageDuration) {
|
||||||
|
this.averageDuration = averageDuration;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,11 @@ public class JobParser implements XmlNodeParser<RundeckJob> {
|
||||||
}
|
}
|
||||||
job.setId(jobId);
|
job.setId(jobId);
|
||||||
|
|
||||||
|
String averageDuration = StringUtils.trimToNull(jobNode.valueOf("@averageDuration"));
|
||||||
|
if (averageDuration != null) {
|
||||||
|
job.setAverageDuration(Long.valueOf(averageDuration));
|
||||||
|
}
|
||||||
|
|
||||||
// project is either a nested element of context, or just a child element
|
// project is either a nested element of context, or just a child element
|
||||||
Node contextNode = jobNode.selectSingleNode("context");
|
Node contextNode = jobNode.selectSingleNode("context");
|
||||||
if (contextNode != null) {
|
if (contextNode != null) {
|
||||||
|
|
|
@ -42,4 +42,33 @@ public class JobParserTest {
|
||||||
Assert.assertEquals("project-name", job.getProject());
|
Assert.assertEquals("project-name", job.getProject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void parseExecutionJob1() throws Exception {
|
||||||
|
InputStream input = getClass().getResourceAsStream("execution-running.xml");
|
||||||
|
Document document = ParserHelper.loadDocument(input);
|
||||||
|
|
||||||
|
RundeckJob job = new JobParser("result/executions/execution/job").parseXmlNode(document);
|
||||||
|
|
||||||
|
Assert.assertEquals("1", job.getId());
|
||||||
|
Assert.assertEquals("ls", job.getName());
|
||||||
|
Assert.assertEquals("list files", job.getDescription());
|
||||||
|
Assert.assertEquals("system", job.getGroup());
|
||||||
|
Assert.assertEquals("test", job.getProject());
|
||||||
|
Assert.assertEquals(10000L, job.getAverageDuration());
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void parseExecutionJob2() throws Exception {
|
||||||
|
InputStream input = getClass().getResourceAsStream("execution-succeeded.xml");
|
||||||
|
Document document = ParserHelper.loadDocument(input);
|
||||||
|
|
||||||
|
RundeckJob job = new JobParser("result/executions/execution/job").parseXmlNode(document);
|
||||||
|
|
||||||
|
Assert.assertEquals("1", job.getId());
|
||||||
|
Assert.assertEquals("ls", job.getName());
|
||||||
|
Assert.assertEquals("list files", job.getDescription());
|
||||||
|
Assert.assertEquals("system", job.getGroup());
|
||||||
|
Assert.assertEquals("test", job.getProject());
|
||||||
|
Assert.assertEquals(-1, job.getAverageDuration());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<result success='true' apiversion='1'><executions count='1'><execution id='1' href='http://localhost:4440/execution/follow/1' status='running'><user>admin</user><date-started unixtime='1302183830082'>2011-04-07T13:43:50Z</date-started><job id='1'><name>ls</name><group>system</group><project>test</project><description>list files</description></job><description>ls ${option.dir}</description><argstring>-arg1 value -arg2 value</argstring></execution></executions></result>
|
<result success='true' apiversion='1'><executions count='1'><execution id='1' href='http://localhost:4440/execution/follow/1' status='running'><user>admin</user><date-started unixtime='1302183830082'>2011-04-07T13:43:50Z</date-started><job id='1' averageDuration="10000"><name>ls</name><group>system</group><project>test</project><description>list files</description></job><description>ls ${option.dir}</description><argstring>-arg1 value -arg2 value</argstring></execution></executions></result>
|
Loading…
Add table
Add a link
Reference in a new issue