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

COVERAGE SUMMARY FOR SOURCE FILE [TerremarkVCloudExpressInternetServiceAndPublicIpAddressSupplier.java]

nameclass, %method, %block, %line, %
TerremarkVCloudExpressInternetServiceAndPublicIpAddressSupplier.java0%   (0/1)0%   (0/2)0%   (0/89)0%   (0/10)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TerremarkVCloudExpressInternetServiceAndPublicIpAddressSupplier0%   (0/1)0%   (0/2)0%   (0/89)0%   (0/10)
TerremarkVCloudExpressInternetServiceAndPublicIpAddressSupplier (TerremarkVCl... 0%   (0/1)0%   (0/9)0%   (0/4)
getNewInternetServiceAndIp (VApp, int, Protocol): Map$Entry 0%   (0/1)0%   (0/80)0%   (0/6)

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.trmk.vcloudexpress.suppliers;
20 
21import static org.jclouds.trmk.vcloud_0_8.options.AddInternetServiceOptions.Builder.withDescription;
22 
23import java.util.Map;
24import java.util.Map.Entry;
25 
26import javax.annotation.Resource;
27import javax.inject.Inject;
28import javax.inject.Named;
29import javax.inject.Singleton;
30 
31import org.jclouds.compute.reference.ComputeServiceConstants;
32import org.jclouds.logging.Logger;
33import org.jclouds.trmk.vcloud_0_8.domain.InternetService;
34import org.jclouds.trmk.vcloud_0_8.domain.Protocol;
35import org.jclouds.trmk.vcloud_0_8.domain.PublicIpAddress;
36import org.jclouds.trmk.vcloud_0_8.domain.VApp;
37import org.jclouds.trmk.vcloud_0_8.suppliers.InternetServiceAndPublicIpAddressSupplier;
38import org.jclouds.trmk.vcloudexpress.TerremarkVCloudExpressClient;
39 
40import com.google.common.collect.ImmutableMap;
41import com.google.common.collect.Iterables;
42 
43/**
44 * @author Adrian Cole
45 */
46@Singleton
47public class TerremarkVCloudExpressInternetServiceAndPublicIpAddressSupplier implements
48      InternetServiceAndPublicIpAddressSupplier {
49 
50   @Resource
51   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
52   public Logger logger = Logger.NULL;
53   protected final TerremarkVCloudExpressClient client;
54 
55   @Inject
56   public TerremarkVCloudExpressInternetServiceAndPublicIpAddressSupplier(TerremarkVCloudExpressClient client) {
57      this.client = client;
58   }
59 
60   @Override
61   public Entry<InternetService, PublicIpAddress> getNewInternetServiceAndIp(VApp vApp, int port, Protocol protocol) {
62      logger.debug(">> creating InternetService in vDC %s:%s:%d", vApp.getVDC().getHref(), protocol, port);
63      InternetService is = client.addInternetServiceToVDC(
64            vApp.getVDC().getHref(),
65            vApp.getName() + "-" + port,
66            protocol,
67            port,
68            withDescription(String.format("port %d access to serverId: %s name: %s", port, vApp.getName(),
69                  vApp.getName())));
70      PublicIpAddress ip = is.getPublicIpAddress();
71      Map<InternetService, PublicIpAddress> result = ImmutableMap.<InternetService, PublicIpAddress> of(is, ip);
72      Entry<InternetService, PublicIpAddress> entry = Iterables.getOnlyElement(result.entrySet());
73      return entry;
74   }
75}

[all classes][org.jclouds.trmk.vcloudexpress.suppliers]
EMMA 2.0.5312 (C) Vladimir Roubtsov