Skip to content

Commit

Permalink
Merge branch 'release/0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jangalinski committed Apr 27, 2023
2 parents 070658b + f8bc2bc commit a2e0eb8
Show file tree
Hide file tree
Showing 17 changed files with 180 additions and 61 deletions.
16 changes: 16 additions & 0 deletions .github/release-notes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


changelog:
sections:
- title: ":rocket: Enhancements & Features"
labels: [ "Type: enhancement", "Type: documentation", "Type: example" ]
- title: ":bug: Bug Fixes"
labels: [ "Type: bug" ]
- title: ":hammer_and_wrench: Chore"
labels: [ "Type: dependencies", "Type: build", "Type: codacy" ]
issues:
exclude:
labels: [ "Type: question" ]
contributors:
exclude:
names: [ "dependabot[bot]" ]
47 changes: 33 additions & 14 deletions .github/workflows/release-notes.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
changelog:
sections:
- title: ":rocket: Enhancements & Features"
labels: [ "Type: enhancement", "Type: documentation", "Type: example" ]
- title: ":bug: Bug Fixes"
labels: [ "Type: bug" ]
- title: ":hammer_and_wrench: Chore"
labels: [ "Type: dependencies", "Type: build", "Type: codacy" ]
issues:
exclude:
labels: [ "Type: question" ]
contributors:
exclude:
names: [ "dependabot[bot]" ]
# Trigger the workflow on milestone events
on:
milestone:
types: [closed]
name: Milestone Closure
jobs:
create-release-notes:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Create Release Notes Markdown
uses: docker://decathlon/release-notes-generator-action:3.1.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
OUTPUT_FOLDER: temp_release_notes
USE_MILESTONE_TITLE: "true"
- name: Get the name of the created Release Notes file and extract Version
run: |
RELEASE_NOTES_FILE=$(ls temp_release_notes/*.md | head -n 1)
echo "RELEASE_NOTES_FILE=$RELEASE_NOTES_FILE" >> $GITHUB_ENV
VERSION=$(echo ${{ github.event.milestone.title }} | cut -d' ' -f2)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Create a Draft Release Notes on GitHub
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ env.VERSION }}
release_name: ${{ env.VERSION }}
body_path: ${{ env.RELEASE_NOTES_FILE }}
draft: true
10 changes: 5 additions & 5 deletions examples/bankaccount-jgiven-junit4/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holixon.axon.testing._</groupId>
<artifactId>examples</artifactId>
<version>0.3.0</version>
<version>0.4.0</version>
</parent>

<groupId>io.holixon.axon.testing.examples</groupId>
Expand All @@ -27,7 +27,7 @@
<dependency>
<groupId>io.toolisticon.testing</groupId>
<artifactId>jgiven-kotlin</artifactId>
<version>1.2.4.0</version>
<version>1.2.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -38,19 +38,19 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.6</version>
<version>2.0.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.1</version>
<version>3.24.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.11.0</version>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
8 changes: 4 additions & 4 deletions examples/bankaccount-jgiven-junit5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holixon.axon.testing._</groupId>
<artifactId>examples</artifactId>
<version>0.3.0</version>
<version>0.4.0</version>
</parent>

<groupId>io.holixon.axon.testing.examples</groupId>
Expand All @@ -29,7 +29,7 @@
<dependency>
<groupId>io.toolisticon.testing</groupId>
<artifactId>jgiven-kotlin</artifactId>
<version>1.2.4.0</version>
<version>1.2.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -40,13 +40,13 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.6</version>
<version>2.0.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.1</version>
<version>3.24.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holixon.axon.testing._</groupId>
<artifactId>axon-testing_</artifactId>
<version>0.3.0</version>
<version>0.4.0</version>
</parent>

<artifactId>examples</artifactId>
Expand Down
6 changes: 3 additions & 3 deletions extension/jgiven/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.holixon.axon.testing._</groupId>
<artifactId>extension-jgiven</artifactId>
<version>0.3.0</version>
<version>0.4.0</version>
</parent>

<groupId>io.holixon.axon.testing</groupId>
Expand Down Expand Up @@ -40,7 +40,7 @@
<dependency>
<groupId>io.github.microutils</groupId>
<artifactId>kotlin-logging-jvm</artifactId>
<version>3.0.4</version>
<version>3.0.5</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -66,7 +66,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.4.5</version>
<version>1.4.7</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion extension/jgiven/junit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.holixon.axon.testing._</groupId>
<artifactId>extension-jgiven</artifactId>
<version>0.3.0</version>
<version>0.4.0</version>
</parent>

<groupId>io.holixon.axon.testing</groupId>
Expand Down
6 changes: 3 additions & 3 deletions extension/jgiven/junit5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.holixon.axon.testing._</groupId>
<artifactId>extension-jgiven</artifactId>
<version>0.3.0</version>
<version>0.4.0</version>
</parent>

<groupId>io.holixon.axon.testing</groupId>
Expand All @@ -27,7 +27,7 @@
<dependency>
<groupId>io.toolisticon.testing</groupId>
<artifactId>jgiven-kotlin</artifactId>
<version>1.2.4.0</version>
<version>1.2.5.0</version>
<scope>test</scope>
</dependency>

Expand All @@ -40,7 +40,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.4.5</version>
<version>1.4.7</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion extension/jgiven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holixon.axon.testing._</groupId>
<artifactId>extension</artifactId>
<version>0.3.0</version>
<version>0.4.0</version>
</parent>

<artifactId>extension-jgiven</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holixon.axon.testing._</groupId>
<artifactId>axon-testing_</artifactId>
<version>0.3.0</version>
<version>0.4.0</version>
</parent>

<artifactId>extension</artifactId>
Expand Down
8 changes: 4 additions & 4 deletions extension/upcaster-test-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.holixon.axon.testing._</groupId>
<artifactId>extension</artifactId>
<version>0.3.0</version>
<version>0.4.0</version>
</parent>

<groupId>io.holixon.axon.testing</groupId>
Expand All @@ -30,6 +30,7 @@
<groupId>org.axonframework</groupId>
<artifactId>axon-test</artifactId>
</dependency>

<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
Expand Down Expand Up @@ -70,9 +71,8 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.6</version>
<scope>test</scope>
<version>2.0.7</version>
</dependency>


</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package io.holixon.axon.testing.upcaster

import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.initialEvent
import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.jsonTestEventData
import org.assertj.core.api.Assertions.assertThat
import org.axonframework.serialization.Revision
import org.axonframework.serialization.SerializedObject
import org.axonframework.serialization.SimpleSerializedType
import org.axonframework.serialization.json.JacksonSerializer
import org.axonframework.serialization.upcasting.event.EventUpcasterChain
import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation
import org.axonframework.serialization.upcasting.event.SingleEventUpcaster
import org.junit.jupiter.api.Test
import kotlin.streams.toList

/**
* Let's assume we had a revision "0" of accountCreated which had different field names and one missing required field.
*/
class AccountCreatedV0V1UpcasterTest {
private val om = jacksonObjectMapper()
private val jsonSerializer = JacksonSerializer.builder().objectMapper(om).build()

@Test
fun `upcast v0 to v1`() {
// GIVEN: a new event with accountId and required field maximalBalance
@Revision("1")
data class AccountCreatedEvent(
val accountId: String,
val customerId: String,
val initialBalance: Int,
val maximalBalance: Int
)

val payloadType = AccountCreatedEvent::class.java.name
val targetRevision = AccountCreatedEvent::class.java.getAnnotation(Revision::class.java).value

// AND GIVEN: an old event with revision "0" with bankAccountId (has to be renamed to accountId), and maximalBalance is missing!
val eventData = jsonTestEventData(
payloadJson = """{"bankAccountId":"1","customerId":"3","initialBalance":0}""",
payloadTypeName = payloadType,
revisionNumber = "0"
)

// AND an upcaster we wrote for this usecase
val upcaster = upcaster(payloadType = payloadType, sourceRevision = eventData.payload.type.revision, targetRevision = targetRevision) {
(it as ObjectNode).apply {
put("accountId", get("bankAccountId").asText())
remove("bankAccountId")
put("maximalBalance", 1000)
}
}

// WHEN we run the upcaster chain on a stream with a single event
val serializedResult: SerializedObject<*> = EventUpcasterChain(upcaster)
.upcast(initialEvent(entry = eventData, serializer = jsonSerializer))
.toList()
.first().data

// AND deserialize to target data class
val revision1data: AccountCreatedEvent = jsonSerializer.deserialize(serializedResult)

// THEN the fields are renamed and set
assertThat(revision1data.accountId).isEqualTo("1")
assertThat(revision1data.customerId).isEqualTo("3")
assertThat(revision1data.initialBalance).isEqualTo(0)
assertThat(revision1data.maximalBalance).isEqualTo(1000)
}

private fun upcaster(payloadType: String, sourceRevision: String, targetRevision: String, upcastFunction: (JsonNode) -> JsonNode) =
object : SingleEventUpcaster() {
override fun canUpcast(representation: IntermediateEventRepresentation): Boolean =
representation.type.name == payloadType && representation.type.revision == sourceRevision

override fun doUpcast(intermediateRepresentation: IntermediateEventRepresentation): IntermediateEventRepresentation =
intermediateRepresentation.upcastPayload(
SimpleSerializedType(payloadType, targetRevision),
JsonNode::class.java,
upcastFunction
)
}
}
2 changes: 1 addition & 1 deletion lib/fixtures/bankaccount/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holixon.axon.testing._</groupId>
<artifactId>fixtures</artifactId>
<version>0.3.0</version>
<version>0.4.0</version>
</parent>

<groupId>io.holixon.axon.testing.lib</groupId>
Expand Down
2 changes: 1 addition & 1 deletion lib/fixtures/giftcard/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holixon.axon.testing._</groupId>
<artifactId>fixtures</artifactId>
<version>0.3.0</version>
<version>0.4.0</version>
</parent>

<groupId>io.holixon.axon.testing.lib</groupId>
Expand Down
4 changes: 2 additions & 2 deletions lib/fixtures/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holixon.axon.testing._</groupId>
<artifactId>lib</artifactId>
<version>0.3.0</version>
<version>0.4.0</version>
</parent>

<artifactId>fixtures</artifactId>
Expand Down Expand Up @@ -38,7 +38,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<version>1.18.26</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holixon.axon.testing._</groupId>
<artifactId>axon-testing_</artifactId>
<version>0.3.0</version>
<version>0.4.0</version>
</parent>

<artifactId>lib</artifactId>
Expand Down
Loading

0 comments on commit a2e0eb8

Please sign in to comment.