Spring Roo 抽象子类 --test 自动失败

发布于 2024-11-04 22:06:36 字数 7446 浏览 3 评论 0原文

我正在使用一个非常简单的域模型,像这样创建...

entity --class ~.domain.Contact --abstract --inheritanceType TABLE_PER_CLASS 
entity --class ~.domain.Student --extends ~.domain.Contact --testAutomatically 
entity --class ~.domain.Family --extends ~.domain.Contact --testAutomatically 

然后我向每个类添加一些字段...

field string --fieldName firstName --class ~.domain.Contact
field string --fieldName secondName --class ~.domain.Contact
field string --fieldName firstName2 --class ~.domain.Family
field string --fieldName secondName2 --class ~.domain.Family

然后我自动生成的测试失败。这对我来说看起来像一个错误,有人找到解决这个问题的方法,或者我可以不在子类上使用 --testAutomatically 吗? (有点垃圾!)

(我在早期阶段对 Roo 失去了信心,grails 正在召唤我回来......)

这是我的堆栈跟踪......

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building hostfamilyfinders
[INFO]    task-segment: [test]
[INFO] ------------------------------------------------------------------------
[INFO] [aspectj:compile {execution: default}]
[WARNING] advice defined in org.springframework.scheduling.aspectj.AbstractAsyncExecutionAspect has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
[debug] execute contextualize
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [aspectj:test-compile {execution: default}]
[ERROR] Type mismatch: cannot convert from Contact to Student
[ERROR] Type mismatch: cannot convert from Contact to Student
[ERROR] Type mismatch: cannot convert from Contact to Student
[ERROR] Type mismatch: cannot convert from Contact to Student
[ERROR] Type mismatch: cannot convert from Contact to Student
[ERROR] Cannot instantiate the type Contact
[ERROR] The method findStudent(Long) is undefined for the type Contact
[ERROR] The method findStudent(Long) is undefined for the type Contact
[ERROR] The method findStudentEntries(int, int) is undefined for the type Contact
[ERROR] The method add(Student) in the type List<Student> is not applicable for the arguments (Contact)
[WARNING] advice defined in org.springframework.orm.jpa.aspectj.JpaExceptionTranslatorAspect has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.scheduling.aspectj.AbstractAsyncExecutionAspect has not been applied [Xlint:adviceDidNotMatch]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Compiler errors : 
error at com.cicoders.com.hostfamilyfinders.domain.Student obj = dod.getRandomContact();
                                                        ^^^^^^^^^^^^^
/Users/charlieivie/Workspace/STS/hostfamilyfinders/src/test/java/com/cicoders/com/hostfamilyfinders/domain/StudentIntegrationTest_Roo_IntegrationTest.aj:34:0::0 Type mismatch: cannot convert from Contact to Student
error at com.cicoders.com.hostfamilyfinders.domain.Student obj = dod.getRandomContact();
                                                        ^^^^^^^^^^^^^
/Users/charlieivie/Workspace/STS/hostfamilyfinders/src/test/java/com/cicoders/com/hostfamilyfinders/domain/StudentIntegrationTest_Roo_IntegrationTest.aj:65:0::0 Type mismatch: cannot convert from Contact to Student
error at com.cicoders.com.hostfamilyfinders.domain.Student obj = dod.getRandomContact();
                                                        ^^^^^^^^^^^^^
/Users/charlieivie/Workspace/STS/hostfamilyfinders/src/test/java/com/cicoders/com/hostfamilyfinders/domain/StudentIntegrationTest_Roo_IntegrationTest.aj:79:0::0 Type mismatch: cannot convert from Contact to Student
error at com.cicoders.com.hostfamilyfinders.domain.Student obj = dod.getNewTransientContact(Integer.MAX_VALUE);
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/Users/charlieivie/Workspace/STS/hostfamilyfinders/src/test/java/com/cicoders/com/hostfamilyfinders/domain/StudentIntegrationTest_Roo_IntegrationTest.aj:95:0::0 Type mismatch: cannot convert from Contact to Student
error at com.cicoders.com.hostfamilyfinders.domain.Student obj = dod.getRandomContact();
                                                        ^^^^^^^^^^^^^
/Users/charlieivie/Workspace/STS/hostfamilyfinders/src/test/java/com/cicoders/com/hostfamilyfinders/domain/StudentIntegrationTest_Roo_IntegrationTest.aj:105:0::0 Type mismatch: cannot convert from Contact to Student
error at com.cicoders.com.hostfamilyfinders.domain.Contact obj = new com.cicoders.com.hostfamilyfinders.domain.Contact();
                                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/Users/charlieivie/Workspace/STS/hostfamilyfinders/src/test/java/com/cicoders/com/hostfamilyfinders/domain/StudentDataOnDemand_Roo_DataOnDemand.aj:21:0::0 Cannot instantiate the type Contact
error at return Contact.findStudent(obj.getId());
               ^^
/Users/charlieivie/Workspace/STS/hostfamilyfinders/src/test/java/com/cicoders/com/hostfamilyfinders/domain/StudentDataOnDemand_Roo_DataOnDemand.aj:42:0::0 The method findStudent(Long) is undefined for the type Contact
error at return Contact.findStudent(obj.getId());
               ^^
/Users/charlieivie/Workspace/STS/hostfamilyfinders/src/test/java/com/cicoders/com/hostfamilyfinders/domain/StudentDataOnDemand_Roo_DataOnDemand.aj:48:0::0 The method findStudent(Long) is undefined for the type Contact
error at data = com.cicoders.com.hostfamilyfinders.domain.Contact.findStudentEntries(0, 10);
                                                         ^^^^^^^^^
/Users/charlieivie/Workspace/STS/hostfamilyfinders/src/test/java/com/cicoders/com/hostfamilyfinders/domain/StudentDataOnDemand_Roo_DataOnDemand.aj:56:0::0 The method findStudentEntries(int, int) is undefined for the type Contact
error at data.add(obj);

/Users/charlieivie/Workspace/STS/hostfamilyfinders/src/test/java/com/cicoders/com/hostfamilyfinders/domain/StudentDataOnDemand_Roo_DataOnDemand.aj:67:0::0 The method add(Student) in the type List<Student> is not applicable for the arguments (Contact)

[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4 seconds
[INFO] Finished at: Mon May 02 17:06:08 BST 2011
[INFO] Final Memory: 22M/81M
[INFO] ------------------------------------------------------------------------

I am using a very simple domain model, created like this...

entity --class ~.domain.Contact --abstract --inheritanceType TABLE_PER_CLASS 
entity --class ~.domain.Student --extends ~.domain.Contact --testAutomatically 
entity --class ~.domain.Family --extends ~.domain.Contact --testAutomatically 

then I am adding a few fields to each class...

field string --fieldName firstName --class ~.domain.Contact
field string --fieldName secondName --class ~.domain.Contact
field string --fieldName firstName2 --class ~.domain.Family
field string --fieldName secondName2 --class ~.domain.Family

Then my automatically generated tests fail. This looks like a bug to me, anbody see a way around this, or can I not use --testAutomatically on subclasses? (a bit rubbish!)

(I'm loosing faith at an early stage with Roo, grails is calling me back...)

Here is my stacktrace...

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building hostfamilyfinders
[INFO]    task-segment: [test]
[INFO] ------------------------------------------------------------------------
[INFO] [aspectj:compile {execution: default}]
[WARNING] advice defined in org.springframework.scheduling.aspectj.AbstractAsyncExecutionAspect has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
[debug] execute contextualize
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [aspectj:test-compile {execution: default}]
[ERROR] Type mismatch: cannot convert from Contact to Student
[ERROR] Type mismatch: cannot convert from Contact to Student
[ERROR] Type mismatch: cannot convert from Contact to Student
[ERROR] Type mismatch: cannot convert from Contact to Student
[ERROR] Type mismatch: cannot convert from Contact to Student
[ERROR] Cannot instantiate the type Contact
[ERROR] The method findStudent(Long) is undefined for the type Contact
[ERROR] The method findStudent(Long) is undefined for the type Contact
[ERROR] The method findStudentEntries(int, int) is undefined for the type Contact
[ERROR] The method add(Student) in the type List<Student> is not applicable for the arguments (Contact)
[WARNING] advice defined in org.springframework.orm.jpa.aspectj.JpaExceptionTranslatorAspect has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.scheduling.aspectj.AbstractAsyncExecutionAspect has not been applied [Xlint:adviceDidNotMatch]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Compiler errors : 
error at com.cicoders.com.hostfamilyfinders.domain.Student obj = dod.getRandomContact();
                                                        ^^^^^^^^^^^^^
/Users/charlieivie/Workspace/STS/hostfamilyfinders/src/test/java/com/cicoders/com/hostfamilyfinders/domain/StudentIntegrationTest_Roo_IntegrationTest.aj:34:0::0 Type mismatch: cannot convert from Contact to Student
error at com.cicoders.com.hostfamilyfinders.domain.Student obj = dod.getRandomContact();
                                                        ^^^^^^^^^^^^^
/Users/charlieivie/Workspace/STS/hostfamilyfinders/src/test/java/com/cicoders/com/hostfamilyfinders/domain/StudentIntegrationTest_Roo_IntegrationTest.aj:65:0::0 Type mismatch: cannot convert from Contact to Student
error at com.cicoders.com.hostfamilyfinders.domain.Student obj = dod.getRandomContact();
                                                        ^^^^^^^^^^^^^
/Users/charlieivie/Workspace/STS/hostfamilyfinders/src/test/java/com/cicoders/com/hostfamilyfinders/domain/StudentIntegrationTest_Roo_IntegrationTest.aj:79:0::0 Type mismatch: cannot convert from Contact to Student
error at com.cicoders.com.hostfamilyfinders.domain.Student obj = dod.getNewTransientContact(Integer.MAX_VALUE);
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/Users/charlieivie/Workspace/STS/hostfamilyfinders/src/test/java/com/cicoders/com/hostfamilyfinders/domain/StudentIntegrationTest_Roo_IntegrationTest.aj:95:0::0 Type mismatch: cannot convert from Contact to Student
error at com.cicoders.com.hostfamilyfinders.domain.Student obj = dod.getRandomContact();
                                                        ^^^^^^^^^^^^^
/Users/charlieivie/Workspace/STS/hostfamilyfinders/src/test/java/com/cicoders/com/hostfamilyfinders/domain/StudentIntegrationTest_Roo_IntegrationTest.aj:105:0::0 Type mismatch: cannot convert from Contact to Student
error at com.cicoders.com.hostfamilyfinders.domain.Contact obj = new com.cicoders.com.hostfamilyfinders.domain.Contact();
                                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/Users/charlieivie/Workspace/STS/hostfamilyfinders/src/test/java/com/cicoders/com/hostfamilyfinders/domain/StudentDataOnDemand_Roo_DataOnDemand.aj:21:0::0 Cannot instantiate the type Contact
error at return Contact.findStudent(obj.getId());
               ^^
/Users/charlieivie/Workspace/STS/hostfamilyfinders/src/test/java/com/cicoders/com/hostfamilyfinders/domain/StudentDataOnDemand_Roo_DataOnDemand.aj:42:0::0 The method findStudent(Long) is undefined for the type Contact
error at return Contact.findStudent(obj.getId());
               ^^
/Users/charlieivie/Workspace/STS/hostfamilyfinders/src/test/java/com/cicoders/com/hostfamilyfinders/domain/StudentDataOnDemand_Roo_DataOnDemand.aj:48:0::0 The method findStudent(Long) is undefined for the type Contact
error at data = com.cicoders.com.hostfamilyfinders.domain.Contact.findStudentEntries(0, 10);
                                                         ^^^^^^^^^
/Users/charlieivie/Workspace/STS/hostfamilyfinders/src/test/java/com/cicoders/com/hostfamilyfinders/domain/StudentDataOnDemand_Roo_DataOnDemand.aj:56:0::0 The method findStudentEntries(int, int) is undefined for the type Contact
error at data.add(obj);

/Users/charlieivie/Workspace/STS/hostfamilyfinders/src/test/java/com/cicoders/com/hostfamilyfinders/domain/StudentDataOnDemand_Roo_DataOnDemand.aj:67:0::0 The method add(Student) in the type List<Student> is not applicable for the arguments (Contact)

[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4 seconds
[INFO] Finished at: Mon May 02 17:06:08 BST 2011
[INFO] Final Memory: 22M/81M
[INFO] ------------------------------------------------------------------------

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文