You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "mladjan-gadzic (via GitHub)" <gi...@apache.org> on 2023/02/06 11:25:24 UTC

[GitHub] [ozone] mladjan-gadzic commented on a diff in pull request #4186: HDDS-7594. [FSO] Folders created through S3G are created on file system as "files".

mladjan-gadzic commented on code in PR #4186:
URL: https://github.com/apache/ozone/pull/4186#discussion_r1097256720


##########
hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestObjectPut.java:
##########
@@ -288,4 +298,82 @@ public void testEmptyStorageType() throws IOException, OS3Exception {
     //default type is set
     Assert.assertEquals(ReplicationType.RATIS, key.getReplicationType());
   }
+
+  @Test
+  public void testDirectoryCreation() throws IOException,
+      OS3Exception {
+    // GIVEN
+    final String bucketname = "bucketName";
+    final String path = "dir";
+    final long length = 0L;
+    final int partNumber = 0;
+    final String uploadId = "";
+    final InputStream body = null;
+    final HttpHeaders headers = Mockito.mock(HttpHeaders.class);
+    final ObjectEndpoint objEndpoint = new ObjectEndpoint();
+    objEndpoint.setOzoneConfiguration(new OzoneConfiguration());
+    objEndpoint.setHeaders(headers);
+    final OzoneClient client = Mockito.mock(OzoneClient.class);
+    objEndpoint.setClient(client);
+    final ObjectStore objectStore = Mockito.mock(ObjectStore.class);
+    final OzoneVolume volume = Mockito.mock(OzoneVolume.class);
+    final OzoneBucket bucket = Mockito.mock(OzoneBucket.class);
+    final ClientProtocol protocol = Mockito.mock(ClientProtocol.class);
+
+    // WHEN
+    when(headers.getHeaderString(any())).thenReturn("");
+    when(client.getObjectStore()).thenReturn(objectStore);
+    when(client.getObjectStore().getS3Volume()).thenReturn(volume);
+    when(volume.getBucket(bucketname)).thenReturn(bucket);
+    when(bucket.getBucketLayout())
+        .thenReturn(BucketLayout.FILE_SYSTEM_OPTIMIZED);
+    when(client.getProxy()).thenReturn(protocol);
+    final Response response = objEndpoint.put(bucketname, path, length,
+        partNumber, uploadId, body);
+
+    // THEN
+    Assertions.assertEquals(HttpStatus.SC_OK, response.getStatus());
+    Mockito.verify(protocol).createDirectory(any(), any(), any());

Review Comment:
   `verify(mock).someMethod("some arg");` is equivalent to `verify(mock, times(1)).someMethod("some arg");` according to Mockito docs.



-- 
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: issues-unsubscribe@ozone.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org