/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayloadTest.java
https://github.com/andreisavu/jclouds · Java · 86 lines · 48 code · 15 blank · 23 comment · 0 complexity · f4d98b3dbbf9daecc5d7e806e8ee95c6 MD5 · raw file
- /**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
- package org.jclouds.vcloud.binders;
- import static org.easymock.EasyMock.createMock;
- import static org.easymock.EasyMock.expect;
- import static org.easymock.EasyMock.replay;
- import static org.easymock.EasyMock.verify;
- import java.io.IOException;
- import java.net.URI;
- import java.util.Map;
- import org.jclouds.rest.internal.GeneratedHttpRequest;
- import org.jclouds.vcloud.VCloudApiMetadata;
- import org.nnsoft.guice.rocoto.Rocoto;
- import org.nnsoft.guice.rocoto.configuration.ConfigurationModule;
- import org.testng.annotations.Test;
- import com.google.common.collect.Maps;
- import com.google.inject.Guice;
- import com.google.inject.Injector;
- /**
- * Tests behavior of {@code BindUndeployVAppParamsToXmlPayload}
- *
- * @author Adrian Cole
- */
- @Test(groups = "unit")
- public class BindUndeployVAppParamsToXmlPayloadTest {
- Injector injector = Guice.createInjector(Rocoto.expandVariables(new ConfigurationModule() {
- @Override
- protected void bindConfigurations() {
- bindProperties(new VCloudApiMetadata().getDefaultProperties());
- }
- }));
-
- public void testSaveStateTrue() throws IOException {
- String expected = "<UndeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\" saveState=\"true\"/>";
- GeneratedHttpRequest request = createMock(GeneratedHttpRequest.class);
- expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
- request.setPayload(expected);
- replay(request);
- BindUndeployVAppParamsToXmlPayload binder = injector.getInstance(BindUndeployVAppParamsToXmlPayload.class);
- Map<String, Object> map = Maps.newHashMap();
- map.put("saveState", "true");
- binder.bindToRequest(request, map);
- verify(request);
- }
- public void testDefault() throws IOException {
- String expected = "<UndeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\"/>";
- GeneratedHttpRequest request = createMock(GeneratedHttpRequest.class);
- expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
- request.setPayload(expected);
- replay(request);
- BindUndeployVAppParamsToXmlPayload binder = injector.getInstance(BindUndeployVAppParamsToXmlPayload.class);
- Map<String, Object> map = Maps.newHashMap();
- binder.bindToRequest(request, map);
- verify(request);
- }
- }