add cover in sonar
@@ -7,9 +7,13 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.modelmapper.ModelMapper;
import org.springframework.core.env.PropertyResolver;
+import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.web.multipart.MultipartFile;
+import java.nio.charset.StandardCharsets;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.when;
@@ -30,4 +34,11 @@ class AzureCloudStorageServiceTest {
when(modelMapper.map("Image", MultipartFile.class)).thenThrow(new BadRequestException("S"));
assertThrows(BadRequestException.class, () -> azureCloudStorageService.convertToMultipartImage("Image"));
}
+
+ @Test
+ void convertToMultipartImage() {
+ MultipartFile multipartFile = new MockMultipartFile("Image", "Image".getBytes(StandardCharsets.UTF_8));
+ when(modelMapper.map("Image", MultipartFile.class)).thenReturn(multipartFile);
+ assertEquals(multipartFile, azureCloudStorageService.convertToMultipartImage("Image"));
+ }
}
\ No newline at end of file
