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

COVERAGE SUMMARY FOR SOURCE FILE [SoftLayerParserModule.java]

nameclass, %method, %block, %line, %
SoftLayerParserModule.java100% (4/4)69%  (9/13)46%  (46/99)61%  (12.3/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SoftLayerParserModule$VirtualGuestAdapter$VirtualGuestInternal100% (1/1)50%  (1/2)22%  (8/36)29%  (0.9/3)
SoftLayerParserModule$VirtualGuestAdapter$VirtualGuestInternal (int, Date, bo... 0%   (0/1)0%   (0/27)0%   (0/2)
getBillingItemId (): int 100% (1/1)89%  (8/9)88%  (0.9/1)
     
class SoftLayerParserModule$VirtualGuestAdapter$BillingItem100% (1/1)50%  (2/4)30%  (9/30)42%  (3.4/8)
SoftLayerParserModule$VirtualGuestAdapter$BillingItem (int): void 0%   (0/1)0%   (0/9)0%   (0/4)
toString (): String 0%   (0/1)0%   (0/12)0%   (0/1)
SoftLayerParserModule$VirtualGuestAdapter$BillingItem (): void 100% (1/1)100% (6/6)100% (3/3)
access$000 (SoftLayerParserModule$VirtualGuestAdapter$BillingItem): int 100% (1/1)100% (3/3)100% (1/1)
     
class SoftLayerParserModule$VirtualGuestAdapter100% (1/1)75%  (3/4)76%  (13/17)80%  (4/5)
serialize (VirtualGuest, Type, JsonSerializationContext): JsonElement 0%   (0/1)0%   (0/4)0%   (0/1)
SoftLayerParserModule$VirtualGuestAdapter (): void 100% (1/1)100% (3/3)100% (2/2)
apply (SoftLayerParserModule$VirtualGuestAdapter$VirtualGuestInternal): Virtu... 100% (1/1)100% (2/2)100% (1/1)
deserialize (JsonElement, Type, JsonDeserializationContext): VirtualGuest 100% (1/1)100% (8/8)100% (1/1)
     
class SoftLayerParserModule100% (1/1)100% (3/3)100% (16/16)100% (5/5)
SoftLayerParserModule (): void 100% (1/1)100% (3/3)100% (2/2)
configure (): void 100% (1/1)100% (7/7)100% (2/2)
provideCustomAdapterBindings (): Map 100% (1/1)100% (6/6)100% (1/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.softlayer.config;
20 
21import java.lang.reflect.Type;
22import java.util.Date;
23import java.util.Map;
24 
25import javax.inject.Singleton;
26 
27import org.jclouds.json.config.GsonModule.DateAdapter;
28import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
29import org.jclouds.softlayer.domain.Datacenter;
30import org.jclouds.softlayer.domain.OperatingSystem;
31import org.jclouds.softlayer.domain.PowerState;
32import org.jclouds.softlayer.domain.VirtualGuest;
33 
34import com.google.common.collect.ImmutableMap;
35import com.google.gson.JsonDeserializationContext;
36import com.google.gson.JsonDeserializer;
37import com.google.gson.JsonElement;
38import com.google.gson.JsonParseException;
39import com.google.gson.JsonSerializationContext;
40import com.google.gson.JsonSerializer;
41import com.google.inject.AbstractModule;
42import com.google.inject.Provides;
43 
44/**
45 * 
46 * @author Adrian Cole
47 */
48public class SoftLayerParserModule extends AbstractModule {
49 
50   @Singleton
51   public static class VirtualGuestAdapter implements JsonSerializer<VirtualGuest>, JsonDeserializer<VirtualGuest> {
52 
53      public JsonElement serialize(VirtualGuest src, Type typeOfSrc, JsonSerializationContext context) {
54         return context.serialize(src);
55      }
56 
57      public VirtualGuest deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
58               throws JsonParseException {
59         return apply(context.<VirtualGuestInternal> deserialize(json, VirtualGuestInternal.class));
60      }
61 
62      public VirtualGuest apply(VirtualGuestInternal in) {
63         return in;
64      }
65 
66      /**
67       * Internal class that flattens billingItem into billingItemId
68       */
69      public static class VirtualGuestInternal extends VirtualGuest {
70         private BillingItem billingItem;
71 
72         public VirtualGuestInternal(int accountId, Date createDate, boolean dedicatedAccountHostOnly, String domain,
73                  String fullyQualifiedDomainName, String hostname, int id, Date lastVerifiedDate, int maxCpu,
74                  String maxCpuUnits, int maxMemory, Date metricPollDate, Date modifyDate, String notes,
75                  boolean privateNetworkOnly, int startCpus, int statusId, String uuid, String primaryBackendIpAddress,
76                  String primaryIpAddress, int billingItemId, OperatingSystem operatingSystem, Datacenter datacenter,
77                  PowerState powerState) {
78            super(accountId, createDate, dedicatedAccountHostOnly, domain, fullyQualifiedDomainName, hostname, id,
79                     lastVerifiedDate, maxCpu, maxCpuUnits, maxMemory, metricPollDate, modifyDate, notes,
80                     privateNetworkOnly, startCpus, statusId, uuid, primaryBackendIpAddress, primaryIpAddress,
81                     billingItemId, operatingSystem, datacenter, powerState);
82         }
83 
84         @Override
85         public int getBillingItemId() {
86            return billingItem != null ? billingItem.id : -1;
87         }
88      }
89 
90      public static class BillingItem {
91 
92         private int id = -1;
93 
94         // for deserializer
95         BillingItem() {
96 
97         }
98 
99         public BillingItem(int id) {
100            this.id = id;
101         }
102 
103         @Override
104         public String toString() {
105            return "[id=" + id + "]";
106         }
107      }
108   }
109 
110   @Provides
111   @Singleton
112   public Map<Type, Object> provideCustomAdapterBindings() {
113      return ImmutableMap.<Type, Object> of(VirtualGuest.class, new VirtualGuestAdapter());
114   }
115 
116   @Override
117   protected void configure() {
118      bind(DateAdapter.class).to(Iso8601DateAdapter.class);
119   }
120 
121}

[all classes][org.jclouds.softlayer.config]
EMMA 2.0.5312 (C) Vladimir Roubtsov