aboutsummaryrefslogtreecommitdiffstats
path: root/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test
diff options
context:
space:
mode:
authorPatrick Brady <pb071s@att.com>2017-07-28 11:29:23 -0700
committerPatrick Brady <pb071s@att.com>2017-08-02 15:43:44 +0000
commit38713207b817ed4700f630748c681116338d32f0 (patch)
tree9eb2097cee8d85ac14f17e3a280ae8aefb69d9de /appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test
parent771ac55e29d099d8bbf783612de975047d75ab12 (diff)
Merging in bug fixes
Change-Id: I85da90b9ba0d03149f42035a820c76ef0285e413 Signed-off-by: Patrick Brady <pb071s@att.com> Issue: APPC-100
Diffstat (limited to 'appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test')
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/java/org/openecomp/appc/executor/TestCommandExecutionTask.java30
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/java/org/openecomp/appc/executor/TestCommandExecutor.java43
2 files changed, 53 insertions, 20 deletions
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/java/org/openecomp/appc/executor/TestCommandExecutionTask.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/java/org/openecomp/appc/executor/TestCommandExecutionTask.java
index ee28fa844..460f0e7ad 100644
--- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/java/org/openecomp/appc/executor/TestCommandExecutionTask.java
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/java/org/openecomp/appc/executor/TestCommandExecutionTask.java
@@ -123,16 +123,23 @@ public class TestCommandExecutionTask {
factory = new CommandTaskFactory();
factory.setLifecyclemanager(lifecyclemanager);
factory.setWorkflowManager(workflowManager);
- factory.setRequestHandler(requestHandler);
+ factory.setVnfRequestHandler(requestHandler);
Mockito.when(workflowManager.executeWorkflow((WorkflowRequest)anyObject())).thenReturn(getWorkflowResponse () );
}
@Test
public void testFactory(){
- CommandTask task = factory.getExecutionTask("Configure", null);
+ CommandTask task;
+ Instant timeStamp = Instant.now();
+ String requestId = "1";
+ RuntimeContext commandExecutorInputConfigure = pouplateCommandExecutorInput("FIREWALL", 30, "1.0",
+ timeStamp, API_VERSION, requestId, ORIGINATOR_ID, "2", VNFOperation.Configure,"15","") ;
+ task = factory.getExecutionTask(commandExecutorInputConfigure);
assertEquals(LCMCommandTask.class,task.getClass() );
- task = factory.getExecutionTask("Sync", null);
+ RuntimeContext commandExecutorInputSync = pouplateCommandExecutorInput("FIREWALL", 30, "1.0",
+ timeStamp, API_VERSION, requestId, ORIGINATOR_ID, "2", VNFOperation.Sync,"15","") ;
+ task = factory.getExecutionTask(commandExecutorInputSync);
assertEquals(LCMReadonlyCommandTask.class,task.getClass() );
}
@@ -215,6 +222,22 @@ public class TestCommandExecutionTask {
}
+ private RuntimeContext getConfigCommandRequest(String vnfType , Integer ttl , Instant timeStamp, String requestId,
+ Map<String,Object> flags, VNFOperation command , String vnfId, String vnfVersion ){
+
+ RuntimeContext commandExecutorInput = pouplateCommandExecutorInput(vnfType, ttl, vnfVersion, timeStamp, API_VERSION, requestId, ORIGINATOR_ID, "", command, vnfId, "");
+
+ return commandExecutorInput;
+ }
+
+ private RuntimeContext getLCMCommandRequest(String vnfType , Integer ttl ,Instant timeStamp, String requestId,
+ Map<String,Object> flags, VNFOperation command , String vnfId, String vnfVersion ){
+
+ RuntimeContext commandExecutorInput = pouplateCommandExecutorInput(vnfType, ttl, vnfVersion, timeStamp, API_VERSION, requestId, ORIGINATOR_ID, "", command, vnfId, "");
+
+ return commandExecutorInput;
+ }
+
public WorkflowResponse getWorkflowResponse (){
WorkflowResponse wfResponse = new WorkflowResponse();
ResponseContext responseContext = createResponseContextWithSuObjects();
@@ -275,4 +298,3 @@ public class TestCommandExecutionTask {
}
}
-
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/java/org/openecomp/appc/executor/TestCommandExecutor.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/java/org/openecomp/appc/executor/TestCommandExecutor.java
index 30b731782..fa9257faa 100644
--- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/java/org/openecomp/appc/executor/TestCommandExecutor.java
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/java/org/openecomp/appc/executor/TestCommandExecutor.java
@@ -24,7 +24,7 @@
package org.openecomp.appc.executor;
/**
- *
+ *
*/
@@ -43,31 +43,41 @@ import org.openecomp.appc.domainmodel.lcm.VNFContext;
import org.openecomp.appc.domainmodel.lcm.VNFOperation;
import org.openecomp.appc.exceptions.APPCException;
import org.openecomp.appc.executionqueue.ExecutionQueueService;
-import org.openecomp.appc.executor.impl.CommandExecutorImpl;
-import org.openecomp.appc.executor.impl.CommandTaskFactory;
-import org.openecomp.appc.executor.impl.LCMCommandTask;
-import org.openecomp.appc.executor.impl.LCMReadonlyCommandTask;
+import org.openecomp.appc.executor.impl.*;
import org.openecomp.appc.lifecyclemanager.LifecycleManager;
import org.openecomp.appc.requesthandler.RequestHandler;
import org.openecomp.appc.workflow.WorkFlowManager;
+import org.powermock.api.mockito.PowerMockito;
+
+import java.util.Date;
+import java.util.concurrent.TimeUnit;
+
+import static junit.framework.Assert.assertTrue;
+import static org.powermock.api.support.membermodification.MemberMatcher.method;
@SuppressWarnings("deprecation")
public class TestCommandExecutor {
- private static final String TTL_FLAG= "TTL";
- private static final String API_VERSION= "2.0.0";
- private static final String ORIGINATOR_ID= "1";
+ private static final String TTL_FLAG= "TTL";
+ private static final String API_VERSION= "2.0.0";
+ private static final String ORIGINATOR_ID= "1";
- CommandExecutorImpl commandExecutor;
+ private CommandExecutorImpl commandExecutor;
- CommandTaskFactory executionTaskFactory;
+ private CommandTaskFactory executionTaskFactory;
private RequestHandler requestHandler;
private WorkFlowManager workflowManager;
private LifecycleManager lifecyclemanager;
private ExecutionQueueService executionQueueService;
+ private Instant timeStamp = Instant.now();
+ private String requestId = "1";
+ private RuntimeContext commandExecutorInputConfigure = pouplateCommandExecutorInput("FIREWALL", 30000, "1.0",
+ timeStamp, API_VERSION, requestId, ORIGINATOR_ID, "2", VNFOperation.Configure,"15","") ;
+ private RuntimeContext commandExecutorInputSync = pouplateCommandExecutorInput("FIREWALL", 30, "1.0",
+ timeStamp, API_VERSION, requestId, ORIGINATOR_ID, "2", VNFOperation.Sync,"15","") ;
@Before
public void init()throws Exception {
@@ -82,16 +92,18 @@ public class TestCommandExecutor {
commandExecutor.setExecutionTaskFactory(executionTaskFactory);
commandExecutor.setExecutionQueueService(executionQueueService);
LCMCommandTask lcmCommandTask = Mockito.mock(LCMCommandTask.class);
- LCMReadonlyCommandTask LCMReadonlyCommandTask = Mockito.mock(LCMReadonlyCommandTask.class);
- Mockito.doReturn(lcmCommandTask).when(executionTaskFactory).getExecutionTask("Configure", null);
- Mockito.doReturn(LCMReadonlyCommandTask).when(executionTaskFactory).getExecutionTask("Sync", null);
+ LCMReadonlyCommandTask lCMReadonlyCommandTask = Mockito.mock(LCMReadonlyCommandTask.class);
+
+ Mockito.when(executionTaskFactory.getExecutionTask(commandExecutorInputConfigure)).thenReturn(lcmCommandTask);
+ Mockito.when(executionTaskFactory.getExecutionTask(commandExecutorInputSync)).thenReturn(lCMReadonlyCommandTask);
+
// Mockito.when(executionQueueService.putMessage((Runnable) Mockito.anyObject(),Mockito.anyLong(),(TimeUnit)Mockito.anyObject())).thenReturn(true);
}
-
+
@Test
- public void testPositiveFlow_LCM(){
+ public void testPositiveFlow_LCM() throws Exception {
//Map <String,Object> flags = setTTLInFlags("30");
String requestId = "1";
RuntimeContext commandExecutorInput = pouplateCommandExecutorInput("FIREWALL", 30, "1.0", Instant.now(), API_VERSION, requestId, ORIGINATOR_ID, "2", VNFOperation.Configure, "15", "") ;
@@ -153,4 +165,3 @@ public class TestCommandExecutor {
}
-