diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/contexts/ContextManagementTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/contexts/ContextManagementTest.java index 2b7f260..5748ea7 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/contexts/ContextManagementTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/contexts/ContextManagementTest.java @@ -548,8 +548,12 @@ public class ContextManagementTest extends ContextTest { @Test public void testLimitOffset() throws Exception { int limit = 2; + int offset = limit * 0; + + List contexts = getAll(offset, limit); + + logger.info("Going to check {}s pagination validity", Context.NAME); - List contexts = getAll(0, limit); if(contexts.size()==0) { return; } @@ -563,10 +567,11 @@ public class ContextManagementTest extends ContextTest { for(Context context : contexts) { UUID uuid = context.getID(); uuids.add(uuid); - logger.info("Found {} with UUID {} and name {}", Context.NAME, uuid, context.getName()); + logger.info("Using getAll({}, {}) found {} with UUID {} and name {}", offset, limit, Context.NAME, uuid, context.getName()); } - contexts = getAll(limit, limit); + offset = limit * 1; + contexts = getAll(offset, limit); if(contexts.size()>0) { Assert.assertTrue(contexts.size() <= limit); @@ -575,7 +580,7 @@ public class ContextManagementTest extends ContextTest { UUID uuid = context.getID(); Assert.assertFalse(uuids.contains(uuid)); uuids.add(uuid); - logger.info("Found {} with UUID {} and name {}", Context.NAME, uuid, context.getName()); + logger.info("Using getAll({}, {}) found {} with UUID {} and name {}", offset, limit, Context.NAME, uuid, context.getName()); } if(contexts.size()=uuids.size()); + List all = getAll(); - for(Context context : contexts) { - UUID uuid = context.getID(); - logger.info("No limit listing: Got {} with UUID {} and name {}", Context.NAME, uuid, context.getName()); + uuids = new HashSet<>(); + + int i = -1; + + while(true) { + offset = ++i * limit; + contexts = getAll(offset, limit); + for(Context context : contexts) { + UUID uuid = context.getID(); + logger.info("Using getAll({}, {}) found {} with UUID {} and name {}", offset, limit, Context.NAME, uuid, context.getName()); + uuids.add(uuid); + } + if(contexts.size()=uuids.size()); + + for(Context context : all) { + UUID uuid = context.getID(); + Assert.assertTrue(uuids.contains(uuid)); + logger.info("Using getAll() found {} with UUID {} and name {}", Context.NAME, uuid, context.getName()); + + } + + logger.info("{} pagination seems properly working", Context.NAME); } }