EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.savvis.vpdc.domain]

COVERAGE SUMMARY FOR SOURCE FILE [Task.java]

nameclass, %method, %block, %line, %
Task.java100% (3/3)73%  (22/30)81%  (259/321)79%  (37/47)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Task$Builder100% (1/1)85%  (11/13)66%  (78/119)89%  (17/19)
fromTask (Task): Task$Builder 0%   (0/1)0%   (0/34)0%   (0/1)
name (String): Task$Builder 0%   (0/1)0%   (0/7)0%   (0/1)
Task$Builder (): void 100% (1/1)100% (3/3)100% (1/1)
build (): Task 100% (1/1)100% (24/24)100% (1/1)
endTime (Date): Task$Builder 100% (1/1)100% (5/5)100% (2/2)
error (TaskError): Task$Builder 100% (1/1)100% (5/5)100% (2/2)
href (URI): Task$Builder 100% (1/1)100% (7/7)100% (1/1)
id (String): Task$Builder 100% (1/1)100% (7/7)100% (1/1)
owner (Resource): Task$Builder 100% (1/1)100% (5/5)100% (2/2)
result (Resource): Task$Builder 100% (1/1)100% (5/5)100% (2/2)
startTime (Date): Task$Builder 100% (1/1)100% (5/5)100% (2/2)
status (Task$Status): Task$Builder 100% (1/1)100% (5/5)100% (2/2)
type (String): Task$Builder 100% (1/1)100% (7/7)100% (1/1)
     
class Task100% (1/1)40%  (4/10)83%  (89/107)65%  (11/17)
getEndTime (): Date 0%   (0/1)0%   (0/3)0%   (0/1)
getOwner (): Resource 0%   (0/1)0%   (0/3)0%   (0/1)
getResult (): Resource 0%   (0/1)0%   (0/3)0%   (0/1)
getStartTime (): Date 0%   (0/1)0%   (0/3)0%   (0/1)
getStatus (): Task$Status 0%   (0/1)0%   (0/3)0%   (0/1)
toBuilder (): Task$Builder 0%   (0/1)0%   (0/3)0%   (0/1)
Task (String, String, String, URI, Task$Status, Date, Date, Resource, Resourc... 100% (1/1)100% (25/25)100% (8/8)
builder (): Task$Builder 100% (1/1)100% (4/4)100% (1/1)
getError (): TaskError 100% (1/1)100% (3/3)100% (1/1)
toString (): String 100% (1/1)100% (57/57)100% (1/1)
     
class Task$Status100% (1/1)100% (7/7)97%  (92/95)82%  (9/11)
fromValue (String): Task$Status 100% (1/1)70%  (7/10)33%  (1/3)
<static initializer> 100% (1/1)100% (64/64)100% (6/6)
Task$Status (String, int): void 100% (1/1)100% (5/5)100% (1/1)
toString (): String 100% (1/1)100% (3/3)100% (1/1)
value (): String 100% (1/1)100% (4/4)100% (1/1)
valueOf (String): Task$Status 100% (1/1)100% (5/5)100% (1/1)
values (): Task$Status [] 100% (1/1)100% (4/4)100% (1/1)

1/**
2 * Licensed to jclouds, Inc. (jclouds) under one or more
3 * contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  jclouds licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  You may obtain a copy of the License at
9 *
10 *   http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied.  See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.jclouds.savvis.vpdc.domain;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.net.URI;
24import java.util.Date;
25 
26import org.jclouds.javax.annotation.Nullable;
27 
28/**
29 * The result of a client request cannot be returned immediately, the server creates a task entity
30 * and returns its URL to the client. The client can use this URL in a subsequent GET request to
31 * obtain the current status of the task.
32 * 
33 * @see <a href="https://api.sandbox.symphonyvpdc.savvis.net/doc/spec/api/getTask.html" />
34 */
35public class Task extends ResourceImpl {
36   public static Builder builder() {
37      return new Builder();
38   }
39 
40   public static class Builder extends ResourceImpl.Builder {
41      private Status status;
42      private Date startTime;
43      private Date endTime;
44      private Resource owner;
45      private Resource result;
46      private TaskError error;
47 
48      public Builder status(Status status) {
49         this.status = status;
50         return this;
51      }
52 
53      public Builder startTime(Date startTime) {
54         this.startTime = startTime;
55         return this;
56      }
57 
58      public Builder endTime(Date endTime) {
59         this.endTime = endTime;
60         return this;
61      }
62 
63      public Builder owner(Resource owner) {
64         this.owner = owner;
65         return this;
66      }
67 
68      public Builder result(Resource result) {
69         this.result = result;
70         return this;
71      }
72 
73      public Builder error(TaskError error) {
74         this.error = error;
75         return this;
76      }
77 
78      @Override
79      public Builder id(String id) {
80         return Builder.class.cast(super.id(id));
81      }
82 
83      @Override
84      public Builder name(String name) {
85         return Builder.class.cast(super.name(name));
86      }
87 
88      @Override
89      public Builder type(String type) {
90         return Builder.class.cast(super.type(type));
91      }
92 
93      @Override
94      public Builder href(URI href) {
95         return Builder.class.cast(super.href(href));
96      }
97 
98      @Override
99      public Task build() {
100         return new Task(id, name, type, href, status, startTime, endTime, owner, result, error);
101      }
102 
103      public static Builder fromTask(Task in) {
104         return new Builder().id(in.getId()).name(in.getName()).type(in.getType()).href(in.getHref())
105               .status(in.getStatus()).startTime(in.getStartTime()).endTime(in.getEndTime()).owner(in.getOwner())
106               .error(in.getError()).result(in.getResult());
107      }
108   }
109 
110   public enum Status {
111      /**
112       * Savvis VPDC successfully provisioned and available for use.
113       */
114      SUCCESS,
115      /**
116       * Savvis VPDC is processing the user request, please wait for the provisioning process to
117       * complete.
118       */
119      RUNNING,
120 
121      /**
122       * Savvis VPDC is processing the user request, please wait for the provisioning process to
123       * complete.
124       */
125      QUEUED,
126      /**
127       * Savvis VPDC is failed, please kindly contact Savvis administrator for further
128       * clarification/assistance with the respective request data.
129       */
130      ERROR,
131      /**
132       * Unexpected Savvus VPDC Status, Savvis VPDC is failed, please kindly contact Savvis
133       * administrator for further clarification/assistance with the respective request data.
134       */
135      NONE, UNRECOGNIZED;
136      public String value() {
137         return name().toLowerCase();
138      }
139 
140      @Override
141      public String toString() {
142         return value();
143      }
144 
145      public static Status fromValue(String status) {
146         try {
147            return valueOf(checkNotNull(status, "status").toUpperCase());
148         } catch (IllegalArgumentException e) {
149            return UNRECOGNIZED;
150         }
151      }
152 
153   }
154 
155   private final Status status;
156   private final Date startTime;
157   private final Date endTime;
158   private final Resource owner;
159   private final Resource result;
160   private final TaskError error;
161 
162   public Task(String id, String name, String type, URI href, Status status, Date startTime, Date endTime,
163         Resource result, Resource owner, TaskError error) {
164      super(id, name, type, href);
165      this.status = status;
166      this.startTime = startTime;
167      this.endTime = endTime;
168      this.owner = owner;
169      this.result = result;
170      this.error = error;
171   }
172 
173   /**
174    * The current status of the task.
175    */
176   public Status getStatus() {
177      return status;
178   }
179 
180   /**
181    * date and time when the task was started.
182    */
183   public Date getStartTime() {
184      return startTime;
185   }
186 
187   /**
188    * date and time when the task completed. Does not appear for running tasks.
189    */
190   @Nullable
191   public Date getEndTime() {
192      return endTime;
193   }
194 
195   /**
196    * A link to the object that owns the task. For copy operations, the owner is the copy that is
197    * being created. For delete operations, the owner is the deleted object, so this element is not
198    * included. For all other operations, the owner is the object to which the request was made.
199    */
200   @Nullable
201   public Resource getOwner() {
202      return owner;
203   }
204 
205   /**
206    * Result is represent outcome of request url. if any VM related operation, the result will
207    * present as get VApp. if any VMDK related operation, the result will present as get VMKD
208    */
209   @Nullable
210   public Resource getResult() {
211      return result;
212   }
213 
214   /**
215    * error message or related information returned by the task
216    */
217   @Nullable
218   public TaskError getError() {
219      return error;
220   }
221 
222   public Builder toBuilder() {
223      return Builder.fromTask(this);
224   }
225 
226   @Override
227   public String toString() {
228      return "[id=" + id + ", name=" + name + ", type=" + type + ", href=" + href + ", status=" + status
229            + ", startTime=" + startTime + ", endTime=" + endTime + ", owner=" + owner + ", result=" + result
230            + ", error=" + error + "]";
231   }
232 
233}

[all classes][org.jclouds.savvis.vpdc.domain]
EMMA 2.0.5312 (C) Vladimir Roubtsov