PageRenderTime 38ms CodeModel.GetById 25ms app.highlight 11ms RepoModel.GetById 0ms app.codeStats 0ms

/apis/vcloud/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java

https://github.com/gnodet/jclouds
Java | 90 lines | 55 code | 12 blank | 23 comment | 0 complexity | 70f1dae49160b98062bafbc359ffd2ee 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.vcloud.options;
20
21import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig;
22import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.customizeOnInstantiate;
23import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.description;
24import static org.testng.Assert.assertEquals;
25
26import java.net.URI;
27
28import org.jclouds.http.functions.config.SaxParserModule;
29import org.jclouds.vcloud.domain.network.FenceMode;
30import org.jclouds.vcloud.domain.network.NetworkConfig;
31import org.testng.annotations.Test;
32
33import com.google.common.collect.Iterables;
34import com.google.inject.Guice;
35import com.google.inject.Injector;
36
37/**
38 * Tests behavior of {@code InstantiateVAppTemplateOptions}
39 * 
40 * @author Adrian Cole
41 */
42@Test(groups = "unit")
43public class InstantiateVAppTemplateOptionsTest {
44
45   Injector injector = Guice.createInjector(new SaxParserModule());
46
47   @Test
48   public void testAddNetworkConfig() {
49      InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
50      options.addNetworkConfig(new NetworkConfig("default", URI.create("http://localhost"), FenceMode.BRIDGED));
51      assertEquals(Iterables.get(options.getNetworkConfig(), 0).getNetworkName(), "default");
52      assertEquals(Iterables.get(options.getNetworkConfig(), 0).getParentNetwork(), URI.create("http://localhost"));
53      assertEquals(Iterables.get(options.getNetworkConfig(), 0).getFenceMode(), FenceMode.BRIDGED);
54   }
55
56   @Test
57   public void testAddNetworkConfigStatic() {
58      InstantiateVAppTemplateOptions options = addNetworkConfig(new NetworkConfig("default",
59            URI.create("http://localhost"), FenceMode.BRIDGED));
60      assertEquals(Iterables.get(options.getNetworkConfig(), 0).getNetworkName(), "default");
61      assertEquals(Iterables.get(options.getNetworkConfig(), 0).getParentNetwork(), URI.create("http://localhost"));
62      assertEquals(Iterables.get(options.getNetworkConfig(), 0).getFenceMode(), FenceMode.BRIDGED);
63   }
64
65   @Test
66   public void testCustomizeOnInstantiate() {
67      InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
68      options.customizeOnInstantiate(true);
69      assertEquals(options.shouldCustomizeOnInstantiate(), new Boolean(true));
70   }
71
72   @Test
73   public void testCustomizeOnInstantiateStatic() {
74      InstantiateVAppTemplateOptions options = customizeOnInstantiate(true);
75      assertEquals(options.shouldCustomizeOnInstantiate(), new Boolean(true));
76   }
77
78   @Test
79   public void testDescription() {
80      InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
81      options.description("foo");
82      assertEquals(options.getDescription(), "foo");
83   }
84
85   @Test
86   public void testDescriptionStatic() {
87      InstantiateVAppTemplateOptions options = description("foo");
88      assertEquals(options.getDescription(), "foo");
89   }
90}