unloggedio / unlogged-sdk

Unlogged SDK for recording JAVA code execution
https://unlogged.io
Apache License 2.0
174 stars 16 forks source link

While Creating JUnit Boilerplate facing SQLiteException #32

Closed AzharMobeen closed 6 months ago

AzharMobeen commented 8 months ago

Describe the bug

I was trying to generate Unit test cases by clicking Create JUnit Boilerplate

org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (no such table: method_call)
    at org.sqlite.core.DB.newSQLException(DB.java:1135)
    at org.sqlite.core.DB.newSQLException(DB.java:1146)
    at org.sqlite.core.DB.throwex(DB.java:1106)
    at org.sqlite.core.NativeDB.prepare_utf8(Native Method)
    at org.sqlite.core.NativeDB.prepare(NativeDB.java:122)
    at org.sqlite.core.DB.prepare(DB.java:264)
    at org.sqlite.core.CorePreparedStatement.<init>(CorePreparedStatement.java:46)
    at org.sqlite.jdbc3.JDBC3PreparedStatement.<init>(JDBC3PreparedStatement.java:31)
    at org.sqlite.jdbc4.JDBC4PreparedStatement.<init>(JDBC4PreparedStatement.java:25)
    at org.sqlite.jdbc4.JDBC4Connection.prepareStatement(JDBC4Connection.java:34)
    at org.sqlite.jdbc3.JDBC3Connection.prepareStatement(JDBC3Connection.java:226)
    at com.j256.ormlite.jdbc.JdbcDatabaseConnection.compileStatement(JdbcDatabaseConnection.java:143)
    at com.j256.ormlite.stmt.mapped.MappedPreparedStmt.compile(MappedPreparedStmt.java:57)
    at com.j256.ormlite.stmt.StatementExecutor.buildIterator(StatementExecutor.java:252)
    at com.j256.ormlite.stmt.StatementExecutor.query(StatementExecutor.java:202)
    at com.j256.ormlite.dao.BaseDaoImpl.query(BaseDaoImpl.java:286)
    at com.j256.ormlite.stmt.QueryBuilder.query(QueryBuilder.java:384)
    at com.j256.ormlite.stmt.Where.query(Where.java:519)
    at com.insidious.plugin.client.DaoService.getConstructorCandidate(DaoService.java:1196)
    at com.insidious.plugin.client.SessionInstance.getConstructorCandidate(SessionInstance.java:3812)
    at com.insidious.plugin.factory.testcase.TestCaseService.buildTestCaseUnit(TestCaseService.java:187)
    at com.insidious.plugin.factory.InsidiousService.getTestCandidateCode(InsidiousService.java:379)
    at com.insidious.plugin.ui.testdesigner.TestCaseDesignerLite.generateAndPreviewTestCase(TestCaseDesignerLite.java:426)
    at com.insidious.plugin.ui.testdesigner.TestCaseDesignerLite.<init>(TestCaseDesignerLite.java:279)
    at com.insidious.plugin.factory.InsidiousService.showDesignerLiteForm(InsidiousService.java:1378)
    at com.insidious.plugin.ui.methodscope.MethodDirectInvokeComponent.lambda$new$3(MethodDirectInvokeComponent.java:121)
    at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
    at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2313)
    at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
    at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
    at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
    at java.desktop/java.awt.Component.processMouseEvent(Component.java:6657)
    at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3385)
    at java.desktop/java.awt.Component.processEvent(Component.java:6422)
    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.LightweightDispatcher.retargetMouseEvent(Container.java:4954)
    at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4581)
    at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4522)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
    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:690)
    at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.kt:638)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:592)
    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:997)
    at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:113)
    at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:997)
    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)

Reproduction steps

  1. I am using Spring Boot and Java 17
  2. Install plugin and added required dependencies and plugin (v 0.1.48)
  3. Select method and move to Direct Invoke section
  4. Click on Create Junit Boilerplate
    ...

Expected behavior

It should preview for Unit test cases and then I will be able to save it.

Additional context

No response

artpar commented 8 months ago

Hi @AzharMobeen

This is failing because there is no session logs with unlogged-sdk of the application.

Starting your application with the unlogged-sdk (and the @Unlogged annotation) will create these missing data and should let you create a boilerplate.

Though I think we can do better and generate boilerplate test cases without session logs actually. So I will make that change for this issue.

artpar commented 6 months ago

Hi,

This should be resolved. Please try the latest release available on the jetbrains marketplace.