Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

# Axon Framework plugin Changelog

## [0.9.2]
- No longer show the routing key inspection warning when the method is not annotated with a relevant handler annotation.

## [0.9.1]
- Disable plugin when Axon Framework 5 or greater is detected. The plugin is not compatible with Axon Framework 5 and greater at this time, as it is an experimental branch. Future versions of the plugin will be compatible with Axon Framework 5 and greater, once it approaches release readiness.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ class JavaMissingRoutingKeyOnAggregateMemberInspection : AbstractBaseJavaLocalIn
?: entity.routingKey
?: return null

if (method.hasAnnotation(AxonAnnotation.EVENT_SOURCING_HANDLER) &&
entityMember.eventForwardingMode != "org.axonframework.modelling.command.ForwardMatchingInstances"
) {
val isEventSourcingHandler = method.hasAnnotation(AxonAnnotation.EVENT_SOURCING_HANDLER)
if(!isEventSourcingHandler && !method.hasAnnotation(AxonAnnotation.COMMAND_HANDLER)) {
return null
}

if (isEventSourcingHandler && entityMember.eventForwardingMode != "org.axonframework.modelling.command.ForwardMatchingInstances") {
return null
}
val payload = method.resolvePayloadType() ?: return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ class KotlinMissingRoutingKeyOnAggregateMemberInspection : AbstractKotlinInspect
val routingKey = entityMember.routingKey
?: entity.routingKey
?: return
if (method.hasAnnotation(AxonAnnotation.EVENT_SOURCING_HANDLER) &&
entityMember.eventForwardingMode != "org.axonframework.modelling.command.ForwardMatchingInstances"
) {
val isEventSourcingHandler = method.hasAnnotation(AxonAnnotation.EVENT_SOURCING_HANDLER)
if(!isEventSourcingHandler && !method.hasAnnotation(AxonAnnotation.COMMAND_HANDLER)) {
return
}
if (isEventSourcingHandler && entityMember.eventForwardingMode != "org.axonframework.modelling.command.ForwardMatchingInstances") {
return
}
val payload = method.resolvePayloadType() ?: return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,45 @@ class JavaMissingRoutingKeyOnAggregateMemberInspectionTest : AbstractAxonFixture
}
}

fun `test will not show problem if has no handler annotation`() {
addFile(
"MyCommand.java", """
class MyCommand {}
""".trimIndent()
)

addFile(
"MyEntity.java", """
import test.MyCommand;

class MyEntity {
@EntityId
private String myEntityId;

public void handle(MyCommand command) {}
}
""".trimIndent(), open = true
)

addFile(
"MyAggregate.java", """
import test.MyEntity;
import java.util.List;

@AggregateRoot
class MyAggregate {
@AggregateMember
List<MyEntity> entities;
""".trimIndent()
)

myFixture.enableInspections(JavaMissingRoutingKeyOnAggregateMemberInspection())
val highlights = myFixture.doHighlighting(HighlightSeverity.WARNING)
Assertions.assertThat(highlights).noneMatch {
it.text == "handle" && it.description.contains("The payload requires a myEntityId property or getter")
}
}

fun `test will not show problem when key is present`() {
addFile(
"MyCommand.java", """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,45 @@ class KotlinMissingRoutingKeyOnAggregateMemberInspectionTest : AbstractAxonFixtu
}
}

fun `test will not show problem if has no handler annotation`() {
addFile(
"MyCommand.kt", """
class MyCommand {}
""".trimIndent()
)

addFile(
"MyEntity.kt", """
import test.MyCommand

class MyEntity {
@EntityId
private lateinit var myEntityId: String

fun handle(command: MyCommand) {}
}
""".trimIndent(), open = true
)

addFile(
"MyAggregate.kt", """
import test.MyEntity
import java.util.List

@AggregateRoot
class MyAggregate {
@AggregateMember
private lateinit var entities: List<MyEntity>
""".trimIndent()
)

myFixture.enableInspections(KotlinMissingRoutingKeyOnAggregateMemberInspection())
val highlights = myFixture.doHighlighting(HighlightSeverity.WARNING)
Assertions.assertThat(highlights).noneMatch {
it.text == "handle" && it.description.contains("The payload requires a myEntityId property or getter")
}
}

fun `test will not show problem when key is present`() {
addFile(
"MyCommand.kt", """
Expand Down
Loading