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

COVERAGE SUMMARY FOR SOURCE FILE [ParseBlobPropertiesFromHeaders.java]

nameclass, %method, %block, %line, %
ParseBlobPropertiesFromHeaders.java100% (1/1)75%  (3/4)68%  (34/50)69%  (9/13)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ParseBlobPropertiesFromHeaders100% (1/1)75%  (3/4)68%  (34/50)69%  (9/13)
apply (HttpResponse): MutableBlobProperties 0%   (0/1)0%   (0/16)0%   (0/4)
ParseBlobPropertiesFromHeaders (ParseSystemAndUserMetadataFromHeaders, BlobMe... 100% (1/1)100% (9/9)100% (4/4)
setContainer (String): ParseBlobPropertiesFromHeaders 100% (1/1)100% (5/5)100% (2/2)
setContext (HttpRequest): ParseBlobPropertiesFromHeaders 100% (1/1)100% (20/20)100% (3/3)

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.azureblob.functions;
20 
21import static com.google.common.base.Preconditions.checkArgument;
22 
23import javax.inject.Inject;
24 
25import org.jclouds.azureblob.blobstore.functions.BlobMetadataToBlobProperties;
26import org.jclouds.azureblob.domain.MutableBlobProperties;
27import org.jclouds.blobstore.domain.BlobMetadata;
28import org.jclouds.blobstore.functions.ParseSystemAndUserMetadataFromHeaders;
29import org.jclouds.http.HttpRequest;
30import org.jclouds.http.HttpResponse;
31import org.jclouds.rest.InvocationContext;
32import org.jclouds.rest.internal.GeneratedHttpRequest;
33 
34import com.google.common.base.Function;
35 
36/**
37 * This parses @{link {@link org.jclouds.azureblob.domain.BlobProperties} from HTTP
38 * headers.
39 * 
40 * 
41 * @author Adrian Cole
42 */
43public class ParseBlobPropertiesFromHeaders implements Function<HttpResponse, MutableBlobProperties>,
44      InvocationContext<ParseBlobPropertiesFromHeaders> {
45   private final ParseSystemAndUserMetadataFromHeaders blobMetadataParser;
46   private final BlobMetadataToBlobProperties blobToBlobProperties;
47   private String container;
48 
49   @Inject
50   public ParseBlobPropertiesFromHeaders(ParseSystemAndUserMetadataFromHeaders blobMetadataParser,
51         BlobMetadataToBlobProperties blobToBlobProperties) {
52      this.blobMetadataParser = blobMetadataParser;
53      this.blobToBlobProperties = blobToBlobProperties;
54   }
55 
56   /**
57    * parses the http response headers to create a new {@link MutableBlobProperties} object.
58    */
59   public MutableBlobProperties apply(HttpResponse from) {
60      BlobMetadata base = blobMetadataParser.apply(from);
61      MutableBlobProperties to = blobToBlobProperties.apply(base);
62      to.setContainer(container);
63      return to;
64   }
65 
66 
67   @Override
68   public ParseBlobPropertiesFromHeaders setContext(HttpRequest request) {
69      checkArgument(request instanceof GeneratedHttpRequest<?>, "note this handler requires a GeneratedHttpRequest");
70      blobMetadataParser.setContext(request);
71      return setContainer(GeneratedHttpRequest.class.cast(request).getArgs().get(0).toString());
72   }
73 
74   private ParseBlobPropertiesFromHeaders setContainer(String container) {
75      this.container = container;
76      return this;
77   }
78}

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