Announcement Announcement Module
Collapse
No announcement yet.
java.util.Currency field generated with --notNull constraint breaks generated tests Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • java.util.Currency field generated with --notNull constraint breaks generated tests

    If an entity field with type java.util.Currency is created like this:
    Code:
    project --topLevelPackage com.example --projectName example --java 6
    jpa setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY 
    entity jpa --class com.example.AccountingTransaction --testAutomatically 
    field other --fieldName currency --type java.util.Currency --notNull
    the automated tests fail because of the @NotNull constraint on this field:
    Code:
     
    testCountAccountingTransactions(com.example.AccountingTransactionIntegrationTest): [ConstraintDescriptorImpl{annotation=javax.validation.constraints.NotNull, payloads=[], hasComposingConstraints=true, isReportAsSingleInvalidConstraint=false, elementType=FIELD, definedOn=DEFINED_LOCALLY, groups=[interface javax.validation.groups.Default], attributes={message={javax.validation.constraints.NotNull.message}, payload=[Ljava.lang.Class;@3cd713fe, groups=[Ljava.lang.Class;@4c61a7e6}}:kann nicht null sein=null]
    This is because of the following generated implementation in aspect AccountingTransactionDataOnDemand_Roo_DataOnDemand :
    Code:
        public void AccountingTransactionDataOnDemand.setCurrency(AccountingTransaction obj, int index) {
            Currency currency = null;
            obj.setCurrency(currency);
        }
    How can this be fixed properly without modifying the generated aspect myself?

  • #2
    Originally posted by Andreas Klöber View Post
    How can this be fixed properly without modifying the generated aspect myself?
    Make a push-in of setCurrency method and modify it.

    Regards !

    Comment


    • #3
      Originally posted by mmartinez View Post
      Make a push-in of setCurrency method and modify it.
      Thanks, that worked!

      Comment

      Working...
      X