summaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-02-22 12:44:39 +0000
committerGerrit Code Review <gerrit@onap.org>2021-02-22 12:44:39 +0000
commit80a4d78e798bee6379961008c2d49b7fae5f2924 (patch)
treeb43f502f5afec734e3b6c678218670ac53baf5e2 /main/src
parentde818b6638b3fe537017fd103c0b9997b707dce0 (diff)
parente3771883bafbf8a3848f47cd2e02c9f7ffc6030a (diff)
Merge "Refactor Pap code to use Instant from Date"
Diffstat (limited to 'main/src')
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/StatisticsRestProvider.java8
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java5
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/e2e/StatisticsTest.java6
3 files changed, 10 insertions, 9 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/StatisticsRestProvider.java b/main/src/main/java/org/onap/policy/pap/main/rest/StatisticsRestProvider.java
index 9a283391..512dbe76 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/StatisticsRestProvider.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/StatisticsRestProvider.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
+ * Copyright (C) 2020-2021 Nordix Foundation.
* Modifications Copyright (C) 2019 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,8 +21,8 @@
package org.onap.policy.pap.main.rest;
+import java.time.Instant;
import java.util.ArrayList;
-import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -86,8 +86,8 @@ public class StatisticsRestProvider {
Registry.get(PapConstants.REG_PAP_DAO_FACTORY, PolicyModelsProviderFactoryWrapper.class);
Map<String, Map<String, List<PdpStatistics>>> pdpStatisticsMap;
try (PolicyModelsProvider databaseProvider = modelProviderWrapper.create()) {
- Date startTime = null;
- Date endTime = null;
+ Instant startTime = null;
+ Instant endTime = null;
if (groupName == null) {
pdpStatisticsMap = generatePdpStatistics(databaseProvider.getPdpStatistics(pdpName, startTime));
diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
index 1fdbfe65..01edbdcf 100644
--- a/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertEquals;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.time.Instant;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@@ -57,7 +58,7 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
private static final CommInfrastructure INFRA = CommInfrastructure.NOOP;
private static final String TOPIC = "my-topic";
- private Date timeStamp;
+ private Instant timeStamp;
private PdpHeartbeatListener pdpHeartbeatListener;
@Test
@@ -207,7 +208,7 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
public void testPdpStatistics() throws CoderException, PfModelException, ParseException {
addGroups("PdpGroups.json");
pdpHeartbeatListener = new PdpHeartbeatListener(new PdpParameters());
- timeStamp = new SimpleDateFormat("yyyy-MM-dd").parse("2020-01-01");
+ timeStamp = Instant.parse("2021-02-12T17:48:01.029211400Z");
// init default pdp group
final PdpStatus status1 = new PdpStatus();
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/StatisticsTest.java b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/StatisticsTest.java
index 75aafba6..2f6cc3a1 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/StatisticsTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/StatisticsTest.java
@@ -3,7 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,8 +24,8 @@ package org.onap.policy.pap.main.rest.e2e;
import static org.junit.Assert.assertEquals;
import java.net.HttpURLConnection;
+import java.time.Instant;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.ws.rs.client.Invocation;
@@ -117,7 +117,7 @@ public class StatisticsTest extends End2EndBase {
pdpStatisticsRecord.setPdpGroupName("defaultGroup");
pdpStatisticsRecord.setPdpSubGroupName("apex");
pdpStatisticsRecord.setPdpInstanceId("pdp1");
- pdpStatisticsRecord.setTimeStamp(new Date());
+ pdpStatisticsRecord.setTimeStamp(Instant.now());
pdpStatisticsRecord.setPolicyDeployCount(1);
pdpStatisticsRecord.setPolicyDeployFailCount(0);
pdpStatisticsRecord.setPolicyDeploySuccessCount(1);