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

COVERAGE SUMMARY FOR SOURCE FILE [VCloudExpressAllCatalogItemsInCatalog.java]

nameclass, %method, %block, %line, %
VCloudExpressAllCatalogItemsInCatalog.java0%   (0/3)0%   (0/7)0%   (0/68)0%   (0/11)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class VCloudExpressAllCatalogItemsInCatalog0%   (0/1)0%   (0/3)0%   (0/44)0%   (0/8)
VCloudExpressAllCatalogItemsInCatalog (VCloudExpressAsyncClient, ExecutorServ... 0%   (0/1)0%   (0/12)0%   (0/5)
access$000 (VCloudExpressAllCatalogItemsInCatalog): VCloudExpressAsyncClient 0%   (0/1)0%   (0/3)0%   (0/1)
apply (Catalog): Iterable 0%   (0/1)0%   (0/29)0%   (0/2)
     
class VCloudExpressAllCatalogItemsInCatalog$10%   (0/1)0%   (0/2)0%   (0/11)0%   (0/2)
VCloudExpressAllCatalogItemsInCatalog$1 (VCloudExpressAllCatalogItemsInCatalo... 0%   (0/1)0%   (0/6)0%   (0/1)
apply (ReferenceType): boolean 0%   (0/1)0%   (0/5)0%   (0/1)
     
class VCloudExpressAllCatalogItemsInCatalog$20%   (0/1)0%   (0/2)0%   (0/13)0%   (0/2)
VCloudExpressAllCatalogItemsInCatalog$2 (VCloudExpressAllCatalogItemsInCatalo... 0%   (0/1)0%   (0/6)0%   (0/1)
apply (ReferenceType): Future 0%   (0/1)0%   (0/7)0%   (0/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 */
19package org.jclouds.vcloud.functions;
20 
21import static com.google.common.collect.Iterables.filter;
22import static org.jclouds.concurrent.FutureIterables.transformParallel;
23 
24import java.util.concurrent.ExecutorService;
25import java.util.concurrent.Future;
26 
27import javax.annotation.Resource;
28import javax.inject.Inject;
29import javax.inject.Named;
30import javax.inject.Singleton;
31 
32import org.jclouds.Constants;
33import org.jclouds.compute.reference.ComputeServiceConstants;
34import org.jclouds.logging.Logger;
35import org.jclouds.vcloud.VCloudExpressAsyncClient;
36import org.jclouds.vcloud.VCloudExpressMediaType;
37import org.jclouds.vcloud.domain.Catalog;
38import org.jclouds.vcloud.domain.CatalogItem;
39import org.jclouds.vcloud.domain.ReferenceType;
40 
41import com.google.common.base.Function;
42import com.google.common.base.Predicate;
43 
44/**
45 * @author Adrian Cole
46 */
47@Singleton
48public class VCloudExpressAllCatalogItemsInCatalog implements Function<Catalog, Iterable<? extends CatalogItem>> {
49   @Resource
50   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
51   public Logger logger = Logger.NULL;
52 
53   private final VCloudExpressAsyncClient aclient;
54   private final ExecutorService executor;
55 
56   @Inject
57   VCloudExpressAllCatalogItemsInCatalog(VCloudExpressAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
58      this.aclient = aclient;
59      this.executor = executor;
60   }
61 
62   @Override
63   public Iterable<? extends CatalogItem> apply(Catalog from) {
64 
65      Iterable<CatalogItem> catalogItems = transformParallel(filter(from.values(), new Predicate<ReferenceType>() {
66 
67         @Override
68         public boolean apply(ReferenceType input) {
69            return input.getType().equals(VCloudExpressMediaType.CATALOGITEM_XML);
70         }
71 
72      }), new Function<ReferenceType, Future<CatalogItem>>() {
73 
74         @SuppressWarnings("unchecked")
75         @Override
76         public Future<CatalogItem> apply(ReferenceType from) {
77            return (Future<CatalogItem>) aclient.getCatalogItem(from.getHref());
78         }
79 
80      }, executor, null, logger, "catalogItems in " + from.getHref());
81      return catalogItems;
82   }
83 
84}

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