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

COVERAGE SUMMARY FOR SOURCE FILE [OrgsForLocations.java]

nameclass, %method, %block, %line, %
OrgsForLocations.java0%   (0/4)0%   (0/9)0%   (0/76)0%   (0/12)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class OrgsForLocations0%   (0/1)0%   (0/3)0%   (0/39)0%   (0/7)
OrgsForLocations (VCloudAsyncClient, ExecutorService): void 0%   (0/1)0%   (0/12)0%   (0/5)
access$000 (OrgsForLocations): VCloudAsyncClient 0%   (0/1)0%   (0/3)0%   (0/1)
apply (Iterable): Iterable 0%   (0/1)0%   (0/24)0%   (0/1)
     
class OrgsForLocations$10%   (0/1)0%   (0/2)0%   (0/14)0%   (0/2)
OrgsForLocations$1 (OrgsForLocations): void 0%   (0/1)0%   (0/6)0%   (0/1)
apply (Location): boolean 0%   (0/1)0%   (0/8)0%   (0/1)
     
class OrgsForLocations$20%   (0/1)0%   (0/2)0%   (0/11)0%   (0/2)
OrgsForLocations$2 (OrgsForLocations): void 0%   (0/1)0%   (0/6)0%   (0/1)
apply (Location): URI 0%   (0/1)0%   (0/5)0%   (0/1)
     
class OrgsForLocations$30%   (0/1)0%   (0/2)0%   (0/12)0%   (0/2)
OrgsForLocations$3 (OrgsForLocations): void 0%   (0/1)0%   (0/6)0%   (0/1)
apply (URI): Future 0%   (0/1)0%   (0/6)0%   (0/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.vcloud.functions;
20 
21import static com.google.common.collect.Iterables.filter;
22import static com.google.common.collect.Iterables.transform;
23import static org.jclouds.concurrent.FutureIterables.transformParallel;
24 
25import java.net.URI;
26import java.util.concurrent.ExecutorService;
27import java.util.concurrent.Future;
28 
29import javax.annotation.Resource;
30import javax.inject.Inject;
31import javax.inject.Named;
32import javax.inject.Singleton;
33 
34import org.jclouds.Constants;
35import org.jclouds.domain.Location;
36import org.jclouds.domain.LocationScope;
37import org.jclouds.logging.Logger;
38import org.jclouds.vcloud.VCloudAsyncClient;
39import org.jclouds.vcloud.domain.Org;
40 
41import com.google.common.base.Function;
42import com.google.common.base.Predicate;
43import com.google.common.collect.Sets;
44 
45/**
46 * @author Adrian Cole
47 */
48@Singleton
49public class OrgsForLocations implements Function<Iterable<? extends Location>, Iterable<? extends Org>> {
50   @Resource
51   public Logger logger = Logger.NULL;
52   private final VCloudAsyncClient aclient;
53   private final ExecutorService executor;
54 
55   @Inject
56   OrgsForLocations(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
57      this.aclient = aclient;
58      this.executor = executor;
59   }
60 
61   /**
62    * Zones are assignable, but we want regions. so we look for zones, whose
63    * parent is region. then, we use a set to extract the unique set.
64    */
65   @Override
66   public Iterable<? extends Org> apply(Iterable<? extends Location> from) {
67 
68      return transformParallel(Sets.newLinkedHashSet(transform(filter(from, new Predicate<Location>() {
69 
70         @Override
71         public boolean apply(Location input) {
72            return input.getScope() == LocationScope.ZONE;
73         }
74 
75      }), new Function<Location, URI>() {
76 
77         @Override
78         public URI apply(Location from) {
79            return URI.create(from.getParent().getId());
80         }
81 
82      })), new Function<URI, Future<Org>>() {
83 
84         @SuppressWarnings("unchecked")
85         @Override
86         public Future<Org> apply(URI from) {
87            return (Future<Org>) aclient.getOrg(from);
88         }
89 
90      }, executor, null, logger, "organizations for uris");
91   }
92 
93}

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