EMMA Coverage Report (generated Wed Jun 22 19:47:49 EDT 2011)
[all classes][org.jclouds.vcloud.functions]

COVERAGE SUMMARY FOR SOURCE FILE [ParseTaskFromLocationHeader.java]

nameclass, %method, %block, %line, %
ParseTaskFromLocationHeader.java100% (1/1)50%  (1/2)8%   (3/37)14%  (1/7)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ParseTaskFromLocationHeader100% (1/1)50%  (1/2)8%   (3/37)14%  (1/7)
apply (HttpResponse): Task 0%   (0/1)0%   (0/34)0%   (0/6)
ParseTaskFromLocationHeader (): void 100% (1/1)100% (3/3)100% (1/1)

1/**
2 *
3 * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4 *
5 * ====================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * 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, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ====================================================================
18 */
19 
20package org.jclouds.vcloud.functions;
21 
22import java.net.URI;
23import java.util.Date;
24 
25import javax.inject.Singleton;
26import javax.ws.rs.core.HttpHeaders;
27 
28import org.jclouds.http.HttpResponse;
29import org.jclouds.http.HttpResponseException;
30import org.jclouds.vcloud.domain.Task;
31import org.jclouds.vcloud.domain.TaskStatus;
32import org.jclouds.vcloud.domain.internal.TaskImpl;
33 
34import com.google.common.base.Function;
35 
36/**
37 * 
38 * @author Adrian Cole
39 */
40@Singleton
41public class ParseTaskFromLocationHeader implements Function<HttpResponse, Task> {
42 
43   public Task apply(HttpResponse from) {
44      String location = from.getFirstHeaderOrNull(HttpHeaders.LOCATION);
45      if (location == null)
46         location = from.getFirstHeaderOrNull("location");
47      if (location != null) {
48         return new TaskImpl(URI.create(location), null, TaskStatus.QUEUED, new Date(), null, null, null, null);
49      } else {
50         throw new HttpResponseException("no uri in headers or content", null, from);
51      }
52 
53   }
54}

[all classes][org.jclouds.vcloud.functions]
EMMA 2.0.5312 (C) Vladimir Roubtsov