Skip to content

Commit

Permalink
tests fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ElisKina-dev committed Jul 26, 2024
1 parent b04038e commit 10ed7db
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import it.gov.pagopa.atmlayer.service.model.enumeration.NoDeployableResourceType;
import it.gov.pagopa.atmlayer.service.model.exception.AtmLayerException;
import it.gov.pagopa.atmlayer.service.model.mapper.ResourceEntityMapper;
import it.gov.pagopa.atmlayer.service.model.mapper.ResourceFileMapper;
import it.gov.pagopa.atmlayer.service.model.model.PageInfo;
import it.gov.pagopa.atmlayer.service.model.model.ResourceDTO;
import it.gov.pagopa.atmlayer.service.model.model.ResourceFrontEndDTO;
Expand All @@ -31,6 +32,7 @@
import java.io.File;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.UUID;

import static it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorCodeEnum.RESOURCE_FILE_DOES_NOT_EXIST;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ void testCreateSyncError() {
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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@ void testFindByIdSuccess() {
UserProfiles expectedProfile = new UserProfiles();
expectedProfile.setUserProfilesPK(userProfilesPK);

when(userProfilesRepository.findById(userProfilesPK))
when(userProfilesRepository.findById(any(UserProfilesPK.class)))
.thenReturn(Uni.createFrom().item(expectedProfile));

Uni<UserProfiles> result = userProfilesService.findById(userId, profileId);
Uni<UserProfiles> result = userProfilesService.getById(userId, profileId);

result.subscribe().with(
actualProfile -> assertEquals(expectedProfile, actualProfile),
Expand All @@ -277,19 +277,13 @@ void testFindByIdSuccess() {

@Test
void testFindByIdNotFound() {
String userId = "nonExistingUser";
int profileId = 999;
UserProfilesPK userProfilesPK = new UserProfilesPK(userId, profileId);

when(userProfilesRepository.findById(userProfilesPK))
.thenReturn(Uni.createFrom().nullItem());

Uni<UserProfiles> result = userProfilesService.findById(userId, profileId);
UserProfilesPK userProfilesPK = new UserProfilesPK("[email protected]", 2);
when(userProfilesRepository.findById(userProfilesPK)).thenReturn(Uni.createFrom().nullItem());

result.subscribe().with(
Assertions::assertNull,
throwable -> fail("Test fallito a causa di: " + throwable)
);
userProfilesService.getById(userProfilesPK.getUserId(), userProfilesPK.getProfileId())
.subscribe()
.withSubscriber(UniAssertSubscriber.create())
.assertFailed();
}

@Test
Expand Down

0 comments on commit 10ed7db

Please sign in to comment.