PageRenderTime 105ms CodeModel.GetById 96ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageListTest.java

https://github.com/richardcloudsoft/legacy-jclouds
Java | 87 lines | 56 code | 9 blank | 22 comment | 0 complexity | 2bc67505cc367a655ebe808cddffbc26 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.openstack.nova.v2_0.parse;
20
21import java.net.URI;
22import java.util.Set;
23
24import javax.ws.rs.Consumes;
25import javax.ws.rs.core.MediaType;
26
27import org.jclouds.json.BaseSetParserTest;
28import org.jclouds.json.config.GsonModule;
29import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
30import org.jclouds.openstack.v2_0.domain.Link;
31import org.jclouds.openstack.v2_0.domain.Link.Relation;
32import org.jclouds.openstack.v2_0.domain.Resource;
33import org.jclouds.rest.annotations.SelectJson;
34import org.testng.annotations.Test;
35
36import com.google.common.collect.ImmutableSet;
37import com.google.inject.Guice;
38import com.google.inject.Injector;
39
40/**
41 * 
42 * @author Jeremy Daggett
43 */
44@Test(groups = "unit", testName = "ParseImageListTest")
45public class ParseImageListTest extends BaseSetParserTest<Resource> {
46
47   @Override
48   public String resource() {
49      return "/image_list.json";
50   }
51
52   @Override
53   @SelectJson("images")
54   @Consumes(MediaType.APPLICATION_JSON)
55   public Set<Resource> expected() {
56      return ImmutableSet
57            .of(Resource
58                  .builder()
59                  .id("52415800-8b69-11e0-9b19-734f6f006e54")
60                  .name("CentOS 5.2")
61                  .links(
62                        Link.create(
63                              Relation.SELF,
64                              URI.create("http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f6f006e54")),
65                        Link.create(
66                              Relation.BOOKMARK,
67                              URI.create("http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f6f006e54")))
68                  .build(),
69                  Resource
70                        .builder()
71                        .id("52415800-8b69-11e0-9b19-734f5736d2a2")
72                        .name("My Server Backup")
73                        .links(
74                              Link.create(
75                                    Relation.SELF,
76                                    URI.create("http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2")),
77                              Link.create(
78                                    Relation.BOOKMARK,
79                                    URI.create("http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2")))
80                        .build());
81   }
82
83   protected Injector injector() {
84      return Guice.createInjector(new NovaParserModule(), new GsonModule());
85   }
86
87}