Spring Roo
  1. Spring Roo
  2. ROO-2947

Roo Integration Test generation fails - Data on demand issue with 2 attributes of same type

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Complete
    • Affects Version/s: 1.2.0.M1
    • Fix Version/s: 1.2.0.RELEASE
    • Component/s: TESTING
    • Labels:
      None

      Description

      Failure to generate an Integration test for an entity object that has 2 attributes of same custom data type in my example CurrencyAmount is defined with @Embeddable with 2 fields amount and currency, I get the following errors when I try to do anything on my entity, it fails to add any new field or generate Integration tests for this entity

      ~.domain.ccti.CreditTransferTxnInfo roo> test integration
      Created SRC_TEST_JAVA\com\acps\app\payments\core\domain\cc ti\CreditTransferTxnInfoDataOnDemand.java
      Created SRC_TEST_JAVA\com\acps\app\payments\core\domain\cc ti\CreditTransferTxnInfoIntegrationTest.java
      Undo create SRC_TEST_JAVA\com\acps\app\payments\core\domain\cc ti\CreditTransferTxnInfoIntegrationTest.java
      Undo create SRC_TEST_JAVA\com\acps\app\payments\core\domain\cc ti\CreditTransferTxnInfoDataOnDemand.java

      java.lang.IllegalArgumentException: Method 'setAmount' already defined in ITD (ITD target 'com.acps.app.payments.core.domain.ccti.CreditTran sferTxnInfoDataOnDemand_Roo_DataOnDemand'
      ~.domain.ccti.CreditTransferTxnInfo roo>

      My Class CreditTransferTxnInfo is listed here

      import com.acps.app.payments.core.domain.embed.CurrencyAmount;

      @RooJavaBean
      @RooToString
      @RooJpaEntity
      public class CreditTransferTxnInfo {

      @Size(max = 35)
      private String instructionId;

      @Size(max = 35)
      private String endToEndId;

      @Embedded
      private PaymentTypeInfo paymentTypeInfo;

      @Embedded
      @AttributeOverrides( {
      @AttributeOverride(name="amount", column = @Column(name="instructedAmount") ),
      @AttributeOverride(name="currencyCode", column = @Column(name="instructedAmount_currency") )
      } )
      private CurrencyAmount instructedAmount;

      @Embedded
      @AttributeOverrides(

      { @AttributeOverride(name="amount", column = @Column(name="equivalentAmount") ), @AttributeOverride(name="currencyCode", column = @Column(name="equivalentAmount_currency") ) } ) private CurrencyAmount equivalentAmount; }

      Here is the Definition of CurrencyAmount.java that defines amount and CurrencyCode

      @RooJavaBean
      @RooToString
      @Embeddable
      public class CurrencyAmount {
      private BigDecimal amount;

      @Size(max = 3)
      private String currencyCode;
      }

      Does Roo not support Generating DataOnDemand when there are different properties of same Type?

      1. CreditTransferTxnInfo_Roo_JavaBean.aj
        1 kB
        Ritesh Kirad
      2. CreditTransferTxnInfo_Roo_Jpa_Entity.aj
        1 kB
        Ritesh Kirad
      3. CreditTransferTxnInfo_Roo_ToString.aj
        0.9 kB
        Ritesh Kirad
      4. CreditTransferTxnInfo.java
        35 kB
        Ritesh Kirad
      5. CreditTransferTxnInfo.java
        35 kB
        Ritesh Kirad
      6. InstructionForCdtrDbtrAgent.java
        0.8 kB
        Ritesh Kirad

        Issue Links

          Activity

          Hide
          Alan Stewart added a comment -

          Resolved in Git ID 36a7c5b00465af6797db79d8a521dc1953d0822d.

          I prefixed the individual embedded field method names with the name of the emmbedded field itself to avoid ambiguity as well as to be able to customize individual methods after pushing in.

          For example, the setCurrencyCode method for the @Embedded field instructedAmount now becomes:

          setInstructedAmountCurrencyCode(CurrencyAmount obj, int index) {...}
          

          and similarly for the @Embedded field equivalentAmount,

          setEquivalentAmountCurrencyCode(CurrencyAmount obj, int index) {...}
          
          Show
          Alan Stewart added a comment - Resolved in Git ID 36a7c5b00465af6797db79d8a521dc1953d0822d. I prefixed the individual embedded field method names with the name of the emmbedded field itself to avoid ambiguity as well as to be able to customize individual methods after pushing in. For example, the setCurrencyCode method for the @Embedded field instructedAmount now becomes: setInstructedAmountCurrencyCode(CurrencyAmount obj, int index) {...} and similarly for the @Embedded field equivalentAmount, setEquivalentAmountCurrencyCode(CurrencyAmount obj, int index) {...}
          Hide
          Ritesh Kirad added a comment -

          Thanks Alan for the quick turnaround, I have 2 questions for you

          1. Will this also work for multiple Nested properties for instance

          private BranchAndFiIdentification itermediaryAgent1; is defined with the following embed tag @AttributeOverride(name="financialInstAddress.postalCode", column = @Column(name="itermediaryAgent1_addrPostalCode") )

          will you fix generate setItermediaryAgent1FinancialInstAddressPostalCode ?
          since the BranchAndFiIdentification has a property called financialInstAddress which is of type PostalAddress

          2. To get your fix do I just download the Latest Development Release 1.2.0.RC1 from http://www.springsource.com/download/community?sid=1420796

          or should I get the zip from http://static.springsource.org/downloads/nightly/snapshot-download.php?project=ROO
          that is labeled ROO/spring-roo-1.2.0.BUILD-SNAPSHOT_20111205.010612-1bae4f5.zip

          I wasn't sure if your fix made it to the dev release build, so I just wanted to confirm before I started testing

          Thanks a bunch for the quick turnaround on this one
          Ritesh

          Show
          Ritesh Kirad added a comment - Thanks Alan for the quick turnaround, I have 2 questions for you 1. Will this also work for multiple Nested properties for instance private BranchAndFiIdentification itermediaryAgent1; is defined with the following embed tag @AttributeOverride(name="financialInstAddress.postalCode", column = @Column(name="itermediaryAgent1_addrPostalCode") ) will you fix generate setItermediaryAgent1FinancialInstAddressPostalCode ? since the BranchAndFiIdentification has a property called financialInstAddress which is of type PostalAddress 2. To get your fix do I just download the Latest Development Release 1.2.0.RC1 from http://www.springsource.com/download/community?sid=1420796 or should I get the zip from http://static.springsource.org/downloads/nightly/snapshot-download.php?project=ROO that is labeled ROO/spring-roo-1.2.0.BUILD-SNAPSHOT_20111205.010612-1bae4f5.zip I wasn't sure if your fix made it to the dev release build, so I just wanted to confirm before I started testing Thanks a bunch for the quick turnaround on this one Ritesh
          Hide
          Alan Stewart added a comment -

          1. Data-on-demand does not consider any @AttributeOverride annotations (beyond the the scope at present). It will just look at the field names in the embedded class and the @Embedded field name itself.

          2. Use the 2nd URL - http://static.springsource.org/downloads/nightly/snapshot-download.php?project=ROO

          Show
          Alan Stewart added a comment - 1. Data-on-demand does not consider any @AttributeOverride annotations (beyond the the scope at present). It will just look at the field names in the embedded class and the @Embedded field name itself. 2. Use the 2nd URL - http://static.springsource.org/downloads/nightly/snapshot-download.php?project=ROO
          Hide
          Ritesh Kirad added a comment -

          I took the 2nd URL and after running now I have another issue

          [INFO] Compiler errors :
          error at InstructionForCdtrDbtrAgent attached = InstructionForCdtrDbtrAgent.findInstructionForCdtrDbtrAgent(this.id);

          The CreditTransferTxnInfo object has a OneToMany relationship defined as follows that is now failing when I do a Run As->Maven Package on my project, did you get this error? I'm attaching the java files for just these 2 java classes since the project is still the same that is already in the last attachment, is this a different issue?

          @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
          private Set<InstructionForCdtrDbtrAgent> instrForCdtrAgt = new HashSet<InstructionForCdtrDbtrAgent>();

          Show
          Ritesh Kirad added a comment - I took the 2nd URL and after running now I have another issue [INFO] Compiler errors : error at InstructionForCdtrDbtrAgent attached = InstructionForCdtrDbtrAgent.findInstructionForCdtrDbtrAgent(this.id); The CreditTransferTxnInfo object has a OneToMany relationship defined as follows that is now failing when I do a Run As->Maven Package on my project, did you get this error? I'm attaching the java files for just these 2 java classes since the project is still the same that is already in the last attachment, is this a different issue? @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) private Set<InstructionForCdtrDbtrAgent> instrForCdtrAgt = new HashSet<InstructionForCdtrDbtrAgent>();
          Hide
          Ritesh Kirad added a comment -

          Sorry I figured it out that was wrong annotation but now I still have an issue to generate the Integration Test for the CreditTransferTxnInfo object, it gives me the following error

          roo> test integration
          Type com.acps.app.payments.core.domain.ccti.CreditTransferTxnInfo must be a persistent type

          this is the same class we have been working on to get the DataOnDeman fix, I wanted to make sure the integration test will work so I deleted the existing DataOnDemand and IntegrationTest for this entity and now it gives me the above error

          I'm using spring-roo-1.2.0.BUILD-SNAPSHOT rev 280149c

          Show
          Ritesh Kirad added a comment - Sorry I figured it out that was wrong annotation but now I still have an issue to generate the Integration Test for the CreditTransferTxnInfo object, it gives me the following error roo> test integration Type com.acps.app.payments.core.domain.ccti.CreditTransferTxnInfo must be a persistent type this is the same class we have been working on to get the DataOnDeman fix, I wanted to make sure the integration test will work so I deleted the existing DataOnDemand and IntegrationTest for this entity and now it gives me the above error I'm using spring-roo-1.2.0.BUILD-SNAPSHOT rev 280149c

            People

            • Assignee:
              Alan Stewart
              Reporter:
              Ritesh Kirad
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: