Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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/'
Expand Down
13 changes: 7 additions & 6 deletions symphony-bdk-bom/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions symphony-bdk-config/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions symphony-bdk-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -387,6 +389,8 @@ private BdkConfig createRsaConfigDeprecatedPath(Supplier<String> 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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions symphony-bdk-examples/bdk-core-examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
2 changes: 1 addition & 1 deletion symphony-bdk-examples/bdk-spring-boot-example/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions symphony-bdk-http/symphony-bdk-http-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

1 change: 1 addition & 0 deletions symphony-bdk-http/symphony-bdk-http-jersey2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

1 change: 1 addition & 0 deletions symphony-bdk-http/symphony-bdk-http-webclient/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -32,7 +32,7 @@
})
public class CircleOfTrustServiceTest {

@MockBean
@MockitoBean
private ExtensionAppAuthenticator authenticator;

@Autowired
Expand Down
Loading
Loading