wrdv / testme-idea

TestMe IntelliJ IDEA Plugin - Auto generates Unit Test code
http://weirddev.com/testme
Other
171 stars 65 forks source link

@superbuilder(lombok) can make testme code generator error #43

Closed winint1988 closed 4 months ago

winint1988 commented 5 months ago

@Data @Superbuilder public class A { private String name; }

@Data @SuperBuilder public class B extends A { private String name1; }

// test class public class TestCase {

public boolean testCase(String[] args) {
    B b = B.builder().name("name").name1("name1").build();
    return false;
}

}

The above situation will cause “testme” to make the following mistakes:

java.lang.NullPointerException: Cannot invoke "String.replace(java.lang.CharSequence, java.lang.CharSequence)" because "typeName" is null at com.weirddev.testme.intellij.utils.ClassNameUtils.stripArrayVarargsDesignator(ClassNameUtils.java:40) at com.weirddev.testme.intellij.template.context.Field.(Field.java:64) at com.weirddev.testme.intellij.template.context.Type.resolveFields(Type.java:254) at com.weirddev.testme.intellij.template.context.Type.resolveDependencies(Type.java:240) at com.weirddev.testme.intellij.template.TypeDictionary.getTypeInternal(TypeDictionary.java:150) at com.weirddev.testme.intellij.template.TypeDictionary.getType(TypeDictionary.java:135) at com.weirddev.testme.intellij.builder.MethodFactory.resolveReturnType(MethodFactory.java:134) at com.weirddev.testme.intellij.builder.MethodFactory.createMethod(MethodFactory.java:58) at com.weirddev.testme.intellij.builder.MethodFactory.resolveCalledMethods(MethodFactory.java:118) at com.weirddev.testme.intellij.builder.MethodFactory.resolveInternalReferences(MethodFactory.java:67) at com.weirddev.testme.intellij.template.context.Type.resolveDependencies(Type.java:234) at com.weirddev.testme.intellij.template.TypeDictionary.getTypeInternal(TypeDictionary.java:150) at com.weirddev.testme.intellij.template.TypeDictionary.getType(TypeDictionary.java:126) at com.weirddev.testme.intellij.generator.TestTemplateContextBuilder.build(TestTemplateContextBuilder.java:56) at com.weirddev.testme.intellij.generator.TestMeGenerator.createTestClassFromCodeTemplate(TestMeGenerator.java:120) at com.weirddev.testme.intellij.generator.TestMeGenerator.createTestClass(TestMeGenerator.java:110) at com.weirddev.testme.intellij.generator.TestMeGenerator$1$1.compute(TestMeGenerator.java:66) at com.weirddev.testme.intellij.generator.TestMeGenerator$1$1.compute(TestMeGenerator.java:61) at com.intellij.openapi.application.impl.ApplicationImpl.lambda$runWriteAction$9(ApplicationImpl.java:1001) at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:980) at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1001) at com.weirddev.testme.intellij.generator.TestMeGenerator$1.compute(TestMeGenerator.java:61) at com.weirddev.testme.intellij.generator.TestMeGenerator$1.compute(TestMeGenerator.java:59) at com.intellij.psi.impl.source.PostprocessReformattingAspectImpl.postponeFormattingInside(PostprocessReformattingAspectImpl.java:149) at com.weirddev.testme.intellij.generator.TestMeGenerator.generateTest(TestMeGenerator.java:59) at com.weirddev.testme.intellij.action.CreateTestMeAction$1.run(CreateTestMeAction.java:134) at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:219) at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:174) at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:164) at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:150) at com.weirddev.testme.intellij.action.CreateTestMeAction.createTest(CreateTestMeAction.java:131) at com.weirddev.testme.intellij.action.TestMeCreator.invoke(TestMeCreator.java:36) at com.weirddev.testme.intellij.action.TestMeCreator.createTest(TestMeCreator.java:26) at com.weirddev.testme.intellij.action.TestMeAdditionalAction.execute(TestMeAdditionalAction.java:53) at com.weirddev.testme.intellij.ui.popup.TestMePopUpHandler.lambda$show$1(TestMePopUpHandler.java:127) at com.intellij.openapi.ui.popup.PopupChooserBuilder.lambda$setItemChosenCallback$0(PopupChooserBuilder.java:207) at com.intellij.ui.popup.AbstractPopup.lambda$dispose$18(AbstractPopup.java:1625) at com.intellij.openapi.wm.impl.FocusManagerImpl.lambda$doWhenFocusSettlesDown$3(FocusManagerImpl.java:173) at com.intellij.util.ui.EdtInvocationManager.invokeLaterIfNeeded(EdtInvocationManager.java:33) at com.intellij.ide.IdeEventQueue.ifFocusEventsInTheQueue(IdeEventQueue.kt:210) at com.intellij.ide.IdeEventQueue.executeWhenAllFocusEventsLeftTheQueue(IdeEventQueue.kt:176) at com.intellij.openapi.wm.impl.FocusManagerImpl.doWhenFocusSettlesDown(FocusManagerImpl.java:169) at com.intellij.openapi.wm.impl.FocusManagerImpl.doWhenFocusSettlesDown(FocusManagerImpl.java:163) at com.intellij.ui.popup.AbstractPopup.dispose(AbstractPopup.java:1623) at com.intellij.openapi.util.ObjectTree.runWithTrace(ObjectTree.java:129) at com.intellij.openapi.util.ObjectTree.executeAll(ObjectTree.java:161) at com.intellij.openapi.util.Disposer.dispose(Disposer.java:262) at com.intellij.ui.popup.AbstractPopup.cancel(AbstractPopup.java:892) at com.intellij.ui.popup.AbstractPopup.closeOk(AbstractPopup.java:827) at com.intellij.openapi.ui.popup.PopupChooserBuilder.closePopup(PopupChooserBuilder.java:501) at com.intellij.openapi.ui.popup.PopupChooserBuilder$2.actionPerformed(PopupChooserBuilder.java:490) at java.desktop/javax.swing.JComponent$ActionStandin.actionPerformed(JComponent.java:3486) at java.desktop/javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1810) at java.desktop/javax.swing.JComponent.processKeyBinding(JComponent.java:2943) at java.desktop/javax.swing.JComponent.processKeyBindings(JComponent.java:3005) at java.desktop/javax.swing.JComponent.processKeyEvent(JComponent.java:2905) at java.desktop/java.awt.Component.processEvent(Component.java:6434) at java.desktop/java.awt.Container.processEvent(Container.java:2266) at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5027) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4855) at java.desktop/java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954) at java.desktop/java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:886) at java.desktop/java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1166) at java.desktop/java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:1023) at java.desktop/java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:849) at com.intellij.ide.IdeKeyboardFocusManager.access$dispatchEvent$s1569605750(IdeKeyboardFocusManager.kt:18) at com.intellij.ide.IdeKeyboardFocusManager$dispatchEvent$1.invoke(IdeKeyboardFocusManager.kt:25) at com.intellij.ide.IdeKeyboardFocusManager$dispatchEvent$1.invoke(IdeKeyboardFocusManager.kt:25) at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:992) at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105) at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:992) at com.intellij.ide.IdeKeyboardFocusManager.dispatchEvent(IdeKeyboardFocusManager.kt:25) at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4904) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324) at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2808) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4855) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:794) at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:739) at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:733) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:766) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:764) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:763) at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:685) at com.intellij.ide.IdeEventQueue.dispatchKeyEvent(IdeEventQueue.kt:620) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:587) at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:67) at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:369) at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:368) at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:787) at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:368) at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:363) at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:992) at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:113) at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:992) at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$7(IdeEventQueue.kt:363) at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:861) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:405) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

please help.

yaronyam commented 5 months ago

@winint1988 - Lombok support is not so great and needs to improve....I'm short on time lately. if you can please share Lombok's generated B.builder() method, I'll be able to create a full TC and hopefully this might be quick fix. Thanks for raising this issue

huangliang992 commented 4 months ago

image the middle class generated by lombok has no QualifiedName, it makes this problem.

yaronyam commented 4 months ago

Fixed by @huangliang992 in https://github.com/wrdv/testme-idea/pull/45 released in v6.6.0

winint1988 commented 4 months ago

am very busy recently,Sorry, my reply is a bit late。Thanks for fix this issue。

At 2024-07-11 02:39:52, "Yaron" @.***> wrote:

Fixed by @huangliang992 in #45 released in v6.6.0

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

winint1988 commented 4 months ago

Thanks, I don't know much about these infra-level codes, can you explain more detail about this. just like why the middle class has no QualifiedName will makes this promblem.

At 2024-07-04 17:27:28, "HuangLiang" @.***> wrote:

image.png (view on web) the middle class generated by lombok has no QualifiedName, it makes this problem.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>