diff options
author | Gary Wu <gary.i.wu@huawei.com> | 2017-05-08 12:59:44 -0700 |
---|---|---|
committer | Patrick Brady <pb071s@att.com> | 2017-05-16 18:13:41 +0000 |
commit | 753cb638fcb58f355f2c979e9e0a43cba2832984 (patch) | |
tree | 55526dce196663d6c5c4265e504882e3deec2cc2 /appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test | |
parent | f16391cacb2e91063bbe9ad66cb2310855c93695 (diff) |
Migrate to Java 8 Time API
Migrate the uses of the old Date class in CommonHeader,
RuntimeContext, QueueMessage, and TransactionRecord to
Java 8 Time API.
Change-Id: I3b0c18b2e63cdab06e37587d2010cb7f626a0396
Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
Diffstat (limited to 'appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test')
2 files changed, 20 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 9757430d8..7bf9f7c03 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 @@ -54,6 +54,7 @@ import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import java.time.Instant; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -142,28 +143,28 @@ public class TestCommandExecutionTask { @Test public void testOnRequestCompletion(){ Mockito.doNothing().when(requestHandler).onRequestTTLEnd((RuntimeContext) anyObject(),anyBoolean()); - RuntimeContext request = pouplateCommandExecutorInput("FIREWALL", 30, "1.0", new Date(), API_VERSION, "11", ORIGINATOR_ID, "", VNFOperation.Configure, "1", ""); + RuntimeContext request = pouplateCommandExecutorInput("FIREWALL", 30, "1.0", Instant.now(), API_VERSION, "11", ORIGINATOR_ID, "", VNFOperation.Configure, "1", ""); CommandResponse response = getCommandResponse(VNFOperation.Configure, true, "11", "","1"); executionTask.onRequestCompletion(request, response); } @Test public void testRunGetConfig(){ - RuntimeContext request = pouplateCommandExecutorInput("FIREWALL", 30, "1.0", new Date(), API_VERSION, "11", ORIGINATOR_ID, "", VNFOperation.Sync, "1", ""); + RuntimeContext request = pouplateCommandExecutorInput("FIREWALL", 30, "1.0", Instant.now(), API_VERSION, "11", ORIGINATOR_ID, "", VNFOperation.Sync, "1", ""); LCMReadonlyCommandTask.setCommandRequest(request); LCMReadonlyCommandTask.run(); } @Test public void testRun(){ - RuntimeContext request = pouplateCommandExecutorInput("FIREWALL", 30, "1.0", new Date(), API_VERSION, "11", ORIGINATOR_ID, "", VNFOperation.Sync, "1", ""); + RuntimeContext request = pouplateCommandExecutorInput("FIREWALL", 30, "1.0", Instant.now(), API_VERSION, "11", ORIGINATOR_ID, "", VNFOperation.Sync, "1", ""); executionTask.setCommandRequest(request); executionTask.run(); } @Test public void testRunNegative(){ - RuntimeContext request = pouplateCommandExecutorInput("FIREWALL", 30, "1.0", new Date(), API_VERSION, "11", ORIGINATOR_ID, "", VNFOperation.Sync, "1", ""); + RuntimeContext request = pouplateCommandExecutorInput("FIREWALL", 30, "1.0", Instant.now(), API_VERSION, "11", ORIGINATOR_ID, "", VNFOperation.Sync, "1", ""); executionTask.setCommandRequest(request); executionTask.run(); } @@ -191,7 +192,7 @@ public class TestCommandExecutionTask { responseContext.setStatus(new Status(100, null)); commonHeader.setRequestId(responseId); responseContext.setPayload(payload); - commonHeader.setTimestamp(new Date()); + commonHeader.setTimestamp(Instant.now()); vnfContext.setId(vnfId); return commandResponse; } @@ -201,10 +202,9 @@ public class TestCommandExecutionTask { @Test public void testPositiveFlow_configure() { - Date timeStamp = new Date(); String requestId = "1"; - RuntimeContext commandExecutorInput = pouplateCommandExecutorInput("FIREWALL",30, "1.0", timeStamp, API_VERSION, requestId, ORIGINATOR_ID, "", VNFOperation.Configure, "33", ""); + RuntimeContext commandExecutorInput = pouplateCommandExecutorInput("FIREWALL",30, "1.0", Instant.now(), API_VERSION, requestId, ORIGINATOR_ID, "", VNFOperation.Configure, "33", ""); } @@ -226,7 +226,7 @@ public class TestCommandExecutionTask { return wfResponse; } - private RuntimeContext pouplateCommandExecutorInput(String vnfType, int ttl, String vnfVersion, Date timeStamp, String apiVersion, String requestId, String originatorID, String subRequestID, VNFOperation action, String vnfId , String payload){ + private RuntimeContext pouplateCommandExecutorInput(String vnfType, int ttl, String vnfVersion, Instant timeStamp, String apiVersion, String requestId, String originatorID, String subRequestID, VNFOperation action, String vnfId , String payload){ RuntimeContext commandExecutorInput = createCommandExecutorInputWithSubObjects(); RequestContext requestContext = commandExecutorInput.getRequestContext(); ResponseContext responseContext = createResponseContextWithSuObjects(); 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 bb4e39109..7e972b738 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 @@ -25,12 +25,19 @@ package org.openecomp.appc.executor; */ +import java.time.Instant; + import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; -import org.openecomp.appc.domainmodel.lcm.*; -import org.openecomp.appc.domainmodel.lcm.Flags.Mode; +import org.openecomp.appc.domainmodel.lcm.ActionIdentifiers; +import org.openecomp.appc.domainmodel.lcm.CommonHeader; +import org.openecomp.appc.domainmodel.lcm.Flags; +import org.openecomp.appc.domainmodel.lcm.RequestContext; +import org.openecomp.appc.domainmodel.lcm.RuntimeContext; +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; @@ -41,11 +48,6 @@ import org.openecomp.appc.lifecyclemanager.LifecycleManager; import org.openecomp.appc.requesthandler.RequestHandler; import org.openecomp.appc.workflow.WorkFlowManager; -import java.util.Date; -import java.util.concurrent.TimeUnit; - -import static junit.framework.Assert.assertTrue; - @SuppressWarnings("deprecation") public class TestCommandExecutor { @@ -88,9 +90,8 @@ public class TestCommandExecutor { @Test public void testPositiveFlow_LCM(){ //Map <String,Object> flags = setTTLInFlags("30"); - Date timeStamp = new Date(); String requestId = "1"; - RuntimeContext commandExecutorInput = pouplateCommandExecutorInput("FIREWALL", 30, "1.0", timeStamp, API_VERSION, requestId, ORIGINATOR_ID, "2", VNFOperation.Configure, "15", "") ; + RuntimeContext commandExecutorInput = pouplateCommandExecutorInput("FIREWALL", 30, "1.0", Instant.now(), API_VERSION, requestId, ORIGINATOR_ID, "2", VNFOperation.Configure, "15", "") ; try { commandExecutor.executeCommand(commandExecutorInput); } catch (APPCException e) { @@ -101,10 +102,9 @@ public class TestCommandExecutor { @Test public void testPositiveFlow_GetConfig(){ - Date timeStamp = new Date(); String requestId = "1"; - RuntimeContext commandExecutorInput = pouplateCommandExecutorInput("FIREWALL", 30, "1.0", timeStamp, API_VERSION, requestId, ORIGINATOR_ID, "2", VNFOperation.Sync,"15","") ; + RuntimeContext commandExecutorInput = pouplateCommandExecutorInput("FIREWALL", 30, "1.0", Instant.now(), API_VERSION, requestId, ORIGINATOR_ID, "2", VNFOperation.Sync,"15","") ; try { commandExecutor.executeCommand(commandExecutorInput); } catch (APPCException e) { @@ -114,7 +114,7 @@ public class TestCommandExecutor { } - private RuntimeContext pouplateCommandExecutorInput(String vnfType, int ttl, String vnfVersion, Date timeStamp, String apiVersion, String requestId, String originatorID, String subRequestID, VNFOperation action, String vnfId , String payload){ + private RuntimeContext pouplateCommandExecutorInput(String vnfType, int ttl, String vnfVersion, Instant timeStamp, String apiVersion, String requestId, String originatorID, String subRequestID, VNFOperation action, String vnfId , String payload){ RuntimeContext commandExecutorInput = createCommandExecutorInputWithSubObjects(); RequestContext requestContext = commandExecutorInput.getRequestContext(); requestContext.getCommonHeader().setFlags(new Flags(null, false, ttl)); |