sheetalshah1007 commented on code in PR #304:
URL: https://github.com/apache/atlas/pull/304#discussion_r1998088654


##########
repository/src/test/java/org/apache/atlas/glossary/GlossaryServiceTest.java:
##########
@@ -1270,6 +1300,90 @@ public void testIncorrectFileException() {
         }
     }
 
+    @DataProvider(name = "getAllGlossaryForPaginationDataProvider")
+    public Object[][] getAllGlossaryForPaginationDataProvider() {
+
+        List<String> listAllGuids = Arrays.asList("guid-1", "guid-2", 
"guid-3", "guid-4", "guid-5",
+                "guid-6", "guid-7", "guid-8", "guid-9", "guid-10");
+
+        return new Object[][] {
+                // limit, offset, sortOrder, expected glossaries guids, 
skipped glossaries, Number of pages required to fetch expected glossaries
+                {-1, 0, SortOrder.ASCENDING, 10, listAllGuids, null, 1},
+                {15, 0, SortOrder.ASCENDING, 10, listAllGuids, null, 1},
+                {10, 0, SortOrder.ASCENDING, 10, listAllGuids, null, 1},
+                {10, 2, SortOrder.ASCENDING, 8, listAllGuids, null, 1},
+                {10, 6, SortOrder.ASCENDING, 4, listAllGuids, null, 1},
+                {5, 0, SortOrder.ASCENDING, 5, listAllGuids, null, 1},
+                {5, 5, SortOrder.ASCENDING, 5, listAllGuids, null, 1},
+                {5, 2, SortOrder.ASCENDING, 5, listAllGuids, null, 1},
+                {10, 0, SortOrder.ASCENDING, 9, listAllGuids, 
Collections.singletonList("guid-3"), 1},
+                {5, 2, SortOrder.ASCENDING, 5, listAllGuids, 
Arrays.asList("guid-3", "guid-7"), 2}
+        };
+    }
+
+    @Test(dataProvider = "getAllGlossaryForPaginationDataProvider")
+    void testGetGlossaries_WithPaginationHandlingSkippedGlossaries(int limit, 
int offset, SortOrder sortOrder, int expectedSize,
+            List<String> allGlossaryGuids, List<String> guidsToSkip, int 
expectedPageCount) throws Exception {
+
+        mockedEntityStore = mock(AtlasEntityStore.class);
+        
when(mockedDataAccess.getAtlasEntityStore()).thenReturn(mockedEntityStore);
+
+        List<String> finalGuidsToSkip = (guidsToSkip == null) ? 
Collections.emptyList() : guidsToSkip;
+
+        List<String> guidsToReturn = new ArrayList<>(allGlossaryGuids);
+        guidsToReturn.removeAll(finalGuidsToSkip);
+
+        try (MockedStatic<AtlasGraphUtilsV2> mockedGraphUtilsClass = 
Mockito.mockStatic(AtlasGraphUtilsV2.class)) {
+
+            // Mocking the retrieval of glossary GUIDs from the system
+            mockedGraphUtilsClass.when(() -> 
AtlasGraphUtilsV2.findEntityGUIDsByType(anyString(), any()))
+                    .thenReturn(allGlossaryGuids);
+
+            // Create a list of AtlasEntity and AtlasGlossary objects
+            for (String guid : guidsToReturn) {

Review Comment:
   removed this block; glossaryDTO is mocked while mocking getByIds() 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@atlas.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to