Skip to content

Commit

Permalink
Merge branch 'main' into feature/create-test-for-authenticationContro…
Browse files Browse the repository at this point in the history
…ller
  • Loading branch information
LauroSilveira committed Dec 30, 2023
2 parents 5d6fc28 + 1dac226 commit adb5dbb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<properties>
<java.version>17</java.version>
<mapstruct.version>1.5.5.Final</mapstruct.version>
<maven-compiler-plugin.version>3.12.0</maven-compiler-plugin.version>
<maven-compiler-plugin.version>3.12.1</maven-compiler-plugin.version>
<springdoc.version>2.3.0</springdoc.version>
<jwt.version>4.4.0</jwt.version>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ public UpdateVideoDto updateMovie(UpdateVideoDto dto) {
@Override
public VideoDto delete(String id) {
final var entity = videoRepository.findById(id);
entity.ifPresentOrElse(this.videoRepository::delete, () -> {
if (entity.isPresent()) {
this.videoRepository.delete(entity.get());
return this.videoMapper.mapToVideoDto(entity.get());
} else {
throw new ResourceNotFoundException("Resource not found: " + id);
});
return this.videoMapper.mapToVideoDto(entity.get());
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void login_test() {
final var tokenJwtFake = UUID.randomUUID().toString();
final var userAdministrator = new User("1", "admin@aluraflix.com", "administrator",
Set.of(Roles.builder().id("1").role(RolesEnum.ROLE_ADMIN).build()));

final var testingAuthenticationToken = new TestingAuthenticationToken(userAdministrator, userAdministrator);
when(this.tokenService.generateTokenJWT(Mockito.any())).thenReturn(tokenJwtFake);
when(this.manager.authenticate(Mockito.any())).thenReturn(testingAuthenticationToken);
Expand Down

0 comments on commit adb5dbb

Please sign in to comment.