Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
update ssdk to 17 (#19)
Browse files Browse the repository at this point in the history
* update ssdk to 17

* update ssdk to 17
  • Loading branch information
afsinka-backbase authored Apr 8, 2024
1 parent f588431 commit 8e9f831
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jobs:
verify:
name: Maven Verify
uses: backbase/workflows/.github/workflows/maven-verify.yml@main
with:
java-version: "21"
secrets:
maven-username: ${{ secrets.REPO_USERNAME }}
maven-password: ${{ secrets.REPO_PASSWORD }}
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
uses: backbase/workflows/.github/workflows/maven-docker-release.yml@main
with:
version: ${GITHUB_REF##*v}
java-version: "21"
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}
maven-username: ${{ secrets.MAVEN_USERNAME }}
Expand Down
35 changes: 30 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<parent>
<groupId>com.backbase.buildingblocks</groupId>
<artifactId>service-sdk-starter-core</artifactId>
<version>16.1.5</version>
<version>17.0.0</version>
</parent>

<groupId>com.backbase.testing</groupId>
<artifactId>event-emitter</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.8.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Backbase :: Testing Components :: Events Emitter</name>

Expand All @@ -28,7 +28,7 @@
<pocket-tailor.version>0.5</pocket-tailor.version>
<audit-spec.version>7.0.0</audit-spec.version>

<java.version>17</java.version>
<java.version>21</java.version>
<api.target>${project.build.directory}/downloaded-api</api.target>
<specs.repo.url>https://repo.backbase.com/specs/</specs.repo.url>
<json-path-assert.version>2.2.0</json-path-assert.version>
Expand All @@ -43,8 +43,8 @@
<apache-commons-beanutils.version>1.9.4</apache-commons-beanutils.version>
<hamcrest-date.version>2.0.7</hamcrest-date.version>
<dbunit.version>2.6.0</dbunit.version>
<boat.version>0.17.20</boat.version>
<swagger-core-annotations.version>2.2.15</swagger-core-annotations.version>
<boat.version>0.17.30</boat.version>
<swagger-core-annotations.version>2.2.19</swagger-core-annotations.version>
<jackson-databind-nullable.version>0.2.1</jackson-databind-nullable.version>
<wagon.plugin.version>2.0.0</wagon.plugin.version>
<testcontainers.version>1.17.6</testcontainers.version>
Expand Down Expand Up @@ -478,6 +478,31 @@
</systemPropertyVariables>
</configuration>
</plugin>
<!--Below plugin is added as a temporary fix to solve events javaType issue; this can be removed once
actions-reactive-spec repo is migrated to SSDK 16x-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
<executions>
<execution>
<id>replace-javaType</id>
<goals>
<goal>run</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<target name="replace">
<replaceregexp
file="target/unpacked-specs/actions-reactive-spec/account-balance-changed-event.json"
match="&quot;javaType&quot;: &quot;java\.math\.BigDecimal&quot;"
replace="&quot;existingJavaType&quot;: &quot;java\.math\.BigDecimal&quot;"
flags="g"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
35 changes: 32 additions & 3 deletions src/main/java/com/backbase/eo/testing/events/EventEmitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,45 @@

package com.backbase.eo.testing.events;

import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;

import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;

// @checkstyle:off
@SpringBootApplication
public class EventEmitter {

public static void main(String[] args) throws Exception {
SpringApplication.run(EventEmitter.class, args);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(EventEmitter.class, args);
}

@Bean(name = {"objectMapper"})
@Primary
ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
ObjectMapper myObjectMapper = builder
.serializationInclusion(NON_NULL)
.failOnEmptyBeans(false)
.failOnUnknownProperties(false)
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.build();
/*
* Why is it disabled?
* BigDecimal fields in event definitions are serialized by com.backbase.buildingblocks.backend.api.BigDecimalJsonSerializer
* which causes "java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "result" is null"
* while trying to send messages with Spring Cloud Stream (SCS) because we deserialize requests coming from APIs
* and then serialize again while sending via SCS but SCS is using different serializers which create issues.
**/
myObjectMapper.disable(MapperFeature.USE_ANNOTATIONS);

return myObjectMapper;
}

}
// @checkstyle:on
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.backbase.buildingblocks.persistence.model.Event;
import com.backbase.buildingblocks.presentation.errors.BadRequestException;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.annotation.Nullable;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.BigInteger;
Expand All @@ -19,9 +20,8 @@
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import jakarta.annotation.Nullable;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.reflections.Reflections;
import org.springframework.http.MediaType;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
Expand All @@ -34,10 +34,11 @@

@RestController
@RequiredArgsConstructor
@Slf4j
public class EventEmittingController {

private final EventBus eventBus;
private final ObjectMapper mapper;
private final ObjectMapper objectMapper;

private static final int BATCH_SIZE = 10000;
private static final int USERS_COUNT = 20;
Expand Down Expand Up @@ -97,12 +98,12 @@ private EnvelopedEvent buildEventPayload(String eventId, String body, String req
.flatMap(clazz -> {
try {
if (body != null) {
return Optional.of(mapper.readValue(body, clazz));
return Optional.of(objectMapper.readValue(body, clazz));
} else {
return Optional.of(createAndFill(clazz));
}
} catch (Exception e) {
e.printStackTrace();
log.error("Serialize error", e);
return Optional.empty();
}
}).orElseThrow(() -> new BadRequestException("Unknown event"));
Expand Down

0 comments on commit 8e9f831

Please sign in to comment.