summaryrefslogtreecommitdiffstats
path: root/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java')
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/TestRebootServer.java50
1 files changed, 45 insertions, 5 deletions
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/TestRebootServer.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/TestRebootServer.java
index 33ce7c2cc..876201fa6 100644
--- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/TestRebootServer.java
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/TestRebootServer.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,23 +24,26 @@
*/
package org.onap.appc.adapter.iaas.provider.operation.impl;
-import static org.mockito.Mockito.inOrder;
import org.onap.appc.adapter.iaas.ProviderAdapter;
-import org.junit.Assert;
+import org.onap.appc.adapter.iaas.impl.RequestContext;
+import org.onap.appc.adapter.iaas.impl.RequestFailedException;
+import org.onap.appc.configuration.ConfigurationFactory;
import org.junit.Test;
-import org.mockito.InOrder;
+import org.mockito.Mockito;
import org.onap.appc.exceptions.APPCException;
import com.att.cdp.exceptions.ZoneException;
+import com.att.cdp.zones.Context;
import com.att.cdp.zones.model.Server;
import com.att.cdp.zones.model.Server.Status;
+import com.att.cdp.zones.model.Tenant;
import static org.junit.Assert.assertEquals;
+import java.util.Properties;
public class TestRebootServer {
@Test
- public void should_returnNullAsServer() throws ZoneException,APPCException {
+ public void should_returnNullAsServer() throws ZoneException,APPCException {
MockGenerator mg = new MockGenerator(Status.SUSPENDED);
- Server server = mg.getServer();
RebootServer rbs = new RebootServer();
mg.getParams().put(ProviderAdapter.PROPERTY_INSTANCE_URL, "url1");
mg.getParams().put(ProviderAdapter.REBOOT_TYPE, "");
@@ -48,4 +53,39 @@ public class TestRebootServer {
assertEquals("SUCCESS", mg.getParams().get("REBOOT_STATUS"));
}
+ @Test
+ public void rebootServerTest() throws ZoneException,APPCException, RequestFailedException {
+ MockGenerator mg = new MockGenerator(Status.RUNNING);
+ SubclassRebootServer rbs = Mockito.spy(new SubclassRebootServer());
+ mg.getParams().put(ProviderAdapter.PROPERTY_INSTANCE_URL, getURL());
+ mg.getParams().put(ProviderAdapter.REBOOT_TYPE, "HARD");
+ mg.getParams().put("REBOOT_STATUS", "SUCCESS");
+ Tenant tenant = new Tenant();
+ tenant.setName("TENANT_NAME");
+ mg.getContext().setTenant(tenant);
+ Mockito.doReturn(mg.getContext()).when(rbs).getContext(Mockito.any(RequestContext.class), Mockito.anyString(),
+ Mockito.anyString());
+ Mockito.doReturn(mg.getServer()).when(rbs).lookupServer(Mockito.any(RequestContext.class), Mockito.any(Context.class),
+ Mockito.anyString());
+ rbs.setProviderCache(mg.getProviderCacheMap());
+ rbs.executeProviderOperation(mg.getParams(), mg.getSvcLogicContext());
+ assertEquals("SUCCESS", mg.getParams().get("REBOOT_STATUS"));
+ }
+
+ private String getURL() {
+ Properties props = ConfigurationFactory.getConfiguration().getProperties();
+ return String.format("http://%s:%s/v2/%s/servers/%s", props.getProperty("test.ip"), props.getProperty("test.port"),
+ "3b3d77e0-a79d-4c10-bfac-1b3914af1a14", "3b3d77e0-a79d-4c10-bfac-1b3914af1a14");
+ }
+
+ class SubclassRebootServer extends RebootServer {
+ @Override
+ public Context getContext(RequestContext rc, String selfLinkURL, String providerName) {
+ return super.getContext(rc, selfLinkURL, providerName);
+ }
+ @Override
+ public Server lookupServer(RequestContext rc, Context context, String id) throws ZoneException, RequestFailedException {
+ return super.lookupServer(rc, context, id);
+ }
+ }
}