Unable to mock Entity when plugin is enabled
pnartowski opened this issue · 6 comments
pnartowski commented
Hi
I'm unable to mock Entity, when running test getting :
org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: class SimpleEntity
Mockito can only mock non-private & non-final classes.
If you're not sure why you're getting this error, please report to the mailing list.
Caused by: java.lang.ClassFormatError: Duplicate method name "_ebean_getMarker" with signature "()Ljava.lang.String;" in class file SimpleEntity$MockitoMock$1545927225
@Entity
public class SimpleEntity {}
public class SimpleTest {
@Test
public void testOne() {
SimpleEntity mock = mock(SimpleEntity.class)
}
}
Plugin version: ebean-idea-11.41.4
in previous version (don't remember which one ) this code doesn't cause exception
rbygrave commented
java.lang.NullPointerException
at test.model.PersistentFile$MockitoMock$1216739959._ebean_get_mockitoInterceptor(Unknown Source)
at test.model.PersistentFile$MockitoMock$1216739959._ebean_set_mockitoInterceptor(Unknown Source)
at test.model.PersistentFile$MockitoMock$1216739959.setMockitoInterceptor(Unknown Source)
at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:49)
at org.mockito.internal.creation.bytebuddy.ByteBuddyMockMaker.createMock(ByteBuddyMockMaker.java:25)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:62)
at org.mockito.Mockito.mock(Mockito.java:1908)
at org.mockito.Mockito.mock(Mockito.java:1817)
at test.enhancement.MockEntityBeanTest.mockitoMock(MockEntityBeanTest.java:12)
...
rbygrave commented
Fixed in 11.42.2 of ebean-agent ... which treats mockitoInterceptor
field as a transient field.
rbygrave commented
I'll update and release this plugin with the updated agent. For people in more of a hurry.
- mkdir ~/.ebean
- download the ebean-agent-11.42.3.jar from maven central and put it into ~/.ebean
- turn the plugin off and then back on (this makes the plugin look for an agent in the ~/.ebean directory)
- Run the tests again (this time mockitoInterceptor field is not treated as a persistent field)
rbygrave commented
FYI The updated plugin has been submitted to Jetbrains. Should be available in approx 2 days.
pnartowski commented
Hi Rob,
Thanks for you fix for my problem.
It works for me.
I have no idea how detect if project is using ebean, I have no experience
with plugins in IntelliJ.
Regards,
Pawel
…On Wed, 7 Aug 2019 at 11:06, Rob Bygrave ***@***.***> wrote:
FYI The updated plugin has been submitted to Jetbrains. Should be
available in approx 2 days.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2?email_source=notifications&email_token=ABSYY7SU7OFTTZ2LKRVWHX3QDKGCVA5CNFSM4IJLHGNKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3XXYDI#issuecomment-519011341>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABSYY7V7JM53TD2CPVL7NOTQDKGCVANCNFSM4IJLHGNA>
.
rbygrave commented
Yeah cool. I'll keep pondering this and maybe come back to it some time later.
Cheers, Rob.