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

COVERAGE SUMMARY FOR SOURCE FILE [RimuHostingRestClientModule.java]

nameclass, %method, %block, %line, %
RimuHostingRestClientModule.java100% (3/3)83%  (5/6)90%  (46/51)92%  (13/14)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class RimuHostingRestClientModule$RimuIso8601DateAdapter100% (1/1)67%  (2/3)85%  (29/34)87%  (7/8)
serialize (Date, Type, JsonSerializationContext): JsonElement 0%   (0/1)0%   (0/4)0%   (0/1)
deserialize (JsonElement, Type, JsonDeserializationContext): Date 100% (1/1)95%  (20/21)98%  (3/3)
RimuHostingRestClientModule$RimuIso8601DateAdapter (DateService, Json): void 100% (1/1)100% (9/9)100% (4/4)
     
class RimuHostingRestClientModule100% (1/1)100% (2/2)100% (14/14)100% (5/5)
RimuHostingRestClientModule (): void 100% (1/1)100% (5/5)100% (2/2)
configure (): void 100% (1/1)100% (9/9)100% (3/3)
     
class RimuHostingRestClientModule$RimuIso8601DateAdapter$DateHolder100% (1/1)100% (1/1)100% (3/3)100% (1/1)
RimuHostingRestClientModule$RimuIso8601DateAdapter$DateHolder (): void 100% (1/1)100% (3/3)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.rimuhosting.miro.config;
20 
21import java.lang.reflect.Type;
22import java.util.Date;
23 
24import javax.inject.Inject;
25import javax.inject.Singleton;
26 
27import org.jclouds.date.DateService;
28import org.jclouds.http.RequiresHttp;
29import org.jclouds.json.Json;
30import org.jclouds.json.config.GsonModule.DateAdapter;
31import org.jclouds.rest.ConfiguresRestClient;
32import org.jclouds.rest.config.RestClientModule;
33import org.jclouds.rimuhosting.miro.RimuHostingAsyncClient;
34import org.jclouds.rimuhosting.miro.RimuHostingClient;
35 
36import com.google.gson.JsonDeserializationContext;
37import com.google.gson.JsonElement;
38import com.google.gson.JsonParseException;
39import com.google.gson.JsonSerializationContext;
40 
41/**
42 * 
43 * @author Adrian Cole
44 */
45@RequiresHttp
46@ConfiguresRestClient
47public class RimuHostingRestClientModule extends RestClientModule<RimuHostingClient, RimuHostingAsyncClient> {
48 
49   public RimuHostingRestClientModule() {
50      super(RimuHostingClient.class, RimuHostingAsyncClient.class);
51   }
52 
53   @Override
54   protected void configure() {
55      bind(DateAdapter.class).to(RimuIso8601DateAdapter.class);
56      super.configure();
57   }
58 
59   @Singleton
60   public static class RimuIso8601DateAdapter implements DateAdapter {
61      private final DateService dateService;
62      private final Json json;
63 
64      private static class DateHolder {
65         String iso_format;
66      }
67 
68      @Inject
69      private RimuIso8601DateAdapter(DateService dateService, Json json) {
70         this.dateService = dateService;
71         this.json = json;
72      }
73 
74      public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
75         throw new UnsupportedOperationException();
76      }
77 
78      public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
79               throws JsonParseException {
80         String toParse = json.toString();
81         DateHolder dateHolder = this.json.fromJson(toParse, DateHolder.class);
82         return (dateHolder.iso_format != null) ? dateService.iso8601SecondsDateParse(dateHolder.iso_format) : null;
83      }
84 
85   }
86}

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