diff --git a/pom.xml b/pom.xml index 0b094f0..d4630a8 100644 --- a/pom.xml +++ b/pom.xml @@ -26,10 +26,10 @@ 2.19.0 6.6.0 - 3.0.0 + 0.2.3 - 2.10.0 - 6.0.5 + + 6.0.5 2.10.9.2 2.1.1 3.12.1 @@ -38,10 +38,10 @@ 2.1.214 4.9.1 8.0.0.Final - 4.1.1 + 4.23.2 17 17 - 3.0.0 + @@ -83,6 +83,11 @@ spring-security-core ${spring-security.version} + + org.springframework.boot + spring-boot-starter-oauth2-resource-server + + @@ -125,21 +130,19 @@ plexus-utils 3.3.0 - + + io.swagger.core.v3 swagger-annotations 2.2.15 + + - io.springfox - springfox-boot-starter - ${springfox.boot.starter.version} - - - io.swagger.parser.v3 - swagger-parser - 2.1.15 + org.springdoc + springdoc-openapi-starter-webmvc-ui + 2.4.0 @@ -149,12 +152,6 @@ 20220320 - - - io.springfox - springfox-boot-starter - ${springfox-boot-starter.version} - org.keycloak @@ -250,19 +247,14 @@ org.springframework.security spring-security-test + ${spring-security.version} test - powermock-module-junit4 - org.powermock - test - 2.0.2 - - - powermock-api-mockito2 - org.powermock + junit + junit + 4.13.2 test - 2.0.2 diff --git a/src/main/java/de/caritas/cob/videoservice/api/controller/CustomSwaggerApiResourceController.java b/src/main/java/de/caritas/cob/videoservice/api/controller/CustomSwaggerApiResourceController.java deleted file mode 100644 index 20c524d..0000000 --- a/src/main/java/de/caritas/cob/videoservice/api/controller/CustomSwaggerApiResourceController.java +++ /dev/null @@ -1,19 +0,0 @@ -package de.caritas.cob.videoservice.api.controller; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import springfox.documentation.annotations.ApiIgnore; -import springfox.documentation.swagger.web.ApiResourceController; -import springfox.documentation.swagger.web.SwaggerResourcesProvider; - -@Controller -@ApiIgnore -@RequestMapping(value = "${springfox.docuPath}" + "/swagger-resources") -public class CustomSwaggerApiResourceController extends ApiResourceController { - - public static final String SWAGGER_UI_BASE_URL = "/videocalls/docs"; - - public CustomSwaggerApiResourceController(SwaggerResourcesProvider swaggerResources) { - super(swaggerResources, SWAGGER_UI_BASE_URL); - } -} diff --git a/src/main/java/de/caritas/cob/videoservice/api/controller/VideoController.java b/src/main/java/de/caritas/cob/videoservice/api/controller/VideoController.java index 905b2e3..473e5f5 100644 --- a/src/main/java/de/caritas/cob/videoservice/api/controller/VideoController.java +++ b/src/main/java/de/caritas/cob/videoservice/api/controller/VideoController.java @@ -41,7 +41,7 @@ public class VideoController implements VideocallsApi { */ @Override public ResponseEntity createVideoCall( - @RequestHeader String rcUserId, @Valid CreateVideoCallDTO createVideoCallDto) { + @RequestHeader String rcUserId, CreateVideoCallDTO createVideoCallDto) { var response = videoCallFacade.startVideoCall(createVideoCallDto, rcUserId); return new ResponseEntity<>(response, HttpStatus.CREATED); diff --git a/src/main/java/de/caritas/cob/videoservice/api/service/UuidRegistry.java b/src/main/java/de/caritas/cob/videoservice/api/service/UuidRegistry.java index fb28a0b..521d31b 100644 --- a/src/main/java/de/caritas/cob/videoservice/api/service/UuidRegistry.java +++ b/src/main/java/de/caritas/cob/videoservice/api/service/UuidRegistry.java @@ -10,7 +10,7 @@ @Component public class UuidRegistry { - private static final List GENERATED_UUIDS = new CopyOnWriteArrayList<>(); + protected static final List GENERATED_UUIDS = new CopyOnWriteArrayList<>(); /** * Generates an unique {@link UUID} string that is currently not registered and adds it to the diff --git a/src/main/java/de/caritas/cob/videoservice/config/SpringFoxConfig.java b/src/main/java/de/caritas/cob/videoservice/config/SpringFoxConfig.java deleted file mode 100644 index 07f14cd..0000000 --- a/src/main/java/de/caritas/cob/videoservice/config/SpringFoxConfig.java +++ /dev/null @@ -1,135 +0,0 @@ -package de.caritas.cob.videoservice.config; - -import static java.util.Collections.singletonList; - -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.ApiKey; -import springfox.documentation.service.AuthorizationScope; -import springfox.documentation.service.Contact; -import springfox.documentation.service.SecurityReference; -import springfox.documentation.service.SecurityScheme; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spi.service.contexts.SecurityContext; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -/** - * Provides the SpringFox (API documentation generation) configuration. - * - */ -@Configuration -@Import(BeanValidatorPluginsConfiguration.class) -@EnableSwagger2 -public class SpringFoxConfig { - - @Value("${springfox.docuTitle}") - private String docuTitle; - @Value("${springfox.docuDescription}") - private String docuDescription; - @Value("${springfox.docuVersion}") - private String docuVersion; - @Value("${springfox.docuTermsUrl}") - private String docuTermsUrl; - @Value("${springfox.docuContactName}") - private String docuContactName; - @Value("${springfox.docuContactUrl}") - private String docuContactUrl; - @Value("${springfox.docuContactEmail}") - private String docuContactEmail; - @Value("${springfox.docuLicense}") - private String docuLicense; - @Value("${springfox.docuLicenseUrl}") - private String docuLicenseUrl; - - /** - * White list for path patterns that should be white listed so that swagger UI can be accessed - * without authorization. - */ - public static final String[] WHITE_LIST = - new String[] { - "/videocalls/docs", - "/videocalls/docs/**", - "/videocalls/event/stop", - "/v2/api-docs", - "/configuration/ui", - "/swagger-resources/**", - "/configuration/security", - "/swagger-ui", - "/swagger-ui/**", - "/webjars/**", - "/actuator/health", - "/actuator/health/**" - }; - - /** - * SpringFox Docket Bean. - * - * @return {@link Docket} - */ - @Bean - public Docket apiDocket() { - return new Docket(DocumentationType.SWAGGER_2).select() - .apis(RequestHandlerSelectors.basePackage("de.caritas.cob.agencyservice.api")).build() - .consumes(getContentTypes()).produces(getContentTypes()).apiInfo(getApiInfo()) - .useDefaultResponseMessages(false).protocols(protocols()).securitySchemes(securitySchemes()) - .securityContexts(securityContexts()); - } - - private List securityContexts() { - return singletonList(SecurityContext.builder() - .forPaths(PathSelectors.any()).securityReferences(securityReferences()).build()); - } - - private List securityReferences() { - return singletonList( - SecurityReference.builder().reference("token").scopes(new AuthorizationScope[0]).build()); - } - - private List securitySchemes() { - return singletonList(new ApiKey("Bearer", "Authorization", "header")); - } - - /** - * Returns the API protocols (for documentation). - * - * @return the supported protocols - */ - private Set protocols() { - Set protocols = new HashSet<>(); - protocols.add("https"); - return protocols; - } - - /** - * Returns all content types which should be consumed/produced. - * - * @return the supported content types - */ - private Set getContentTypes() { - Set contentTypes = new HashSet<>(); - contentTypes.add("application/json"); - return contentTypes; - } - - /** - * Returns the API information (defined in application.properties). - * - * @return api information - */ - private ApiInfo getApiInfo() { - return new ApiInfo(docuTitle, docuDescription, docuVersion, docuTermsUrl, - new Contact(docuContactName, docuContactUrl, docuContactEmail), docuLicense, docuLicenseUrl, - Collections.emptyList()); - } -} diff --git a/src/main/java/de/caritas/cob/videoservice/config/security/WebSecurityConfig.java b/src/main/java/de/caritas/cob/videoservice/config/security/WebSecurityConfig.java index 97d4ed3..2dc3894 100644 --- a/src/main/java/de/caritas/cob/videoservice/config/security/WebSecurityConfig.java +++ b/src/main/java/de/caritas/cob/videoservice/config/security/WebSecurityConfig.java @@ -1,7 +1,6 @@ package de.caritas.cob.videoservice.config.security; import de.caritas.cob.videoservice.api.authorization.Authority.AuthorityValue; -import de.caritas.cob.videoservice.config.SpringFoxConfig; import de.caritas.cob.videoservice.filter.HttpTenantFilter; import de.caritas.cob.videoservice.filter.StatelessCsrfFilter; import jakarta.annotation.Nullable; @@ -30,6 +29,22 @@ public class WebSecurityConfig implements WebMvcConfigurer { private static final String UUID_PATTERN = "\\b[0-9a-f]{8}\\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\\b[0-9a-f]{12}\\b"; + public static final String[] WHITE_LIST = + new String[] { + "/videocalls/docs", + "/videocalls/docs/**", + "/videocalls/event/stop", + "/v2/api-docs", + "/configuration/ui", + "/swagger-resources/**", + "/configuration/security", + "/swagger-ui", + "/swagger-ui/**", + "/webjars/**", + "/actuator/health", + "/actuator/health/**" + }; + @Autowired AuthorisationService authorisationService; @Autowired JwtAuthConverterProperties jwtAuthConverterProperties; @@ -69,7 +84,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { .sessionCreationPolicy(SessionCreationPolicy.STATELESS) .and() .authorizeRequests() - .requestMatchers(SpringFoxConfig.WHITE_LIST) + .requestMatchers(WHITE_LIST) .permitAll() .requestMatchers("/videocalls/new") .hasAuthority(AuthorityValue.CONSULTANT) diff --git a/src/main/java/de/caritas/cob/videoservice/filter/StatelessCsrfFilter.java b/src/main/java/de/caritas/cob/videoservice/filter/StatelessCsrfFilter.java index 797adce..36a906f 100644 --- a/src/main/java/de/caritas/cob/videoservice/filter/StatelessCsrfFilter.java +++ b/src/main/java/de/caritas/cob/videoservice/filter/StatelessCsrfFilter.java @@ -3,7 +3,7 @@ import static java.util.Objects.isNull; import static java.util.Objects.nonNull; -import de.caritas.cob.videoservice.config.SpringFoxConfig; +import de.caritas.cob.videoservice.config.security.WebSecurityConfig; import jakarta.servlet.FilterChain; import jakarta.servlet.ServletException; import jakarta.servlet.http.Cookie; @@ -74,7 +74,7 @@ public static final class DefaultRequiresCsrfMatcher implements RequestMatcher { @Override public boolean matches(HttpServletRequest request) { - if (Arrays.stream(SpringFoxConfig.WHITE_LIST) + if (Arrays.stream(WebSecurityConfig.WHITE_LIST) .parallel() .anyMatch(request.getRequestURI().toLowerCase()::contains)) { return false; diff --git a/src/main/resources/application-testing.properties b/src/main/resources/application-testing.properties index cb637d2..6999e1e 100644 --- a/src/main/resources/application-testing.properties +++ b/src/main/resources/application-testing.properties @@ -31,7 +31,9 @@ spring.liquibase.enabled=false spring.datasource.driver-class-name=org.h2.Driver spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1 spring.datasource.schema=classpath*:database/VideoServiceDatabase.sql,classpath*:database/VideoData.sql +spring.sql.init.schema-locations=classpath*:database/VideoServiceDatabase.sql,classpath*:database/VideoData.sql spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect + spring.jpa.open-in-view=false spring.jpa.hibernate.ddl-auto=none spring.data.jpa.repositories.bootstrap-mode=default diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index b542b10..a2b1680 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -72,4 +72,11 @@ spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDB103Dialect spring.datasource.url=jdbc:mariadb://localhost:3306/videoservice spring.datasource.username=videoservice -spring.datasource.password= \ No newline at end of file +spring.datasource.password= + +spring.security.oauth2.resourceserver.jwt.issuer-uri: https://localhost/auth/realms/onlineberatung +spring.security.oauth2.resourceserver.jwt.jwk-set-uri: https://localhost/auth/realms/onlineberatung/protocol/openid-connect/certs +spring.jwt.auth.converter.resource-id: app +spring.jwt.auth.converter.principal-attribute: preferred_username + +springdoc.api-docs.enabled=false \ No newline at end of file diff --git a/src/test/java/de/caritas/cob/videoservice/ApiDefaultResponseEntityExceptionHandlerTest.java b/src/test/java/de/caritas/cob/videoservice/ApiDefaultResponseEntityExceptionHandlerTest.java index 44a165c..6eee9c7 100644 --- a/src/test/java/de/caritas/cob/videoservice/ApiDefaultResponseEntityExceptionHandlerTest.java +++ b/src/test/java/de/caritas/cob/videoservice/ApiDefaultResponseEntityExceptionHandlerTest.java @@ -1,41 +1,29 @@ package de.caritas.cob.videoservice; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.powermock.reflect.Whitebox.setInternalState; -import de.caritas.cob.videoservice.api.service.LogService; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.slf4j.Logger; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.web.context.request.WebRequest; -@RunWith(MockitoJUnitRunner.class) -public class ApiDefaultResponseEntityExceptionHandlerTest { +@ExtendWith(MockitoExtension.class) +class ApiDefaultResponseEntityExceptionHandlerTest { @InjectMocks private ApiDefaultResponseEntityExceptionHandler exceptionHandler; - @Mock private Logger logger; - - @Before - public void setup() { - setInternalState(LogService.class, "LOGGER", logger); - } - @Test - public void handleInternal_Should_logInternalServerError_When_exceptionIsGiven() { + void handleInternal_Should_respondWithStatusInternalServerError_When_exceptionIsGiven() { RuntimeException exception = new RuntimeException("error"); - this.exceptionHandler.handleInternal(exception, mock(WebRequest.class)); + ResponseEntity objectResponseEntity = + this.exceptionHandler.handleInternal(exception, mock(WebRequest.class)); - verify(this.logger, times(1)) - .error(eq("VideoService API: 500 Internal Server Error: {}"), anyString()); + assertThat(objectResponseEntity.getStatusCode(), equalTo(HttpStatus.INTERNAL_SERVER_ERROR)); } } diff --git a/src/test/java/de/caritas/cob/videoservice/ApiResponseEntityExceptionHandlerTest.java b/src/test/java/de/caritas/cob/videoservice/ApiResponseEntityExceptionHandlerTest.java deleted file mode 100644 index e3eb640..0000000 --- a/src/test/java/de/caritas/cob/videoservice/ApiResponseEntityExceptionHandlerTest.java +++ /dev/null @@ -1,109 +0,0 @@ -package de.caritas.cob.videoservice; - -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.powermock.reflect.Whitebox.setInternalState; -import static org.springframework.http.HttpStatus.NOT_FOUND; - -import de.caritas.cob.videoservice.api.exception.httpresponse.BadRequestException; -import de.caritas.cob.videoservice.api.exception.httpresponse.InternalServerErrorException; -import de.caritas.cob.videoservice.api.service.LogService; -import java.util.NoSuchElementException; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.slf4j.Logger; -import org.springframework.http.HttpHeaders; -import org.springframework.web.bind.MethodArgumentNotValidException; -import org.springframework.web.client.HttpClientErrorException; -import org.springframework.web.context.request.WebRequest; -import org.springframework.web.server.ResponseStatusException; - -@RunWith(MockitoJUnitRunner.class) -public class ApiResponseEntityExceptionHandlerTest { - - @InjectMocks private ApiResponseEntityExceptionHandler exceptionHandler; - - @Mock private Logger logger; - - @Before - public void setup() { - setInternalState(LogService.class, "LOGGER", logger); - } - - @Test - public void handleCustomBadRequest_Should_executeLogging_When_badRequestIsGiven() { - BadRequestException badRequestException = - new BadRequestException("test", LogService::logWarning); - - this.exceptionHandler.handleCustomBadRequest(badRequestException, mock(WebRequest.class)); - - verify(logger, times(1)).warn(eq("VideoService API: {}"), anyString()); - } - - @Test - public void - handleNoSuchElementException_Should_executeLogging_When_noSuchElementExceptionRequestIsGiven() { - NoSuchElementException noSuchElementException = new NoSuchElementException("test"); - - this.exceptionHandler.handleNoSuchElementException( - noSuchElementException, mock(WebRequest.class)); - - verify(logger, times(1)).warn(eq("VideoService API: {}: {}"), eq("Not Found"), anyString()); - } - - @Test - public void handleMethodArgumentNotValid_Should_executeLogging() { - this.exceptionHandler.handleMethodArgumentNotValid( - mock(MethodArgumentNotValidException.class), - new HttpHeaders(), - NOT_FOUND, - mock(WebRequest.class)); - - verify(logger, times(1)).warn(eq("VideoService API: {}: {}"), eq("Not Found"), anyString()); - } - - @Test - public void handleInternal_Should_executeLogging_When_RuntimeExceptionIsGiven() { - RuntimeException runtimeException = new RuntimeException("test"); - - this.exceptionHandler.handleInternal(runtimeException, mock(WebRequest.class)); - - verify(logger, times(1)) - .error(eq("VideoService API: 500 Internal Server Error: {}"), anyString()); - } - - @Test - public void handleInternal_Should_executeLogging_When_InternalServerErrorIsGiven() { - InternalServerErrorException exception = new InternalServerErrorException("error"); - - this.exceptionHandler.handleInternal(exception, mock(WebRequest.class)); - - verify(logger, times(1)) - .error(eq("VideoService API: 500 Internal Server Error: {}"), anyString()); - } - - @Test - public void handleInternal_Should_executeLogging_When_ResponseStatusExceptionIsGiven() { - ResponseStatusException exception = new ResponseStatusException(NOT_FOUND); - - this.exceptionHandler.handleInternal(exception, mock(WebRequest.class)); - - verify(logger, times(1)).warn(eq("VideoService API: {}"), anyString()); - } - - @Test - public void handleInternal_Should_executeLogging_When_HttpClientErrorExceptionIsGiven() { - HttpClientErrorException exception = new HttpClientErrorException(NOT_FOUND); - - this.exceptionHandler.handleInternal(exception, mock(WebRequest.class)); - - verify(logger, times(1)).error(eq("VideoService API: {}"), anyString()); - } -} diff --git a/src/test/java/de/caritas/cob/videoservice/api/controller/VideoControllerIT.java b/src/test/java/de/caritas/cob/videoservice/api/controller/VideoControllerIT.java index b57a6fd..1662d63 100644 --- a/src/test/java/de/caritas/cob/videoservice/api/controller/VideoControllerIT.java +++ b/src/test/java/de/caritas/cob/videoservice/api/controller/VideoControllerIT.java @@ -20,6 +20,8 @@ import de.caritas.cob.videoservice.api.model.RejectVideoCallDTO; import de.caritas.cob.videoservice.api.service.RejectVideoCallService; import de.caritas.cob.videoservice.api.service.video.VideoCallUrlGeneratorService; +import de.caritas.cob.videoservice.config.security.AuthorisationService; +import de.caritas.cob.videoservice.config.security.JwtAuthConverterProperties; import java.util.UUID; import org.junit.Test; import org.junit.runner.RunWith; @@ -42,6 +44,10 @@ public class VideoControllerIT { @MockBean private RejectVideoCallService rejectVideoCallService; + @MockBean private AuthorisationService authorisationService; + + @MockBean private JwtAuthConverterProperties jwtAuthConverterProperties; + @MockBean @SuppressWarnings("unused") private RoleAuthorizationAuthorityMapper roleAuthorizationAuthorityMapper; diff --git a/src/test/java/de/caritas/cob/videoservice/api/facade/VideoCallFacadeTest.java b/src/test/java/de/caritas/cob/videoservice/api/facade/VideoCallFacadeTest.java index 43efecc..673f5b4 100644 --- a/src/test/java/de/caritas/cob/videoservice/api/facade/VideoCallFacadeTest.java +++ b/src/test/java/de/caritas/cob/videoservice/api/facade/VideoCallFacadeTest.java @@ -11,6 +11,7 @@ import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; @@ -47,18 +48,18 @@ import java.util.Objects; import java.util.Optional; import org.jeasy.random.EasyRandom; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.springframework.security.access.AccessDeniedException; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.util.ReflectionTestUtils; -@RunWith(SpringRunner.class) -public class VideoCallFacadeTest { +@ExtendWith(SpringExtension.class) +class VideoCallFacadeTest { @InjectMocks private VideoCallFacade videoCallFacade; @Mock private SessionService sessionService; @@ -75,12 +76,13 @@ public class VideoCallFacadeTest { @Mock private MessageService messageService; @Test - public void startVideoCall_Should_ReturnCorrectVideoCallUrl_When_UrlWasGeneratedSuccessfully() { + void startVideoCall_Should_ReturnCorrectVideoCallUrl_When_UrlWasGeneratedSuccessfully() { // given when(authenticatedUser.getUserId()).thenReturn(CONSULTANT_ID); when(uuidRegistry.generateUniqueUuid()).thenReturn(VIDEO_CALL_UUID); ConsultantSessionDTO consultantSessionDto = mock(ConsultantSessionDTO.class); when(consultantSessionDto.getStatus()).thenReturn(IN_PROGRESS.getValue()); + when(consultantSessionDto.getAskerId()).thenReturn("askerId"); VideoCallUrls videoCallUrls = new EasyRandom().nextObject(VideoCallUrls.class); when(sessionService.findSessionOfCurrentConsultant(SESSION_ID)) @@ -96,8 +98,7 @@ public void startVideoCall_Should_ReturnCorrectVideoCallUrl_When_UrlWasGenerated } @Test - public void - startGroupVideoCall_Should_ReturnCorrectVideoCallUrl_When_UrlWasGeneratedSuccessfully() { + void startGroupVideoCall_Should_ReturnCorrectVideoCallUrl_When_UrlWasGeneratedSuccessfully() { // given when(authenticatedUser.getUserId()).thenReturn(CONSULTANT_ID); @@ -132,8 +133,8 @@ public void startVideoCall_Should_ReturnCorrectVideoCallUrl_When_UrlWasGenerated assertThat(captor.getValue()).containsExactlyInAnyOrder("anotherUserId"); } - @Test(expected = AccessDeniedException.class) - public void startGroupVideoCall_Should_ThrowForbiddenException_When_UserDoesNotHavePermissions() { + @Test + void startGroupVideoCall_Should_ThrowForbiddenException_When_UserDoesNotHavePermissions() { // given when(authenticatedUser.getUserId()).thenReturn(CONSULTANT_ID); when(uuidRegistry.generateUniqueUuid()).thenReturn(VIDEO_CALL_UUID); @@ -142,13 +143,17 @@ public void startGroupVideoCall_Should_ThrowForbiddenException_When_UserDoesNotH .when(chatService) .assertCanModerateChat(GROUP_CHAT_ID); - // when - videoCallFacade.startVideoCall(new CreateVideoCallDTO().groupChatId(GROUP_CHAT_ID), "rcUserId"); + // when, then + CreateVideoCallDTO createVideoCallRequest = new CreateVideoCallDTO().groupChatId(GROUP_CHAT_ID); + assertThrows( + AccessDeniedException.class, + () -> + videoCallFacade.startVideoCall( + createVideoCallRequest, "rcUserId")); } @Test - public void - joinGroupVideoCall_Should_ReturnCorrectVideoCallUrl_When_UrlWasGeneratedSuccessfully() { + void joinGroupVideoCall_Should_ReturnCorrectVideoCallUrl_When_UrlWasGeneratedSuccessfully() { // given when(authenticatedUser.getUserId()).thenReturn(CONSULTANT_ID); @@ -159,6 +164,7 @@ public void startGroupVideoCall_Should_ThrowForbiddenException_When_UserDoesNotH VideoRoomEntity videoRoomEntity = new EasyRandom().nextObject(VideoRoomEntity.class); videoRoomEntity.setGroupChatId(GROUP_CHAT_ID); + videoRoomEntity.setSessionId(null); when(videoRoomService.findByJitsiRoomId(VIDEO_CALL_UUID)) .thenReturn(Optional.of(videoRoomEntity)); @@ -172,18 +178,19 @@ public void startGroupVideoCall_Should_ThrowForbiddenException_When_UserDoesNotH assertThat(result.getModeratorVideoCallUrl()).isEqualTo(videoCallUrls.getModeratorVideoUrl()); } - @Test(expected = NoSuchElementException.class) - public void joinGroupVideoCall_Should_ThrowNoSuchElementException_When_GivenChatNotFound() { - // when - videoCallFacade.joinGroupVideoCall(VIDEO_CALL_UUID); + @Test + void joinGroupVideoCall_Should_ThrowNoSuchElementException_When_GivenChatNotFound() { + assertThrows( + NoSuchElementException.class, () -> videoCallFacade.joinGroupVideoCall(VIDEO_CALL_UUID)); } - @Test(expected = AccessDeniedException.class) - public void joinGroupVideoCall_Should_ThrowForbiddenException_When_UserIsNotModerator() { + @Test + void joinGroupVideoCall_Should_ThrowForbiddenException_When_UserIsNotModerator() { // given when(authenticatedUser.getUserId()).thenReturn(CONSULTANT_ID); when(uuidRegistry.generateUniqueUuid()).thenReturn(VIDEO_CALL_UUID); VideoRoomEntity videoRoomEntity = new EasyRandom().nextObject(VideoRoomEntity.class); + videoRoomEntity.setSessionId(null); videoRoomEntity.setGroupChatId(GROUP_CHAT_ID); when(videoRoomService.findByJitsiRoomId(VIDEO_CALL_UUID)) .thenReturn(Optional.of(videoRoomEntity)); @@ -193,11 +200,12 @@ public void joinGroupVideoCall_Should_ThrowForbiddenException_When_UserIsNotMode .assertCanModerateChat(GROUP_CHAT_ID); // when - videoCallFacade.joinGroupVideoCall(VIDEO_CALL_UUID); + assertThrows( + AccessDeniedException.class, () -> videoCallFacade.joinGroupVideoCall(VIDEO_CALL_UUID)); } @Test - public void + void startVideoCall_Should_CallLiveServiceAndBuildCorrectLiveEventMessageWithVideoCallRequestDto() { // given @@ -228,8 +236,8 @@ public void joinGroupVideoCall_Should_ThrowForbiddenException_When_UserIsNotMode assertEquals(USERNAME, eventContent.getInitiatorUsername()); } - @Test(expected = BadRequestException.class) - public void startVideoCall_Should_throwBadRequestException_When_sessionIsNotInProgress() { + @Test + void startVideoCall_Should_throwBadRequestException_When_sessionIsNotInProgress() { // given when(authenticatedUser.getUserId()).thenReturn(CONSULTANT_ID); when(uuidRegistry.generateUniqueUuid()).thenReturn(VIDEO_CALL_UUID); @@ -239,17 +247,21 @@ public void startVideoCall_Should_throwBadRequestException_When_sessionIsNotInPr .thenReturn(consultantSessionDto); // when - videoCallFacade.startVideoCall(new CreateVideoCallDTO().sessionId(SESSION_ID), ""); + CreateVideoCallDTO createVideoCallRequest = new CreateVideoCallDTO().sessionId(SESSION_ID); + assertThrows( + BadRequestException.class, + () -> videoCallFacade.startVideoCall(createVideoCallRequest, "")); } @Test - public void startVideoCall_Should_FireAssignSessionStatisticsEvent() { + void startVideoCall_Should_FireAssignSessionStatisticsEvent() { // given when(authenticatedUser.getUserId()).thenReturn(CONSULTANT_ID); when(uuidRegistry.generateUniqueUuid()).thenReturn(VIDEO_CALL_UUID); ConsultantSessionDTO consultantSessionDto = mock(ConsultantSessionDTO.class); when(consultantSessionDto.getStatus()).thenReturn(IN_PROGRESS.getValue()); + when(consultantSessionDto.getAskerId()).thenReturn("askerId"); VideoCallUrls videoCallUrls = new EasyRandom().nextObject(VideoCallUrls.class); when(sessionService.findSessionOfCurrentConsultant(SESSION_ID)) @@ -283,7 +295,7 @@ public void startVideoCall_Should_FireAssignSessionStatisticsEvent() { } @Test - public void + void startVideoCall_Should_FireAssignSessionStatisticsEventWithDisplayName_When_initiatorDisplayNameIsSet() { // given @@ -291,6 +303,7 @@ public void startVideoCall_Should_FireAssignSessionStatisticsEvent() { when(uuidRegistry.generateUniqueUuid()).thenReturn(VIDEO_CALL_UUID); ConsultantSessionDTO consultantSessionDto = mock(ConsultantSessionDTO.class); when(consultantSessionDto.getStatus()).thenReturn(IN_PROGRESS.getValue()); + when(consultantSessionDto.getAskerId()).thenReturn("askerId"); VideoCallUrls videoCallUrls = new EasyRandom().nextObject(VideoCallUrls.class); when(sessionService.findSessionOfCurrentConsultant(SESSION_ID)) @@ -315,7 +328,7 @@ public void startVideoCall_Should_FireAssignSessionStatisticsEvent() { } @Test - public void handleVideoCallStoppedEvent_Should_StopPeristentVideoCallRoom() { + void handleVideoCallStoppedEvent_Should_StopPeristentVideoCallRoom() { // given when(uuidRegistry.generateUniqueUuid()).thenReturn(VIDEO_CALL_UUID); @@ -338,7 +351,7 @@ public void handleVideoCallStoppedEvent_Should_StopPeristentVideoCallRoom() { } @Test - public void handleVideoCallStoppedEvent_Should_StopPeristentVideoCallRoomForOneToOneCall() { + void handleVideoCallStoppedEvent_Should_StopPeristentVideoCallRoomForOneToOneCall() { // given when(uuidRegistry.generateUniqueUuid()).thenReturn(VIDEO_CALL_UUID); diff --git a/src/test/java/de/caritas/cob/videoservice/api/helper/JsonHelperTest.java b/src/test/java/de/caritas/cob/videoservice/api/helper/JsonHelperTest.java index afc0fa7..a0b0070 100644 --- a/src/test/java/de/caritas/cob/videoservice/api/helper/JsonHelperTest.java +++ b/src/test/java/de/caritas/cob/videoservice/api/helper/JsonHelperTest.java @@ -63,7 +63,9 @@ public void serialize_Should_returnOptionalWithSerializedObject() { + "\"," + " \"videoCallUuid\":\"" + uuid - + "\"" + + "\"," + + "\"adviceSeekerId\": null," + + "\"tenantId\": null" + "}"; assertThat(result.get(), jsonEquals(expectedJson)); diff --git a/src/test/java/de/caritas/cob/videoservice/api/service/LogServiceTest.java b/src/test/java/de/caritas/cob/videoservice/api/service/LogServiceTest.java deleted file mode 100644 index dfd28cc..0000000 --- a/src/test/java/de/caritas/cob/videoservice/api/service/LogServiceTest.java +++ /dev/null @@ -1,94 +0,0 @@ -package de.caritas.cob.videoservice.api.service; - -import static de.caritas.cob.videoservice.api.service.LogService.STATISTICS_EVENT_PROCESSING_ERROR; -import static de.caritas.cob.videoservice.api.service.LogService.STATISTICS_EVENT_PROCESSING_WARNING; -import static jakarta.servlet.RequestDispatcher.ERROR_MESSAGE; -import static org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.powermock.reflect.Whitebox.setInternalState; - -import java.io.PrintWriter; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.slf4j.Logger; -import org.springframework.http.HttpStatus; - -@RunWith(MockitoJUnitRunner.class) -public class LogServiceTest { - - @Mock Exception exception; - - @Mock private Logger logger; - - public static final Exception EXCEPTION = new Exception(); - - @Before - public void setup() { - setInternalState(LogService.class, "LOGGER", logger); - } - - @Test - public void logInfo_Should_LogInfoMessage() { - LogService.logInfo("info message"); - - verify(logger, atLeastOnce()).info("info message"); - } - - @Test - public void logWarning_Should_LogWarnMessage_When_onlyExceptionIsProvided() { - LogService.logWarning(exception); - - verify(logger, atLeastOnce()).warn(eq("VideoService API: {}"), anyString()); - verify(exception, atLeastOnce()).printStackTrace(any(PrintWriter.class)); - } - - @Test - public void logWarning_Should_LogWarnMessage_When_onlyExceptionAndStatusProvided() { - LogService.logWarning(HttpStatus.MULTI_STATUS, exception); - - verify(logger, atLeastOnce()) - .warn(eq("VideoService API: {}: {}"), eq("Multi-Status"), anyString()); - verify(exception, atLeastOnce()).printStackTrace(any(PrintWriter.class)); - } - - @Test - public void logInternalServerError_Should_LogError() { - LogService.logInternalServerError(exception); - - verify(logger, atLeastOnce()) - .error(eq("VideoService API: 500 Internal Server Error: {}"), anyString()); - verify(exception, atLeastOnce()).printStackTrace(any(PrintWriter.class)); - } - - @Test - public void logError_Should_LogError() { - LogService.logError(exception); - - verify(logger, atLeastOnce()).error(eq("VideoService API: {}"), anyString()); - verify(exception, atLeastOnce()).printStackTrace(any(PrintWriter.class)); - } - - @Test - public void logStatisticEventError_Should_LogExceptionStackTraceAndErrorMessage() { - - LogService.logStatisticsEventError(EXCEPTION); - verify(logger, times(1)) - .error(anyString(), eq(STATISTICS_EVENT_PROCESSING_ERROR), eq(getStackTrace(EXCEPTION))); - } - - @Test - public void logStatisticEventWarning_Should_LogErrorMessageAsWarning() { - - LogService.logStatisticsEventWarning(ERROR_MESSAGE); - verify(logger, times(1)) - .warn(anyString(), eq(STATISTICS_EVENT_PROCESSING_WARNING), eq(ERROR_MESSAGE)); - } -} diff --git a/src/test/java/de/caritas/cob/videoservice/api/service/UuidRegistryTest.java b/src/test/java/de/caritas/cob/videoservice/api/service/UuidRegistryTest.java index 0e55ffa..d969148 100644 --- a/src/test/java/de/caritas/cob/videoservice/api/service/UuidRegistryTest.java +++ b/src/test/java/de/caritas/cob/videoservice/api/service/UuidRegistryTest.java @@ -1,31 +1,24 @@ package de.caritas.cob.videoservice.api.service; -import static de.caritas.cob.videoservice.api.testhelper.FieldConstants.FIELD_NAME_GENERATED_UUIDS; +import static de.caritas.cob.videoservice.api.service.UuidRegistry.GENERATED_UUIDS; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.powermock.reflect.Whitebox.setInternalState; -import java.util.List; import java.util.UUID; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.powermock.modules.junit4.PowerMockRunner; +import org.mockito.junit.MockitoJUnitRunner; -@RunWith(PowerMockRunner.class) +@RunWith(MockitoJUnitRunner.class) public class UuidRegistryTest { - @InjectMocks private UuidRegistry uuidRegistry; - @Mock private List uuidList; + private UuidRegistry uuidRegistry = new UuidRegistry(); @Before public void setUp() { - setInternalState(UuidRegistry.class, FIELD_NAME_GENERATED_UUIDS, uuidList); uuidRegistry.cleanUpUuidRegistry(); } @@ -41,15 +34,12 @@ public void generateUniqueUuid_Should_AddGeneratedUuidToRegistry() { String response = uuidRegistry.generateUniqueUuid(); assertThat(UUID.fromString(response), instanceOf(UUID.class)); - verify(uuidList, times(1)).add(UUID.fromString(response)); + assertThat(GENERATED_UUIDS.size(), equalTo(1)); } @Test public void cleanUpEntireList_Should_cleanListOfUuids() { - uuidList.add(UUID.randomUUID()); - uuidRegistry.cleanUpUuidRegistry(); - - assertEquals(0, uuidList.size()); + assertEquals(0, GENERATED_UUIDS.size()); } } diff --git a/src/test/java/de/caritas/cob/videoservice/api/service/statistics/StatisticsServiceIT.java b/src/test/java/de/caritas/cob/videoservice/api/service/statistics/StatisticsServiceIT.java index 9d97617..5bb151e 100644 --- a/src/test/java/de/caritas/cob/videoservice/api/service/statistics/StatisticsServiceIT.java +++ b/src/test/java/de/caritas/cob/videoservice/api/service/statistics/StatisticsServiceIT.java @@ -44,7 +44,7 @@ public void fireEvent_Should_Send_ExpectedAssignSessionStatisticsEventMessageToQ UUID uuid = UUID.randomUUID(); StartVideoCallStatisticsEvent startVideoCallStatisticsEvent = new StartVideoCallStatisticsEvent( - CONSULTANT_ID, UserRole.CONSULTANT, SESSION_ID, uuid.toString(), ADVICESEEKER_ID); + CONSULTANT_ID, UserRole.CONSULTANT, SESSION_ID, uuid.toString(), ADVICESEEKER_ID, 1L); statisticsService.fireEvent(startVideoCallStatisticsEvent); Message message = @@ -73,7 +73,8 @@ public void fireEvent_Should_Send_ExpectedAssignSessionStatisticsEventMessageToQ + "\"," + " \"videoCallUuid\":\"" + uuid - + "\"" + + "\"," + + "\"tenantId\":1" + "}"; assertThat( diff --git a/src/test/java/de/caritas/cob/videoservice/api/service/statistics/StatisticsServiceTest.java b/src/test/java/de/caritas/cob/videoservice/api/service/statistics/StatisticsServiceTest.java index 65a3ddb..af1b3cb 100644 --- a/src/test/java/de/caritas/cob/videoservice/api/service/statistics/StatisticsServiceTest.java +++ b/src/test/java/de/caritas/cob/videoservice/api/service/statistics/StatisticsServiceTest.java @@ -4,29 +4,27 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; -import static org.powermock.reflect.Whitebox.setInternalState; import static org.springframework.test.util.ReflectionTestUtils.setField; -import de.caritas.cob.videoservice.api.service.LogService; import de.caritas.cob.videoservice.api.service.statistics.event.StartVideoCallStatisticsEvent; import de.caritas.cob.videoservice.statisticsservice.generated.web.model.EventType; import java.nio.charset.StandardCharsets; import java.util.Optional; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; -import org.slf4j.Logger; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.amqp.core.AmqpTemplate; import org.springframework.amqp.core.MessageBuilder; import org.springframework.amqp.core.MessageProperties; -@RunWith(MockitoJUnitRunner.class) -public class StatisticsServiceTest { +@ExtendWith(MockitoExtension.class) +class StatisticsServiceTest { private static final String FIELD_NAME_STATISTICS_ENABLED = "statisticsEnabled"; private static final String FIELD_NAME_RABBIT_EXCHANGE_NAME = "rabbitMqExchangeName"; @@ -38,19 +36,15 @@ public class StatisticsServiceTest { @InjectMocks private StatisticsService statisticsService; @Mock private AmqpTemplate amqpTemplate; - @Mock Logger logger; - @Before - public void setup() { + @BeforeEach + void setup() { startVideoCallStatisticsEvent = Mockito.mock(StartVideoCallStatisticsEvent.class); - when(startVideoCallStatisticsEvent.getEventType()).thenReturn(eventType); - when(startVideoCallStatisticsEvent.getPayload()).thenReturn(Optional.of(PAYLOAD)); - setInternalState(LogService.class, "LOGGER", logger); setField(statisticsService, FIELD_NAME_RABBIT_EXCHANGE_NAME, RABBIT_EXCHANGE_NAME); } @Test - public void fireEvent_Should_NotSendStatisticsMessage_WhenStatisticsIsDisabled() { + void fireEvent_Should_NotSendStatisticsMessage_WhenStatisticsIsDisabled() { setField(statisticsService, FIELD_NAME_STATISTICS_ENABLED, false); statisticsService.fireEvent(startVideoCallStatisticsEvent); @@ -59,8 +53,10 @@ public void fireEvent_Should_NotSendStatisticsMessage_WhenStatisticsIsDisabled() } @Test - public void fireEvent_Should_SendStatisticsMessage_WhenStatisticsIsEnabled() { + void fireEvent_Should_SendStatisticsMessage_WhenStatisticsIsEnabled() { + when(startVideoCallStatisticsEvent.getEventType()).thenReturn(eventType); + when(startVideoCallStatisticsEvent.getPayload()).thenReturn(Optional.of(PAYLOAD)); setField(statisticsService, FIELD_NAME_STATISTICS_ENABLED, true); when(startVideoCallStatisticsEvent.getEventType()).thenReturn(eventType); when(startVideoCallStatisticsEvent.getPayload()).thenReturn(Optional.of(PAYLOAD)); @@ -71,17 +67,19 @@ public void fireEvent_Should_SendStatisticsMessage_WhenStatisticsIsEnabled() { } @Test - public void fireEvent_Should_LogWarning_WhenPayloadIsEmpty() { + void fireEvent_Should_NotSendAmqpMessage_WhenPayloadIsEmpty() { setField(statisticsService, FIELD_NAME_STATISTICS_ENABLED, true); when(startVideoCallStatisticsEvent.getPayload()).thenReturn(Optional.empty()); statisticsService.fireEvent(startVideoCallStatisticsEvent); - verify(logger, times(1)).warn(anyString(), anyString(), anyString()); + verifyNoInteractions(amqpTemplate); } @Test - public void fireEvent_Should_UseEventTypeAsTopicAndSendPayloadOfEvent() { + void fireEvent_Should_UseEventTypeAsTopicAndSendPayloadOfEvent() { + when(startVideoCallStatisticsEvent.getEventType()).thenReturn(eventType); + when(startVideoCallStatisticsEvent.getPayload()).thenReturn(Optional.of(PAYLOAD)); setField(statisticsService, FIELD_NAME_STATISTICS_ENABLED, true); statisticsService.fireEvent(startVideoCallStatisticsEvent); verify(amqpTemplate, times(1)) diff --git a/src/test/java/de/caritas/cob/videoservice/api/service/statistics/event/StartVideoCallStatisticsEventTest.java b/src/test/java/de/caritas/cob/videoservice/api/service/statistics/event/StartVideoCallStatisticsEventTest.java index 93c7fc2..52b8b31 100644 --- a/src/test/java/de/caritas/cob/videoservice/api/service/statistics/event/StartVideoCallStatisticsEventTest.java +++ b/src/test/java/de/caritas/cob/videoservice/api/service/statistics/event/StartVideoCallStatisticsEventTest.java @@ -27,13 +27,15 @@ public class StartVideoCallStatisticsEventTest { @Before public void setup() { uuid = UUID.randomUUID(); + adviceSeekerUuid = UUID.randomUUID(); startVideoCallStatisticsEvent = new StartVideoCallStatisticsEvent( CONSULTANT_ID, UserRole.CONSULTANT, SESSION_ID, uuid.toString(), - adviceSeekerUuid.toString()); + adviceSeekerUuid.toString(), + 1L); } @Test @@ -64,7 +66,11 @@ public void getPayload_Should_ReturnValidJsonPayload() { + "\"," + " \"videoCallUuid\":\"" + uuid - + "\"" + + "\"," + + " \"adviceSeekerId\":\"" + + adviceSeekerUuid + + "\"," + + " \"tenantId\":1" + "}"; Optional result = startVideoCallStatisticsEvent.getPayload(); diff --git a/src/test/java/de/caritas/cob/videoservice/config/apiclient/LiveServiceApiClientConfigIT.java b/src/test/java/de/caritas/cob/videoservice/config/apiclient/LiveServiceApiClientConfigIT.java index d17ce5e..94696d3 100644 --- a/src/test/java/de/caritas/cob/videoservice/config/apiclient/LiveServiceApiClientConfigIT.java +++ b/src/test/java/de/caritas/cob/videoservice/config/apiclient/LiveServiceApiClientConfigIT.java @@ -5,18 +5,18 @@ import de.caritas.cob.videoservice.VideoServiceApplication; import de.caritas.cob.videoservice.liveservice.generated.web.LiveControllerApi; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest(classes = VideoServiceApplication.class) @TestPropertySource(properties = "spring.profiles.active=testing") -public class LiveServiceApiClientConfigIT { +class LiveServiceApiClientConfigIT { @Autowired private LiveControllerApi liveControllerApi; @@ -24,7 +24,7 @@ public class LiveServiceApiClientConfigIT { private String liveServiceApiUrl; @Test - public void configureLiveControllerApi_Should_setCorrectApiUrl() { + void configureLiveControllerApi_Should_setCorrectApiUrl() { String apiClientUrl = this.liveControllerApi.getApiClient().getBasePath(); assertThat(apiClientUrl, is(this.liveServiceApiUrl)); diff --git a/src/test/java/de/caritas/cob/videoservice/config/apiclient/UserServiceApiClientConfigIT.java b/src/test/java/de/caritas/cob/videoservice/config/apiclient/UserServiceApiClientConfigIT.java index 1f50045..66794ce 100644 --- a/src/test/java/de/caritas/cob/videoservice/config/apiclient/UserServiceApiClientConfigIT.java +++ b/src/test/java/de/caritas/cob/videoservice/config/apiclient/UserServiceApiClientConfigIT.java @@ -5,18 +5,18 @@ import de.caritas.cob.videoservice.VideoServiceApplication; import de.caritas.cob.videoservice.userservice.generated.web.UserControllerApi; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest(classes = VideoServiceApplication.class) @TestPropertySource(properties = "spring.profiles.active=testing") -public class UserServiceApiClientConfigIT { +class UserServiceApiClientConfigIT { @Autowired private UserControllerApi userControllerApi; @@ -24,7 +24,7 @@ public class UserServiceApiClientConfigIT { private String userServiceApiUrl; @Test - public void configureLiveControllerApi_Should_setCorrectApiUrl() { + void configureLiveControllerApi_Should_setCorrectApiUrl() { String apiClientUrl = this.userControllerApi.getApiClient().getBasePath(); assertThat(apiClientUrl, is(this.userServiceApiUrl));