From 8d022947d617b48430deca896bd78bab9fe33e7b Mon Sep 17 00:00:00 2001
From: Alok Joshi <ajoshi19@slb.com>
Date: Thu, 7 Jan 2021 18:11:39 -0600
Subject: [PATCH] revert to original change

---
 .../service/CachedPartitionServiceImpl.java   |  4 ++--
 .../CachedPartitionServiceImplTest.java       | 20 ++++++-------------
 2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/partition-core/src/main/java/org/opengroup/osdu/partition/service/CachedPartitionServiceImpl.java b/partition-core/src/main/java/org/opengroup/osdu/partition/service/CachedPartitionServiceImpl.java
index 0591dba13..d5a897da4 100644
--- a/partition-core/src/main/java/org/opengroup/osdu/partition/service/CachedPartitionServiceImpl.java
+++ b/partition-core/src/main/java/org/opengroup/osdu/partition/service/CachedPartitionServiceImpl.java
@@ -50,7 +50,7 @@ public class CachedPartitionServiceImpl implements IPartitionService {
 
         if (pi != null) {
             partitionServiceCache.put(partitionId, partitionInfo);
-            partitionListCache.get(PARTITION_LIST_KEY).add(partitionId);
+            partitionListCache.clearAll();
         }
 
         return pi;
@@ -87,7 +87,7 @@ public class CachedPartitionServiceImpl implements IPartitionService {
         if (partitionService.deletePartition(partitionId)) {
             if (partitionServiceCache.get(partitionId) != null) {
                 partitionServiceCache.delete(partitionId);
-                partitionListCache.get(PARTITION_LIST_KEY).remove(partitionId);
+                partitionListCache.clearAll();
             }
 
             return true;
diff --git a/partition-core/src/test/java/org/opengroup/osdu/partition/service/CachedPartitionServiceImplTest.java b/partition-core/src/test/java/org/opengroup/osdu/partition/service/CachedPartitionServiceImplTest.java
index 46601bc6c..7d2680573 100644
--- a/partition-core/src/test/java/org/opengroup/osdu/partition/service/CachedPartitionServiceImplTest.java
+++ b/partition-core/src/test/java/org/opengroup/osdu/partition/service/CachedPartitionServiceImplTest.java
@@ -44,25 +44,19 @@ public class CachedPartitionServiceImplTest {
     @InjectMocks
     private CachedPartitionServiceImpl cachedPartitionServiceImpl;
 
-    private static final String PARTITION_LIST_KEY = "getAllPartitions";
-
     @Test
     public void createPartitionSucceed() {
         String partId = "key";
 
-        List<String> partitions = new ArrayList<>();
-
         PartitionInfo newPi = PartitionInfo.builder().build();
         PartitionInfo retPi = PartitionInfo.builder().build();
 
         when(partitionServiceImpl.createPartition(partId, newPi)).thenReturn(retPi);
-        when(partitionListCache.get(PARTITION_LIST_KEY)).thenReturn(partitions);
-
         cachedPartitionServiceImpl.createPartition(partId, newPi);
 
         verify(partitionServiceImpl, times(1)).createPartition(partId, newPi);
         verify(partitionServiceCache, times(1)).put(partId, retPi);
-        verify(partitionListCache, times(1)).get(PARTITION_LIST_KEY);
+        verify(partitionListCache, times(1)).clearAll();
     }
 
     @Test
@@ -77,7 +71,7 @@ public class CachedPartitionServiceImplTest {
 
         verify(partitionServiceImpl, times(1)).createPartition(partId, newPi);
         verify(partitionServiceCache, times(0)).put(any(), any());
-        verify(partitionListCache, times(0)).get(PARTITION_LIST_KEY);
+        verify(partitionListCache, times(0)).clearAll();
         verify(partitionServiceCache, times(1)).get(any());
     }
 
@@ -130,18 +124,15 @@ public class CachedPartitionServiceImplTest {
         String partId = "key";
         PartitionInfo retPi = PartitionInfo.builder().build();
 
-        List<String> partitions = new ArrayList<>();
-
         when(partitionServiceImpl.deletePartition(partId)).thenReturn(true);
         when(partitionServiceCache.get(partId)).thenReturn(retPi);
-        when(partitionListCache.get(PARTITION_LIST_KEY)).thenReturn(partitions);
 
         cachedPartitionServiceImpl.deletePartition(partId);
 
         verify(partitionServiceImpl, times(1)).deletePartition(partId);
         verify(partitionServiceCache, times(1)).delete(partId);
         verify(partitionServiceCache, times(1)).get(partId);
-        verify(partitionListCache, times(1)).get(PARTITION_LIST_KEY);
+        verify(partitionListCache, times(1)).clearAll();
     }
 
     @Test
@@ -150,9 +141,10 @@ public class CachedPartitionServiceImplTest {
 
         when(partitionServiceImpl.getAllPartitions()).thenReturn(partitions);
         cachedPartitionServiceImpl.getAllPartitions();
-        verify(partitionListCache, times(1)).get(PARTITION_LIST_KEY);
+        String partKey = "getAllPartitions";
+        verify(partitionListCache, times(1)).get(partKey);
         verify(partitionServiceImpl, times(1)).getAllPartitions();
-        verify(partitionListCache, times(1)).put(PARTITION_LIST_KEY, partitions);
+        verify(partitionListCache, times(1)).put(partKey, partitions);
     }
 
 }
\ No newline at end of file
-- 
GitLab