From 5aaf7f76c6632dcd4bea56b227648482ddde3a50 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Tue, 23 Oct 2018 12:02:27 -0400 Subject: Bug fixes October 23rd fixed the db status not being updated on delete SI added a default sequence flow to isAsync_Gateway Removed @Before and organized imports Added check to prevent db query with only requestStatus correct AAIObjectPlurals enum value name Correct rollbackData setting and protect against null Change-Id: Ic7c47dc968a29987c3d576da9aa50c7ddc8f28ee Issue-ID: SO-1162 Signed-off-by: Benjamin, Max (mb388a) --- .../InfraActiveRequestsRepositoryImpl.java | 20 ++++++++++---------- .../InfraActiveRequestsRepositoryImplTest.java | 9 +++++++++ 2 files changed, 19 insertions(+), 10 deletions(-) (limited to 'mso-api-handlers/mso-requests-db-repositories') diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java index d66e378146..951f02e5d8 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java +++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java @@ -172,6 +172,7 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); final CriteriaQuery crit = cb.createQuery(InfraActiveRequests.class); final Root tableRoot = crit.from(InfraActiveRequests.class); + InfraActiveRequests infraActiveRequests = null; if (instanceName != null && !instanceName.equals("")) { @@ -229,18 +230,17 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep } } } - - predicates.add(tableRoot.get(REQUEST_STATUS) + if(!predicates.isEmpty()){ + predicates.add(tableRoot.get(REQUEST_STATUS) .in(Arrays.asList("PENDING", "IN_PROGRESS", "TIMEOUT", "PENDING_MANUAL_TASK"))); - final Order order = cb.desc(tableRoot.get(START_TIME)); - - final List dupList = executeInfraQuery(crit, predicates, order); - - InfraActiveRequests infraActiveRequests = null; - - if (dupList != null && !dupList.isEmpty()) { - infraActiveRequests = dupList.get(0); + final Order order = cb.desc(tableRoot.get(START_TIME)); + + final List dupList = executeInfraQuery(crit, predicates, order); + + if (dupList != null && !dupList.isEmpty()) { + infraActiveRequests = dupList.get(0); + } } return infraActiveRequests; diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java index b7eb7642a2..4097aee7d5 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java +++ b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java @@ -22,6 +22,7 @@ package org.onap.so.db.request.data.repository; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.onap.so.db.request.data.repository.InfraActiveRequestsRepositoryImpl.ACTION; import static org.onap.so.db.request.data.repository.InfraActiveRequestsRepositoryImpl.REQUEST_ID; @@ -181,4 +182,12 @@ public class InfraActiveRequestsRepositoryImplTest { objUnderTest.getInfraActiveRequests(null, START_TIME_IN_MILISEC, END_TIME_IN_MILISEC, MAX_LIMIT); assertTrue(actualRequests.isEmpty()); } + + @Test + public void checkInstanceNameDuplicateNullInstanceNameTest(){ + Map instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", "e05864f0-ab35-47d0-8be4-56fd9619ba3b"); + InfraActiveRequests results = objUnderTest.checkInstanceNameDuplicate((HashMap)instanceIdMap, null, "vnf"); + assertNull(results); + } } -- cgit 1.2.3-korg