diff --git a/build.gradle b/build.gradle index 9726870b6..a7acfa671 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id "org.owasp.dependencycheck" version "9.0.9" } -ext.projectVersion = '3.1.3-SNAPSHOT' +ext.projectVersion = '3.2.0-SNAPSHOT' ext.isReleaseVersion = !ext.projectVersion.endsWith('SNAPSHOT') ext.mavenRepoUrl = project.properties['mavenRepoUrl'] ?: 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/' diff --git a/symphony-bdk-bom/build.gradle b/symphony-bdk-bom/build.gradle index 07171fcce..c2915df22 100644 --- a/symphony-bdk-bom/build.gradle +++ b/symphony-bdk-bom/build.gradle @@ -16,7 +16,7 @@ repositories { dependencies { // import Spring Boot's BOM - api platform('org.springframework.boot:spring-boot-dependencies:3.3.12') + api platform('org.springframework.boot:spring-boot-dependencies:3.5.4') // import Jackson's BOM api platform('com.fasterxml.jackson:jackson-bom:2.18.2') // import Jersey's BOM @@ -70,13 +70,14 @@ dependencies { api 'com.github.jknack:handlebars:4.3.1' api 'org.reflections:reflections:0.10.2' - api 'org.junit.jupiter:junit-jupiter:5.10.1' - api 'org.junit.jupiter:junit-jupiter-api:5.10.1' - api 'org.junit.jupiter:junit-jupiter-engine:5.10.1' + api "org.junit.jupiter:junit-jupiter:5.10.1" + api "org.junit.jupiter:junit-jupiter-api:5.10.1" + api "org.junit.jupiter:junit-jupiter-engine:5.10.1" + api "org.junit.platform:junit-platform-launcher:1.10.1" api 'com.tngtech.archunit:archunit-junit5:1.2.1' api 'org.mock-server:mockserver-netty:5.15.0' - api 'org.mockito:mockito-core:5.8.0' - api 'org.mockito:mockito-junit-jupiter:5.8.0' + api "org.mockito:mockito-core:5.11.0" + api "org.mockito:mockito-junit-jupiter:5.11.0" api 'org.assertj:assertj-core:3.24.2' api 'jakarta.ws.rs:jakarta.ws.rs-api:3.1.0' diff --git a/symphony-bdk-config/build.gradle b/symphony-bdk-config/build.gradle index 6b5534f8c..80d5914b6 100644 --- a/symphony-bdk-config/build.gradle +++ b/symphony-bdk-config/build.gradle @@ -24,4 +24,5 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter' testImplementation 'ch.qos.logback:logback-classic' testImplementation 'org.assertj:assertj-core' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } diff --git a/symphony-bdk-config/src/main/java/com/symphony/bdk/core/config/BdkConfigParser.java b/symphony-bdk-config/src/main/java/com/symphony/bdk/core/config/BdkConfigParser.java index 7fcce8a3f..0e754c433 100644 --- a/symphony-bdk-config/src/main/java/com/symphony/bdk/core/config/BdkConfigParser.java +++ b/symphony-bdk-config/src/main/java/com/symphony/bdk/core/config/BdkConfigParser.java @@ -46,14 +46,18 @@ public JsonNode parse(InputStream inputStream) throws BdkConfigException { } public JsonNode parseJsonNode(InputStream inputStream) throws BdkConfigException { - String content = new BufferedReader( - new InputStreamReader(inputStream, StandardCharsets.UTF_8)) - .lines() - .collect(Collectors.joining("\n")); + String content = ""; + try ( + InputStreamReader isr = new InputStreamReader(inputStream, StandardCharsets.UTF_8); + BufferedReader reader = new BufferedReader(isr)) { + content = reader.lines().collect(Collectors.joining("\n")); + } catch (IOException e) { + log.error("Error: {}", e.getMessage()); + } try { return JSON_MAPPER.readTree(content); } catch (IOException e) { - log.debug("Config file is not in JSON format, checking for YAML format."); + log.error("Error: {}", e.getMessage()); } try { diff --git a/symphony-bdk-config/src/test/java/com/symphony/bdk/core/config/BdkConfigLoaderTest.java b/symphony-bdk-config/src/test/java/com/symphony/bdk/core/config/BdkConfigLoaderTest.java index 76b1334a4..57f879b4e 100644 --- a/symphony-bdk-config/src/test/java/com/symphony/bdk/core/config/BdkConfigLoaderTest.java +++ b/symphony-bdk-config/src/test/java/com/symphony/bdk/core/config/BdkConfigLoaderTest.java @@ -16,6 +16,7 @@ import org.junit.jupiter.api.io.TempDir; import java.io.FileOutputStream; +import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; @@ -178,8 +179,12 @@ void testLoadConfigFromSymphonyDirectory() throws Exception { final String tmpConfigFileName = UUID.randomUUID().toString() + "-config.yaml"; final Path tmpConfigPath = Paths.get(System.getProperty("user.home"), ".symphony", tmpConfigFileName); FileUtils.forceMkdirParent(tmpConfigPath.toFile()); - final InputStream configInputStream = this.getClass().getResourceAsStream("/config/config.yaml"); - IOUtils.copy(configInputStream, new FileOutputStream(tmpConfigPath.toFile())); + try ( + InputStream configInputStream = this.getClass().getResourceAsStream("/config/config.yaml"); + OutputStream out = new FileOutputStream(tmpConfigPath.toFile()) + ) { + IOUtils.copy(configInputStream, out); + } final BdkConfig config = BdkConfigLoader.loadFromSymphonyDir(tmpConfigFileName); assertThat(config).isNotNull(); diff --git a/symphony-bdk-core/build.gradle b/symphony-bdk-core/build.gradle index b6b176bdf..759fdd14c 100644 --- a/symphony-bdk-core/build.gradle +++ b/symphony-bdk-core/build.gradle @@ -72,6 +72,7 @@ dependencies { testImplementation 'org.mockito:mockito-core' testImplementation 'org.mockito:mockito-junit-jupiter' testImplementation 'org.assertj:assertj-core' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } // OpenAPI code generation diff --git a/symphony-bdk-core/src/main/java/com/symphony/bdk/core/auth/AuthenticatorFactory.java b/symphony-bdk-core/src/main/java/com/symphony/bdk/core/auth/AuthenticatorFactory.java index e280f6957..7b862c7e7 100644 --- a/symphony-bdk-core/src/main/java/com/symphony/bdk/core/auth/AuthenticatorFactory.java +++ b/symphony-bdk-core/src/main/java/com/symphony/bdk/core/auth/AuthenticatorFactory.java @@ -225,10 +225,13 @@ private static String loadPrivateKey(String privateKeyPath) throws IOException, throw new AuthInitializationException( "Unable to find RSA private key as classpath resource from: " + privateKeyPath); } + try (InputStream resourceStream = is) { + return IOUtils.toString(resourceStream, StandardCharsets.UTF_8); + } } else { - is = new FileInputStream(privateKeyPath); + try (InputStream fileStream = new FileInputStream(privateKeyPath)) { + return IOUtils.toString(fileStream, StandardCharsets.UTF_8); + } } - - return IOUtils.toString(is, StandardCharsets.UTF_8); } } diff --git a/symphony-bdk-core/src/test/java/com/symphony/bdk/core/auth/AuthenticatorFactoryTest.java b/symphony-bdk-core/src/test/java/com/symphony/bdk/core/auth/AuthenticatorFactoryTest.java index bafcc28e7..aadf71907 100644 --- a/symphony-bdk-core/src/test/java/com/symphony/bdk/core/auth/AuthenticatorFactoryTest.java +++ b/symphony-bdk-core/src/test/java/com/symphony/bdk/core/auth/AuthenticatorFactoryTest.java @@ -28,6 +28,8 @@ import org.junit.jupiter.api.io.TempDir; import java.io.FileOutputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.util.UUID; import java.util.function.Supplier; @@ -387,6 +389,8 @@ private BdkConfig createRsaConfigDeprecatedPath(Supplier privateKeyPathS @SneakyThrows private static void writeContentToPath(String content, Path path) { - IOUtils.write(content, new FileOutputStream(path.toFile()), "utf-8"); + try (OutputStream out = new FileOutputStream(path.toFile())) { + IOUtils.write(content, out, StandardCharsets.UTF_8); + } } } diff --git a/symphony-bdk-core/src/test/java/com/symphony/bdk/core/service/message/MessageServiceTest.java b/symphony-bdk-core/src/test/java/com/symphony/bdk/core/service/message/MessageServiceTest.java index 5edbf0b21..7e3eb4bbd 100644 --- a/symphony-bdk-core/src/test/java/com/symphony/bdk/core/service/message/MessageServiceTest.java +++ b/symphony-bdk-core/src/test/java/com/symphony/bdk/core/service/message/MessageServiceTest.java @@ -60,6 +60,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.time.Instant; @@ -183,7 +184,6 @@ void testGetMessages() throws IOException { messages.stream().map(V4Message::getMessageId).collect(Collectors.toList())); } - @Test void testSearchMessages() throws IOException { mockApiClient.onPost(V4_SEARCH_MESSAGES, @@ -238,71 +238,83 @@ void testSendWithStreamObjectCallsSendWithStreamId() { @Test void testSendPassingMessageInstanceToStreamId(@TempDir Path tmpDir) throws IOException { Path tempFilePath = tmpDir.resolve("tempFile"); - IOUtils.write("test", new FileOutputStream(tempFilePath.toFile()), StandardCharsets.UTF_8); + try (OutputStream out = new FileOutputStream(tempFilePath.toFile())) { + IOUtils.write("test", out, StandardCharsets.UTF_8); + } + mockApiClient.onPost(V4_STREAM_MESSAGE_CREATE.replace("{sid}", STREAM_ID), JsonHelper.readFromClasspath("/message/send_message.json")); - InputStream inputStream = new FileInputStream(tempFilePath.toString()); - Message message = Message.builder() - .content(MESSAGE) - .addAttachment(inputStream, "test.png") - .build(); + try (InputStream inputStream = new FileInputStream(tempFilePath.toString())) { + Message message = Message.builder() + .content(MESSAGE) + .addAttachment(inputStream, "test.png") + .build(); - final V4Message sentMessage = messageService.send(STREAM_ID, message); + final V4Message sentMessage = messageService.send(STREAM_ID, message); - assertEquals(MESSAGE_ID, sentMessage.getMessageId()); - assertEquals("gXFV8vN37dNqjojYS_y2wX___o2KxfmUdA", sentMessage.getStream().getStreamId()); + assertEquals(MESSAGE_ID, sentMessage.getMessageId()); + assertEquals("gXFV8vN37dNqjojYS_y2wX___o2KxfmUdA", sentMessage.getStream().getStreamId()); + } } @Test void testSendPassingMessageInstanceToStream(@TempDir Path tmpDir) throws IOException { Path tempFilePath = tmpDir.resolve("tempFile"); - IOUtils.write("test", new FileOutputStream(tempFilePath.toFile()), StandardCharsets.UTF_8); + try (OutputStream out = new FileOutputStream(tempFilePath.toFile())) { + IOUtils.write("test", out, StandardCharsets.UTF_8); + } mockApiClient.onPost(V4_STREAM_MESSAGE_CREATE.replace("{sid}", STREAM_ID), JsonHelper.readFromClasspath("/message/send_message.json")); - InputStream inputStream = new FileInputStream(tempFilePath.toString()); - Message message = Message.builder() - .content(MESSAGE) - .addAttachment(inputStream, "test.png") - .build(); + try (InputStream inputStream = new FileInputStream(tempFilePath.toString())) { + Message message = Message.builder() + .content(MESSAGE) + .addAttachment(inputStream, "test.png") + .build(); - final V4Message sentMessage = messageService.send(new V4Stream().streamId(STREAM_ID), message); + final V4Message sentMessage = messageService.send(new V4Stream().streamId(STREAM_ID), message); - assertEquals(MESSAGE_ID, sentMessage.getMessageId()); - assertEquals("gXFV8vN37dNqjojYS_y2wX___o2KxfmUdA", sentMessage.getStream().getStreamId()); + assertEquals(MESSAGE_ID, sentMessage.getMessageId()); + assertEquals("gXFV8vN37dNqjojYS_y2wX___o2KxfmUdA", sentMessage.getStream().getStreamId()); + } } @Test void testSendPassingMessageInstanceToStreamWrongAttachmentName(@TempDir Path tmpDir) throws IOException { Path tempFilePath = tmpDir.resolve("tempFile"); - IOUtils.write("test", new FileOutputStream(tempFilePath.toFile()), StandardCharsets.UTF_8); + try (OutputStream out = new FileOutputStream(tempFilePath.toFile())) { + IOUtils.write("test", out, StandardCharsets.UTF_8); + } mockApiClient.onPost(V4_STREAM_MESSAGE_CREATE.replace("{sid}", STREAM_ID), JsonHelper.readFromClasspath("/message/send_message.json")); - InputStream inputStream = new FileInputStream(tempFilePath.toString()); - - assertThrows(MessageCreationException.class, - () -> { - final Message message = Message.builder() - .content(MESSAGE) - .addAttachment(inputStream, "wrong-name") - .build(); - messageService.send(new V4Stream().streamId(STREAM_ID), message); - }); + try (InputStream inputStream = new FileInputStream(tempFilePath.toString())) { + assertThrows(MessageCreationException.class, + () -> { + final Message message = Message.builder() + .content(MESSAGE) + .addAttachment(inputStream, "wrong-name") + .build(); + messageService.send(new V4Stream().streamId(STREAM_ID), message); + }); + } } @Test void testMessageCreationFailed(@TempDir Path tmpDir) throws IOException { Path tempFilePath = tmpDir.resolve("tempFile"); - IOUtils.write("test", new FileOutputStream(tempFilePath.toFile()), StandardCharsets.UTF_8); + try (OutputStream out = new FileOutputStream(tempFilePath.toFile())) { + IOUtils.write("test", out, StandardCharsets.UTF_8); + } - InputStream inputStream = new FileInputStream(tempFilePath.toString()); - assertThrows(MessageCreationException.class, - () -> Message.builder() - .content(MESSAGE) - .addAttachment(inputStream, "test.png") - .data(new MockObject("wrong object")).build()); + try (InputStream inputStream = new FileInputStream(tempFilePath.toString())) { + assertThrows(MessageCreationException.class, + () -> Message.builder() + .content(MESSAGE) + .addAttachment(inputStream, "test.png") + .data(new MockObject("wrong object")).build()); + } } @Test diff --git a/symphony-bdk-examples/bdk-core-examples/build.gradle b/symphony-bdk-examples/bdk-core-examples/build.gradle index a56f64686..463082d86 100644 --- a/symphony-bdk-examples/bdk-core-examples/build.gradle +++ b/symphony-bdk-examples/bdk-core-examples/build.gradle @@ -26,4 +26,6 @@ dependencies { compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.junit.jupiter:junit-jupiter' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } diff --git a/symphony-bdk-examples/bdk-spring-boot-example/build.gradle b/symphony-bdk-examples/bdk-spring-boot-example/build.gradle index 74036681e..0e258991c 100644 --- a/symphony-bdk-examples/bdk-spring-boot-example/build.gradle +++ b/symphony-bdk-examples/bdk-spring-boot-example/build.gradle @@ -1,6 +1,6 @@ plugins { id 'bdk.java-common-conventions' - id 'org.springframework.boot' version "3.2.2" + id 'org.springframework.boot' version "3.5.4" } description = 'Symphony Java BDK Examples for the SpringBoot integration' diff --git a/symphony-bdk-examples/bdk-spring-boot-example/src/test/java/com/symphony/bdk/examples/spring/SampleSpringAppIntegrationTest.java b/symphony-bdk-examples/bdk-spring-boot-example/src/test/java/com/symphony/bdk/examples/spring/SampleSpringAppIntegrationTest.java index efc2cbcdb..9e17ffc55 100644 --- a/symphony-bdk-examples/bdk-spring-boot-example/src/test/java/com/symphony/bdk/examples/spring/SampleSpringAppIntegrationTest.java +++ b/symphony-bdk-examples/bdk-spring-boot-example/src/test/java/com/symphony/bdk/examples/spring/SampleSpringAppIntegrationTest.java @@ -28,7 +28,7 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import java.time.Instant; import java.util.HashMap; @@ -39,7 +39,7 @@ public class SampleSpringAppIntegrationTest { private final V4User initiator = new V4User().displayName("user").userId(2L); private final V4Stream stream = new V4Stream().streamId("my-room"); - @MockBean SymphonyGroupService symphonyGroupService; + @MockitoBean SymphonyGroupService symphonyGroupService; @Test @DisplayName("Reply message upon received echo command") diff --git a/symphony-bdk-extensions/symphony-group-extension/build.gradle b/symphony-bdk-extensions/symphony-group-extension/build.gradle index 970568385..fe4fab8a4 100644 --- a/symphony-bdk-extensions/symphony-group-extension/build.gradle +++ b/symphony-bdk-extensions/symphony-group-extension/build.gradle @@ -24,6 +24,7 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter' testImplementation 'org.mockito:mockito-core' testImplementation 'com.tngtech.archunit:archunit-junit5' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } def baseSpecsUrl = 'https://raw.githubusercontent.com/finos/symphony-api-spec/af73762a33357436edacca0b198cc18192e96606/profile-manager' diff --git a/symphony-bdk-http/symphony-bdk-http-api/build.gradle b/symphony-bdk-http/symphony-bdk-http-api/build.gradle index 4baeb308b..ffd9540a4 100644 --- a/symphony-bdk-http/symphony-bdk-http-api/build.gradle +++ b/symphony-bdk-http/symphony-bdk-http-api/build.gradle @@ -18,5 +18,6 @@ dependencies { testImplementation 'ch.qos.logback:logback-classic' testImplementation 'org.mockito:mockito-core' testImplementation 'org.mockito:mockito-junit-jupiter' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } diff --git a/symphony-bdk-http/symphony-bdk-http-jersey2/build.gradle b/symphony-bdk-http/symphony-bdk-http-jersey2/build.gradle index bd2e9bc20..2ea028923 100644 --- a/symphony-bdk-http/symphony-bdk-http-jersey2/build.gradle +++ b/symphony-bdk-http/symphony-bdk-http-jersey2/build.gradle @@ -40,5 +40,6 @@ dependencies { testImplementation 'org.mock-server:mockserver-netty' testImplementation 'org.mockito:mockito-core' testImplementation 'org.mockito:mockito-junit-jupiter' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } diff --git a/symphony-bdk-http/symphony-bdk-http-webclient/build.gradle b/symphony-bdk-http/symphony-bdk-http-webclient/build.gradle index b93871376..b121e5a23 100644 --- a/symphony-bdk-http/symphony-bdk-http-webclient/build.gradle +++ b/symphony-bdk-http/symphony-bdk-http-webclient/build.gradle @@ -35,4 +35,5 @@ dependencies { testImplementation 'org.mock-server:mockserver-netty' testImplementation 'org.mockito:mockito-core' testImplementation 'org.mockito:mockito-junit-jupiter' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } diff --git a/symphony-bdk-http/symphony-bdk-http-webclient/src/test/java/com/symphony/bdk/http/webclient/ApiClientWebClientTest.java b/symphony-bdk-http/symphony-bdk-http-webclient/src/test/java/com/symphony/bdk/http/webclient/ApiClientWebClientTest.java index 028f3e42e..69e36857f 100644 --- a/symphony-bdk-http/symphony-bdk-http-webclient/src/test/java/com/symphony/bdk/http/webclient/ApiClientWebClientTest.java +++ b/symphony-bdk-http/symphony-bdk-http-webclient/src/test/java/com/symphony/bdk/http/webclient/ApiClientWebClientTest.java @@ -234,7 +234,7 @@ void testInvokeApiWithFormParamTest(final BdkMockServer mockServer) throws ApiEx .withMethod("POST") .withPath("/test-api") .withHeader( - Header.header("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8") + Header.header("Content-Type", "application/x-www-form-urlencoded") ) .withBody(ParameterBody.params( Parameter.param("param-1", "test-1"), diff --git a/symphony-bdk-spring/symphony-bdk-app-spring-boot-starter/build.gradle b/symphony-bdk-spring/symphony-bdk-app-spring-boot-starter/build.gradle index 3ebfa9b37..54837378b 100644 --- a/symphony-bdk-spring/symphony-bdk-app-spring-boot-starter/build.gradle +++ b/symphony-bdk-spring/symphony-bdk-app-spring-boot-starter/build.gradle @@ -38,6 +38,9 @@ dependencies { testCompileOnly 'org.projectlombok:lombok' testAnnotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.junit.jupiter:junit-jupiter' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + testImplementation project(':symphony-bdk-core').sourceSets.test.output testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' diff --git a/symphony-bdk-spring/symphony-bdk-app-spring-boot-starter/src/test/java/com/symphony/bdk/app/spring/auth/CircleOfTrustControllerTest.java b/symphony-bdk-spring/symphony-bdk-app-spring-boot-starter/src/test/java/com/symphony/bdk/app/spring/auth/CircleOfTrustControllerTest.java index 2cad06c8f..06c9d71be 100644 --- a/symphony-bdk-spring/symphony-bdk-app-spring-boot-starter/src/test/java/com/symphony/bdk/app/spring/auth/CircleOfTrustControllerTest.java +++ b/symphony-bdk-spring/symphony-bdk-app-spring-boot-starter/src/test/java/com/symphony/bdk/app/spring/auth/CircleOfTrustControllerTest.java @@ -23,11 +23,11 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.mock.web.MockCookie; import org.springframework.mock.web.MockHttpServletResponse; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.web.servlet.MockMvc; @WebMvcTest(CircleOfTrustController.class) @@ -39,13 +39,13 @@ public class CircleOfTrustControllerTest { @Autowired private MockMvc mockMvc; - @MockBean + @MockitoBean private SymphonyBdkCoreProperties coreProperties; - @MockBean + @MockitoBean private SymphonyBdkAppProperties appProperties; - @MockBean + @MockitoBean private CircleOfTrustService service; @BeforeEach diff --git a/symphony-bdk-spring/symphony-bdk-app-spring-boot-starter/src/test/java/com/symphony/bdk/app/spring/auth/service/CircleOfTrustServiceTest.java b/symphony-bdk-spring/symphony-bdk-app-spring-boot-starter/src/test/java/com/symphony/bdk/app/spring/auth/service/CircleOfTrustServiceTest.java index dc427fbfb..c7e769f53 100644 --- a/symphony-bdk-spring/symphony-bdk-app-spring-boot-starter/src/test/java/com/symphony/bdk/app/spring/auth/service/CircleOfTrustServiceTest.java +++ b/symphony-bdk-spring/symphony-bdk-app-spring-boot-starter/src/test/java/com/symphony/bdk/app/spring/auth/service/CircleOfTrustServiceTest.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) @@ -32,7 +32,7 @@ }) public class CircleOfTrustServiceTest { - @MockBean + @MockitoBean private ExtensionAppAuthenticator authenticator; @Autowired diff --git a/symphony-bdk-spring/symphony-bdk-core-spring-boot-starter/build.gradle b/symphony-bdk-spring/symphony-bdk-core-spring-boot-starter/build.gradle index 2adf59b3d..1b3fdb203 100644 --- a/symphony-bdk-spring/symphony-bdk-core-spring-boot-starter/build.gradle +++ b/symphony-bdk-spring/symphony-bdk-core-spring-boot-starter/build.gradle @@ -42,10 +42,13 @@ dependencies { testCompileOnly 'org.projectlombok:lombok' testAnnotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.junit.jupiter:junit-jupiter' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' testImplementation project(':symphony-bdk-core').sourceSets.test.output testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' + exclude group: 'junit', module: 'junit' } } diff --git a/symphony-bdk-spring/symphony-bdk-core-spring-boot-starter/src/test/java/com/symphony/bdk/spring/events/RealTimeEventListenerAsyncTest.java b/symphony-bdk-spring/symphony-bdk-core-spring-boot-starter/src/test/java/com/symphony/bdk/spring/events/RealTimeEventListenerAsyncTest.java index 1b3d47652..a669ef945 100644 --- a/symphony-bdk-spring/symphony-bdk-core-spring-boot-starter/src/test/java/com/symphony/bdk/spring/events/RealTimeEventListenerAsyncTest.java +++ b/symphony-bdk-spring/symphony-bdk-core-spring-boot-starter/src/test/java/com/symphony/bdk/spring/events/RealTimeEventListenerAsyncTest.java @@ -26,6 +26,7 @@ import org.springframework.context.event.SimpleApplicationEventMulticaster; import org.springframework.core.task.SimpleAsyncTaskExecutor; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.util.ErrorHandler; @@ -36,7 +37,7 @@ public class RealTimeEventListenerAsyncTest { @Autowired private ApplicationEventPublisher publisher; - @SpyBean + @MockitoSpyBean private RealTimeEventsAsyncTestListener eventListener; private RealTimeEventsDispatcher dispatcher; diff --git a/symphony-bdk-spring/symphony-bdk-core-spring-boot-starter/src/test/java/com/symphony/bdk/spring/events/RealTimeEventListenerTest.java b/symphony-bdk-spring/symphony-bdk-core-spring-boot-starter/src/test/java/com/symphony/bdk/spring/events/RealTimeEventListenerTest.java index 863d944f4..5c509125a 100644 --- a/symphony-bdk-spring/symphony-bdk-core-spring-boot-starter/src/test/java/com/symphony/bdk/spring/events/RealTimeEventListenerTest.java +++ b/symphony-bdk-spring/symphony-bdk-core-spring-boot-starter/src/test/java/com/symphony/bdk/spring/events/RealTimeEventListenerTest.java @@ -28,6 +28,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.SpyBean; import org.springframework.context.ApplicationEventPublisher; +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean; import org.springframework.test.context.junit.jupiter.SpringExtension; @SpringBootTest(classes = RealTimeEventsTestListener.class) @@ -37,7 +38,7 @@ public class RealTimeEventListenerTest { @Autowired private ApplicationEventPublisher publisher; - @SpyBean + @MockitoSpyBean private RealTimeEventsTestListener eventListener; private RealTimeEventsDispatcher dispatcher; diff --git a/symphony-bdk-spring/symphony-bdk-core-spring-boot-starter/src/test/java/com/symphony/bdk/spring/events/RealTimeEventsDispatcherTest.java b/symphony-bdk-spring/symphony-bdk-core-spring-boot-starter/src/test/java/com/symphony/bdk/spring/events/RealTimeEventsDispatcherTest.java index 1342eddb3..be00406e8 100644 --- a/symphony-bdk-spring/symphony-bdk-core-spring-boot-starter/src/test/java/com/symphony/bdk/spring/events/RealTimeEventsDispatcherTest.java +++ b/symphony-bdk-spring/symphony-bdk-core-spring-boot-starter/src/test/java/com/symphony/bdk/spring/events/RealTimeEventsDispatcherTest.java @@ -30,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean; import org.springframework.test.context.junit.jupiter.SpringExtension; @SpringBootTest @@ -39,7 +40,7 @@ class RealTimeEventsDispatcherTest { @Autowired private RealTimeEventsDispatcher dispatcher; - @SpyBean + @MockitoSpyBean private RealTimeEventListener listener; @Test diff --git a/symphony-bdk-template/symphony-bdk-template-api/build.gradle b/symphony-bdk-template/symphony-bdk-template-api/build.gradle index 7c1818ff4..87c7d2e0d 100644 --- a/symphony-bdk-template/symphony-bdk-template-api/build.gradle +++ b/symphony-bdk-template/symphony-bdk-template-api/build.gradle @@ -18,5 +18,6 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter' testImplementation 'org.mockito:mockito-core' testImplementation 'org.mockito:mockito-junit-jupiter' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } diff --git a/symphony-bdk-template/symphony-bdk-template-freemarker/build.gradle b/symphony-bdk-template/symphony-bdk-template-freemarker/build.gradle index ec3d777f5..168a2160e 100644 --- a/symphony-bdk-template/symphony-bdk-template-freemarker/build.gradle +++ b/symphony-bdk-template/symphony-bdk-template-freemarker/build.gradle @@ -13,5 +13,6 @@ dependencies { implementation 'commons-io:commons-io' testImplementation 'org.junit.jupiter:junit-jupiter' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } diff --git a/symphony-bdk-template/symphony-bdk-template-freemarker/src/test/java/com/symphony/bdk/template/freemarker/FreeMarkerTemplateTest.java b/symphony-bdk-template/symphony-bdk-template-freemarker/src/test/java/com/symphony/bdk/template/freemarker/FreeMarkerTemplateTest.java index 5496de45e..0bcf74de3 100644 --- a/symphony-bdk-template/symphony-bdk-template-freemarker/src/test/java/com/symphony/bdk/template/freemarker/FreeMarkerTemplateTest.java +++ b/symphony-bdk-template/symphony-bdk-template-freemarker/src/test/java/com/symphony/bdk/template/freemarker/FreeMarkerTemplateTest.java @@ -116,7 +116,7 @@ private void assertTemplateProducesOutput(Template freeMarkerTemplate) { private void assertTemplateProducesOutput(Template freeMarkerTemplate, Object parameters, String expectedOutput) { assertEquals(FreeMarkerTemplate.class, freeMarkerTemplate.getClass()); - assertEquals(expectedOutput, freeMarkerTemplate.process(parameters)); + assertEquals(expectedOutput.replace("\r\n", "\n"), freeMarkerTemplate.process(parameters).replace("\r\n", "\n")); } public static class Class1 { diff --git a/symphony-bdk-template/symphony-bdk-template-handlebars/build.gradle b/symphony-bdk-template/symphony-bdk-template-handlebars/build.gradle index e1bef5f63..09df2965d 100644 --- a/symphony-bdk-template/symphony-bdk-template-handlebars/build.gradle +++ b/symphony-bdk-template/symphony-bdk-template-handlebars/build.gradle @@ -15,4 +15,5 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter' testImplementation 'ch.qos.logback:logback-classic' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } diff --git a/symphony-bdk-template/symphony-bdk-template-handlebars/src/test/java/com/symphony/bdk/template/handlebars/HandlebarsEngineTest.java b/symphony-bdk-template/symphony-bdk-template-handlebars/src/test/java/com/symphony/bdk/template/handlebars/HandlebarsEngineTest.java index ff85c5a37..84d7687fb 100644 --- a/symphony-bdk-template/symphony-bdk-template-handlebars/src/test/java/com/symphony/bdk/template/handlebars/HandlebarsEngineTest.java +++ b/symphony-bdk-template/symphony-bdk-template-handlebars/src/test/java/com/symphony/bdk/template/handlebars/HandlebarsEngineTest.java @@ -28,7 +28,7 @@ void init() { void should_load_template_from_classpath() { final Template template = this.engine.newTemplateFromClasspath("/test.hbs"); final String content = template.process(Collections.singletonMap("message", "hello")); - assertEquals(EXPECTED_TEST_HBS, content); + assertEquals(EXPECTED_TEST_HBS, content.replace("\r\n", "\n")); } @Test @@ -46,7 +46,7 @@ void should_load_template_from_file(@TempDir Path tempDir) throws Exception { final Template template = this.engine.newTemplateFromFile(tempDir.resolve("test.hbs").toAbsolutePath().toString()); final String content = template.process(Collections.singletonMap("message", "hello")); - assertEquals(EXPECTED_TEST_HBS, content); + assertEquals(EXPECTED_TEST_HBS, content.replace("\r\n", "\n")); } @Test diff --git a/symphony-bdk-test/symphony-bdk-test-jupiter/build.gradle b/symphony-bdk-test/symphony-bdk-test-jupiter/build.gradle index 5789622ba..592b295b1 100644 --- a/symphony-bdk-test/symphony-bdk-test-jupiter/build.gradle +++ b/symphony-bdk-test/symphony-bdk-test-jupiter/build.gradle @@ -16,7 +16,7 @@ dependencies { api 'org.mockito:mockito-core' api 'org.mockito:mockito-junit-jupiter' api 'org.assertj:assertj-core' - + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' } diff --git a/symphony-bdk-test/symphony-bdk-test-spring-boot/build.gradle b/symphony-bdk-test/symphony-bdk-test-spring-boot/build.gradle index db5abadf7..42d2debfd 100644 --- a/symphony-bdk-test/symphony-bdk-test-spring-boot/build.gradle +++ b/symphony-bdk-test/symphony-bdk-test-spring-boot/build.gradle @@ -20,5 +20,6 @@ dependencies { api ('org.springframework.boot:spring-boot-starter-test') { exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' exclude group: 'junit', module: 'junit' + exclude group: 'org.mockito' } }