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

COVERAGE SUMMARY FOR SOURCE FILE [DeleteKeyPair.java]

nameclass, %method, %block, %line, %
DeleteKeyPair.java100% (1/1)100% (2/2)100% (75/75)100% (12/12)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DeleteKeyPair100% (1/1)100% (2/2)100% (75/75)100% (12/12)
DeleteKeyPair (TerremarkVCloudClient, ConcurrentMap): void 100% (1/1)100% (12/12)100% (5/5)
execute (OrgAndName): void 100% (1/1)100% (63/63)100% (7/7)

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.vcloud_0_8.compute.strategy;
20 
21import java.util.concurrent.ConcurrentMap;
22 
23import javax.annotation.Resource;
24import javax.inject.Inject;
25import javax.inject.Named;
26import javax.inject.Singleton;
27 
28import org.jclouds.compute.reference.ComputeServiceConstants;
29import org.jclouds.logging.Logger;
30import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient;
31import org.jclouds.trmk.vcloud_0_8.compute.domain.KeyPairCredentials;
32import org.jclouds.trmk.vcloud_0_8.compute.domain.OrgAndName;
33import org.jclouds.trmk.vcloud_0_8.domain.KeyPair;
34 
35/**
36 * 
37 * @author Adrian Cole
38 * 
39 */
40@Singleton
41public class DeleteKeyPair {
42   @Resource
43   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
44   protected Logger logger = Logger.NULL;
45 
46   final TerremarkVCloudClient terremarkClient;
47   final ConcurrentMap<OrgAndName, KeyPairCredentials> credentialsMap;
48 
49   @Inject
50   DeleteKeyPair(TerremarkVCloudClient terremarkClient, ConcurrentMap<OrgAndName, KeyPairCredentials> credentialsMap) {
51      this.terremarkClient = terremarkClient;
52      this.credentialsMap = credentialsMap;
53   }
54 
55   public void execute(OrgAndName orgTag) {
56      for (KeyPair keyPair : terremarkClient.listKeyPairsInOrg(orgTag.getOrg())) {
57         if (keyPair.getName().matches("jclouds#" + orgTag.getName() + "#[0-9a-f]+")) {
58            logger.debug(">> deleting keyPair(%s)", keyPair.getName());
59            terremarkClient.deleteKeyPair(keyPair.getId());
60            // TODO: test this clear happens
61            credentialsMap.remove(orgTag);
62            logger.debug("<< deleted keyPair(%s)", keyPair.getName());
63         }
64      }
65   }
66}

[all classes][org.jclouds.trmk.vcloud_0_8.compute.strategy]
EMMA 2.0.5312 (C) Vladimir Roubtsov