ContextMapper / context-mapper-archunit-extension

Validate your code against the CML model with ArchUnit.
https://contextmapper.org/
Apache License 2.0
5 stars 0 forks source link

If in the JAVA code I use a List of Enum but in the model I only have the reference to the Enum, the plugin didn't complain about it. #7

Open juan-conca opened 1 year ago

juan-conca commented 1 year ago

Describe the bug When I define a CommandEvent that has a reference to an attribute in the java code but is not the same type, the plugging didn't complain.

To Reproduce Create your own CommandEvent in the model:

enum UserRole {
           USER_ROLE_1,
           USER_ROLE_2,
           USER_ROLE_3,
           USER_ROLE_4
}

CommandEvent UserChangeRolesCommand {
           - UserId userId;
           - UserRole userRoles;
           - UserId submittedBy;
}

Then in your JAVA code, you make the error to define a list of enums, not just an enum:

@Command
@DomainRing
public final class UserChangeRolesCommand {

    private final UserId userId;
    private final List<UserRole> userRoles;
    private final UserId submittedBy;
    ...

And when compile, the plugging is not complaining about the difference of types

Expected behaviour I expect that If I define a list in the JAVA code and is not the same type in the model, the plugging complains

IDE and Plugin (please complete the following information):

IntelliJ IDEA 2022.3 (Ultimate Edition) Build #IU-223.7571.182, built on November 29, 2022 Runtime version: 17.0.5+1-b653.14 x86_64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. macOS 13.0.1 GC: G1 Young Generation, G1 Old Generation Non-Bundled Plugins: com.intellij.kubernetes (223.7571.188) com.dubreuia (2.3.0) de.docksnet.puml.syntaxchecker (0.2.0) PlantUML integration (5.20) org.asciidoctor.intellij.asciidoc (0.38.3) org.mapstruct.intellij (1.4.0) com.haulmont.jpab (2022.5.1-223) org.sonarlint.idea (7.2.1.58118)

Kotlin: 223-1.7.20-release-201-IJ7571.182

stefan-ka commented 1 year ago

Thanks for reporting this one as well @juan-conca! Yes, we should implement some type checking, at least there where an easy mapping between CML and Java is possible :+1: