diff options
Diffstat (limited to 'common-be/src/test/java/org/openecomp/sdc/be/csar/storage/MinIoStorageArtifactStorageManagerTest.java')
-rw-r--r-- | common-be/src/test/java/org/openecomp/sdc/be/csar/storage/MinIoStorageArtifactStorageManagerTest.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/common-be/src/test/java/org/openecomp/sdc/be/csar/storage/MinIoStorageArtifactStorageManagerTest.java b/common-be/src/test/java/org/openecomp/sdc/be/csar/storage/MinIoStorageArtifactStorageManagerTest.java index 4d12a0be39..d6a52c5bda 100644 --- a/common-be/src/test/java/org/openecomp/sdc/be/csar/storage/MinIoStorageArtifactStorageManagerTest.java +++ b/common-be/src/test/java/org/openecomp/sdc/be/csar/storage/MinIoStorageArtifactStorageManagerTest.java @@ -35,9 +35,11 @@ import io.minio.GetObjectArgs; import io.minio.GetObjectResponse; import io.minio.MakeBucketArgs; import io.minio.MinioClient; +import io.minio.PutObjectArgs; import io.minio.RemoveBucketArgs; import io.minio.RemoveObjectArgs; import io.minio.StatObjectArgs; +import java.io.ByteArrayInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; @@ -142,6 +144,14 @@ class MinIoStorageArtifactStorageManagerTest { } @Test + void testPutFail() throws Exception { + doThrow(new RuntimeException()).when(minioClient).putObject(any(PutObjectArgs.class)); + assertThrows(ArtifactStorageException.class, () -> { + testSubject.put(VSP_ID, VERSION_ID, new ByteArrayInputStream(new byte[0])); + }); + } + + @Test void testIsEnabled() { Assertions.assertTrue(testSubject.isEnabled()); } @@ -188,6 +198,20 @@ class MinIoStorageArtifactStorageManagerTest { }); } + @Test + void testIsExistsOK() throws Exception { + when(minioClient.bucketExists(any(BucketExistsArgs.class))).thenReturn(true); + Assertions.assertTrue(testSubject.exists(VSP_ID)); + } + + @Test + void testIsExistsFail() throws Exception { + doThrow(new RuntimeException()).when(minioClient).bucketExists(any(BucketExistsArgs.class)); + assertThrows(ArtifactStorageException.class, () -> { + Assertions.assertTrue(testSubject.exists(VSP_ID)); + }); + } + private Attachment mockAttachment() throws IOException { final Attachment attachment = Mockito.mock(Attachment.class); final DataHandler dataHandler = Mockito.mock(DataHandler.class); |