Skip to content

Commit

Permalink
testCreateResourceWithDuplicateSHA256 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ElisKina-dev committed Jul 29, 2024
1 parent 10ed7db commit 31a16fb
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,15 @@ void testCreateResourceWithDuplicateSHA256() {
String sha256 = "duplicateSHA256";
File file = new File("path/to/file");
ResourceFile resourceFile = new ResourceFile();
resourceFile.setStorageKey("storageKey");
ResourceEntity newResourceEntity = new ResourceEntity();
newResourceEntity.setResourceFile(resourceFile);
newResourceEntity.setSha256("duplicateSHA256");
resourceEntity.setSha256(sha256);
resourceFile.setStorageKey("storageKeyThatIsLongEnoughToAvoidException");
ResourceEntity existingResourceEntity = new ResourceEntity();
existingResourceEntity.setResourceFile(resourceFile);
existingResourceEntity.setSha256(sha256);


when(resourceEntityRepository.findBySHA256(sha256)).thenReturn(Uni.createFrom().item(newResourceEntity));
when(resourceEntityRepository.findBySHA256(sha256)).thenReturn(Uni.createFrom().item(existingResourceEntity));

resourceEntityService.createResource(newResourceEntity, file, "filename", "path", "description")
resourceEntityService.createResource(existingResourceEntity, file, "filename", "path", "description")
.subscribe().withSubscriber(UniAssertSubscriber.create())
.assertFailedWith(AtmLayerException.class, "Esiste già una risorsa con lo stesso contenuto");
}
Expand Down

0 comments on commit 31a16fb

Please sign in to comment.