PageRenderTime 23ms CodeModel.GetById 18ms app.highlight 3ms RepoModel.GetById 0ms app.codeStats 1ms

/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListAccountsResponseTest.java

https://github.com/vkris/jclouds
Java | 112 lines | 79 code | 11 blank | 22 comment | 0 complexity | f327ef614f7053efe75a179e222515f3 MD5 | raw file
  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.cloudstack.parse;
 20
 21import java.util.Set;
 22
 23import org.jclouds.cloudstack.config.CloudStackParserModule;
 24import org.jclouds.cloudstack.domain.Account;
 25import org.jclouds.cloudstack.domain.Account.State;
 26import org.jclouds.cloudstack.domain.Account.Type;
 27import org.jclouds.cloudstack.domain.User;
 28import org.jclouds.date.internal.SimpleDateFormatDateService;
 29import org.jclouds.json.BaseSetParserTest;
 30import org.jclouds.json.config.GsonModule;
 31import org.jclouds.rest.annotations.SelectJson;
 32import org.testng.annotations.Test;
 33
 34import com.google.common.collect.ImmutableSet;
 35import com.google.inject.Guice;
 36import com.google.inject.Injector;
 37
 38/**
 39 * 
 40 * @author Adrian Cole
 41 */
 42@Test(groups = "unit")
 43public class ListAccountsResponseTest extends BaseSetParserTest<Account> {
 44   
 45   @Override
 46   protected Injector injector() {
 47      return Guice.createInjector(new CloudStackParserModule(), new GsonModule() {
 48
 49         @Override
 50         protected void configure() {
 51            bind(DateAdapter.class).to(Iso8601DateAdapter.class);
 52            super.configure();
 53         }
 54
 55      });
 56
 57   }
 58
 59   @Override
 60   public String resource() {
 61      return "/listaccountsresponse.json";
 62   }
 63
 64   @Override
 65   @SelectJson("account")
 66   public Set<Account> expected() {
 67      return ImmutableSet.<Account> of(Account
 68            .builder()
 69            .id(505)
 70            .name("jclouds")
 71            .type(Type.USER)
 72            .domainId(457)
 73            .domain("AA000062-jclouds-dev")
 74            .receivedBytes(318900216)
 75            .sentBytes(23189677)
 76            .VMLimit(15l)
 77            .VMs(1)
 78            .IPsAvailable(14l)
 79            .IPLimit(15l)
 80            .IPs(0)
 81            .IPsAvailable(15l)
 82            .volumeLimit(90l)
 83            .volumes(2)
 84            .volumesAvailable(88l)
 85            .snapshotLimit(250l)
 86            .snapshots(0)
 87            .snapshotsAvailable(250l)
 88            .templateLimit(15l)
 89            .templates(0)
 90            .templatesAvailable(15l)
 91            .VMsAvailable(14l)
 92            .VMsStopped(0)
 93            .VMsRunning(1)
 94            .state(State.ENABLED)
 95            .users(
 96                  ImmutableSet.of(User.builder()
 97                        .id(505)
 98                .name("jclouds")
 99                .firstName("Adrian")
100                .lastName("Cole")
101                .email("adrian@jclouds.org")
102                .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-04-19T01:57:24+0000"))
103                .state("enabled")
104                .account("jclouds")
105                .accountType(Type.USER)
106                .domainId(457)
107                .domain("AA000062-jclouds-dev")
108                .apiKey("APIKEY")
109                .secretKey("SECRETKEY").build())).build());
110   }
111
112}