What is Diffblue Cover?
public PutObjectResult uploadFileToBucket(String bucketName, String key, File file) {
try {
return s3client.putObject(bucketName, key, file);
} catch (AmazonS3Exception e) {
throw new IllegalStateException("Totally handled this exception", e);
}
}@ContextConfiguration(classes = {AmazonService.class})
@ExtendWith(SpringExtension.class)
class AmazonServiceDiffblueTest {
@MockBean
private AmazonS3 amazonS3;
@Autowired
private AmazonService amazonService;
/**
* Method under test: {@link AmazonService#uploadFileToBucket(String, String, File)}
*/
@Test
void diffbluetestUploadFileToBucket() throws SdkClientException {
// Arrange
PutObjectResult putObjectResult = new PutObjectResult();
putObjectResult.setContentMd5("MjdjN2NmNDAwMjI5MTAzZTAwYzZkODgzMDAyOWUyOWI=");
when(amazonS3.putObject(Mockito.<String>any(), Mockito.<String>any(), Mockito.<File>any()))
.thenReturn(putObjectResult);
// Act and Assert
assertSame(putObjectResult, amazonService.uploadFileToBucket("bucket-name", "object-key",
Paths.get(System.getProperty("java.io.tmpdir"), "test.txt").toFile()));
verify(amazonS3).putObject(Mockito.<String>any(), Mockito.<String>any(), Mockito.<File>any());
}
}
Some basics
Key features
IDE, CLI, CI Pipeline



Report, Optimize, Refactor



Key benefits - in summary
How it works

Last updated
Was this helpful?

