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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to