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

COVERAGE SUMMARY FOR SOURCE FILE [AllCatalogItemsInCatalog.java]

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

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AllCatalogItemsInCatalog0%   (0/1)0%   (0/3)0%   (0/44)0%   (0/8)
AllCatalogItemsInCatalog (CommonVCloudAsyncClient, ExecutorService): void 0%   (0/1)0%   (0/12)0%   (0/5)
access$000 (AllCatalogItemsInCatalog): CommonVCloudAsyncClient 0%   (0/1)0%   (0/3)0%   (0/1)
apply (Catalog): Iterable 0%   (0/1)0%   (0/29)0%   (0/2)
     
class AllCatalogItemsInCatalog$10%   (0/1)0%   (0/2)0%   (0/11)0%   (0/2)
AllCatalogItemsInCatalog$1 (AllCatalogItemsInCatalog): void 0%   (0/1)0%   (0/6)0%   (0/1)
apply (ReferenceType): boolean 0%   (0/1)0%   (0/5)0%   (0/1)
     
class AllCatalogItemsInCatalog$20%   (0/1)0%   (0/2)0%   (0/13)0%   (0/2)
AllCatalogItemsInCatalog$2 (AllCatalogItemsInCatalog): void 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.logging.Logger;
34import org.jclouds.vcloud.CommonVCloudAsyncClient;
35import org.jclouds.vcloud.VCloudMediaType;
36import org.jclouds.vcloud.domain.Catalog;
37import org.jclouds.vcloud.domain.CatalogItem;
38import org.jclouds.vcloud.domain.ReferenceType;
39 
40import com.google.common.base.Function;
41import com.google.common.base.Predicate;
42 
43/**
44 * @author Adrian Cole
45 */
46@Singleton
47public class AllCatalogItemsInCatalog implements Function<Catalog, Iterable<? extends CatalogItem>> {
48   @Resource
49   public Logger logger = Logger.NULL;
50 
51   private final CommonVCloudAsyncClient aclient;
52   private final ExecutorService executor;
53 
54   @Inject
55   AllCatalogItemsInCatalog(CommonVCloudAsyncClient aclient,
56            @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
57      this.aclient = aclient;
58      this.executor = executor;
59   }
60 
61   @Override
62   public Iterable<? extends CatalogItem> apply(Catalog from) {
63 
64      Iterable<CatalogItem> catalogItems = transformParallel(filter(from.values(), new Predicate<ReferenceType>() {
65 
66         @Override
67         public boolean apply(ReferenceType input) {
68            return input.getType().equals(VCloudMediaType.CATALOGITEM_XML);
69         }
70 
71      }), new Function<ReferenceType, Future<CatalogItem>>() {
72 
73         @SuppressWarnings("unchecked")
74         @Override
75         public Future<CatalogItem> apply(ReferenceType from) {
76            return (Future<CatalogItem>) aclient.getCatalogItem(from.getHref());
77         }
78 
79      }, executor, null, logger, "catalogItems in " + from.getHref());
80      return catalogItems;
81   }
82 
83}

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