@@ -68,55 +68,55 @@ public static void setup() {
6868 @ Test
6969 public void testGetInventoryTopBucketNoDelimiterAws () throws URISyntaxException {
7070 CdmS3Uri uri = new CdmS3Uri (S3TestsCommon .TOP_LEVEL_AWS_BUCKET );
71- checkInventoryTopCount (uri , LIMIT_COUNT_MAX );
71+ checkInventoryTopCountExact (uri , LIMIT_COUNT_MAX );
7272 }
7373
7474 @ Test
7575 public void testGetInventoryTopBucketNoDelimiterGcs () throws URISyntaxException {
7676 CdmS3Uri uri = new CdmS3Uri (S3TestsCommon .TOP_LEVEL_GCS_BUCKET );
77- checkInventoryTopCount (uri , LIMIT_COUNT_MAX );
77+ checkInventoryTopCountExact (uri , LIMIT_COUNT_MAX );
7878 }
7979
8080 @ Test
8181 public void testGetInventoryTopBucketGcsNoDelimiterOsdc () throws URISyntaxException {
8282 CdmS3Uri uri = new CdmS3Uri (S3TestsCommon .TOP_LEVEL_OSDC_BUCKET );
83- checkInventoryTopCount (uri , LIMIT_COUNT_MAX );
83+ checkInventoryTopCountExact (uri , LIMIT_COUNT_MAX );
8484 }
8585
8686 @ Test
8787 public void testGetInventoryTopBucketDelimiterAws () throws URISyntaxException {
8888 CdmS3Uri uri = new CdmS3Uri (S3TestsCommon .TOP_LEVEL_AWS_BUCKET + DELIMITER_FRAGMENT );
8989 // contains a single object at "/" (/index.html)
90- checkInventoryTopCount (uri , 1 );
90+ checkInventoryTopCountAtMost (uri , 3 );
9191 }
9292
9393 @ Test
9494 public void testGetInventoryTopBucketDelimiterGcs () throws URISyntaxException {
9595 CdmS3Uri uri = new CdmS3Uri (S3TestsCommon .TOP_LEVEL_GCS_BUCKET + DELIMITER_FRAGMENT );
9696 // does not contain anything at "/"
97- checkInventoryTopCount (uri , 0 );
97+ checkInventoryTopCountExact (uri , 0 );
9898 }
9999
100100 @ Test
101101 public void testGetInventoryTopBucketDelimiterOsdc () throws URISyntaxException {
102102 CdmS3Uri uri = new CdmS3Uri (S3TestsCommon .TOP_LEVEL_OSDC_BUCKET + DELIMITER_FRAGMENT );
103103 // does not contain anything at "/"
104- checkInventoryTopCount (uri , 0 );
104+ checkInventoryTopCountExact (uri , 0 );
105105 }
106106
107107 @ Test
108108 public void testGetInventoryTopBucketAndPrefixSingleMatchAws () throws URISyntaxException {
109109 for (String delimiter : DELIMITER_FRAGMENTS ) {
110110 CdmS3Uri uri = new CdmS3Uri (S3TestsCommon .TOP_LEVEL_AWS_BUCKET + "?" + G16_KEY_PREFIX_SINGLE_MATCH + delimiter );
111- checkInventoryTopCount (uri , 1 );
111+ checkInventoryTopCountExact (uri , 1 );
112112 }
113113 }
114114
115115 @ Test
116116 public void testGetInventoryTopBucketAndPrefixSingleMatchGcs () throws URISyntaxException {
117117 for (String delimiter : DELIMITER_FRAGMENTS ) {
118118 CdmS3Uri uri = new CdmS3Uri (S3TestsCommon .TOP_LEVEL_GCS_BUCKET + "?" + G16_KEY_PREFIX_SINGLE_MATCH + delimiter );
119- checkInventoryTopCount (uri , 1 );
119+ checkInventoryTopCountExact (uri , 1 );
120120 }
121121 }
122122
@@ -125,7 +125,7 @@ public void testGetInventoryTopBucketAndPrefixSingleMatchOsdc() throws URISyntax
125125 for (String delimiter : DELIMITER_FRAGMENTS ) {
126126 CdmS3Uri uri =
127127 new CdmS3Uri (S3TestsCommon .TOP_LEVEL_OSDC_BUCKET + "?" + getOsdcKey (G16_KEY_PREFIX_SINGLE_MATCH ) + delimiter );
128- checkInventoryTopCount (uri , 1 );
128+ checkInventoryTopCountExact (uri , 1 );
129129 }
130130 }
131131
@@ -134,7 +134,7 @@ public void testGetInventoryTopBucketAndPrefixMultiMatchAws() throws URISyntaxEx
134134 for (String delimiter : DELIMITER_FRAGMENTS ) {
135135 CdmS3Uri uri =
136136 new CdmS3Uri (S3TestsCommon .TOP_LEVEL_AWS_BUCKET + "?" + G16_KEY_PREFIX_SINGLE_DAY_PARTIAL_FILE + delimiter );
137- checkInventoryTopCount (uri , 12 );
137+ checkInventoryTopCountExact (uri , 12 );
138138 }
139139 }
140140
@@ -143,7 +143,7 @@ public void testGetInventoryTopBucketAndPrefixMultiMatchGcs() throws URISyntaxEx
143143 for (String delimiter : DELIMITER_FRAGMENTS ) {
144144 CdmS3Uri uri =
145145 new CdmS3Uri (S3TestsCommon .TOP_LEVEL_GCS_BUCKET + "?" + G16_KEY_PREFIX_SINGLE_DAY_PARTIAL_FILE + delimiter );
146- checkInventoryTopCount (uri , 12 );
146+ checkInventoryTopCountExact (uri , 12 );
147147 }
148148 }
149149
@@ -152,7 +152,7 @@ public void testGetInventoryTopBucketAndPrefixMultiMatchOsdc() throws URISyntaxE
152152 for (String delimiter : DELIMITER_FRAGMENTS ) {
153153 CdmS3Uri uri = new CdmS3Uri (
154154 S3TestsCommon .TOP_LEVEL_OSDC_BUCKET + "?" + getOsdcKey (G16_KEY_PREFIX_SINGLE_DAY_PARTIAL_FILE ) + delimiter );
155- checkInventoryTopCount (uri , 12 );
155+ checkInventoryTopCountExact (uri , 12 );
156156 }
157157 }
158158
@@ -286,12 +286,22 @@ private CollectionConfig getCollectionConfig(CdmS3Uri uri) {
286286 return new CollectionConfig (uri .getBucket (), uri .toString (), true , null , null );
287287 }
288288
289- private void checkInventoryTopCount (CdmS3Uri uri , int expectedCount ) {
289+ private void checkInventoryTopCountExact (CdmS3Uri uri , int expectedCount ) {
290+ int actualCount = topInventoryCount (uri );
291+ assertThat (actualCount ).isEqualTo (expectedCount );
292+ }
293+
294+ private void checkInventoryTopCountAtMost (CdmS3Uri uri , int expectedMaximumCount ) {
295+ int actualCount = topInventoryCount (uri );
296+ assertThat (actualCount ).isAtMost (expectedMaximumCount );
297+ }
298+
299+ private int topInventoryCount (CdmS3Uri uri ) {
290300 logger .debug ("getInventoryTop: {}" , uri );
291301 ControllerS3 controller = new ControllerS3 ();
292302 controller .limit = true ;
293303 Iterator <MFile > it = controller .getInventoryTop (getCollectionConfig (uri ), false );
294- assertThat ( countObjects (it )). isEqualTo ( expectedCount );
304+ return countObjects (it );
295305 }
296306
297307 private void checkInventoryAllCount (CdmS3Uri uri , int expectedCount ) {
@@ -303,7 +313,7 @@ private void checkInventoryAllCount(CdmS3Uri uri, int expectedCount) {
303313 }
304314
305315 private void checkSubdirsCount (CdmS3Uri uri , int expectedCount ) {
306- logger .debug ("getInventoryAll : {}" , uri );
316+ logger .debug ("getSubdirs : {}" , uri );
307317 ControllerS3 controller = new ControllerS3 ();
308318 controller .limit = true ;
309319 Iterator <MFile > it = controller .getSubdirs (getCollectionConfig (uri ), false );
0 commit comments