You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current Behavior
I'm not able to mock com.day.cq.wcm.foundation.model.responsivegrid.ResponsiveGrid and other models
Expected behavior/code
A mocked version of the sling model.
Environment
AEM as a Cloud Service SDK Version 2024.10.18459.20241031T210302Z-241000
Core Components version 2.22.12
JDK 11
Mockito core version: 5.2.0
Hello everyone,
I'm trying to perform some unit testings but I'm not able to mock some core component classes after update to new version of AEM SDK 2024.10.18459.20241031T210302Z-241000
I am using @mock
private ResponsiveGrid responsiveGrid;
The error I'm getting is the following
`org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: class com.day.cq.wcm.foundation.model.responsivegrid.ResponsiveGrid.
If you're not sure why you're getting this error, please open an issue on GitHub.
Java : 11
JVM vendor name : Amazon.com Inc.
JVM vendor version : 11.0.15+9-LTS
JVM name : OpenJDK 64-Bit Server VM
JVM version : 11.0.15+9-LTS
JVM info : mixed mode
OS name : Mac OS X
OS version : 14.7
You are seeing this disclaimer because Mockito is configured to create inlined mocks.
You can learn about inline mocks and their limitations under item #39 of the Mockito class javadoc.
Underlying exception : org.mockito.exceptions.base.MockitoException: Could not modify all classes [class java.lang.Object, interface org.apache.sling.api.adapter.Adaptable, class com.day.cq.wcm.foundation.model.responsivegrid.ResponsiveGrid, interface org.apache.sling.api.resource.Resource, class org.apache.sling.api.adapter.SlingAdaptable, interface com.day.cq.wcm.foundation.model.responsivegrid.export.ResponsiveGridExporter, class org.apache.sling.api.resource.AbstractResource]
Caused by: org.mockito.exceptions.base.MockitoException: Could not modify all classes [class java.lang.Object, interface org.apache.sling.api.adapter.Adaptable, class com.day.cq.wcm.foundation.model.responsivegrid.ResponsiveGrid, interface org.apache.sling.api.resource.Resource, class org.apache.sling.api.adapter.SlingAdaptable, interface com.day.cq.wcm.foundation.model.responsivegrid.export.ResponsiveGridExporter, class org.apache.sling.api.resource.AbstractResource]
Caused by: java.lang.IllegalStateException:
Byte Buddy could not instrument all classes within the mock's type hierarchy
This problem should never occur for javac-compiled classes. This problem has been observed for classes that are:
Compiled by older versions of scalac
Classes that are part of the Android distribution
Caused by: java.lang.NoClassDefFoundError: Lcom/adobe/granite/toggle/api/ToggleRouter;
Caused by: java.lang.ClassNotFoundException: com.adobe.granite.toggle.api.ToggleRouter
`
The text was updated successfully, but these errors were encountered:
Bug Report
Current Behavior
I'm not able to mock com.day.cq.wcm.foundation.model.responsivegrid.ResponsiveGrid and other models
Expected behavior/code
A mocked version of the sling model.
Environment
Hello everyone,
I'm trying to perform some unit testings but I'm not able to mock some core component classes after update to new version of AEM SDK 2024.10.18459.20241031T210302Z-241000
I am using
@mock
private ResponsiveGrid responsiveGrid;
The error I'm getting is the following
`org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: class com.day.cq.wcm.foundation.model.responsivegrid.ResponsiveGrid.
If you're not sure why you're getting this error, please open an issue on GitHub.
Java : 11
JVM vendor name : Amazon.com Inc.
JVM vendor version : 11.0.15+9-LTS
JVM name : OpenJDK 64-Bit Server VM
JVM version : 11.0.15+9-LTS
JVM info : mixed mode
OS name : Mac OS X
OS version : 14.7
You are seeing this disclaimer because Mockito is configured to create inlined mocks.
You can learn about inline mocks and their limitations under item #39 of the Mockito class javadoc.
Underlying exception : org.mockito.exceptions.base.MockitoException: Could not modify all classes [class java.lang.Object, interface org.apache.sling.api.adapter.Adaptable, class com.day.cq.wcm.foundation.model.responsivegrid.ResponsiveGrid, interface org.apache.sling.api.resource.Resource, class org.apache.sling.api.adapter.SlingAdaptable, interface com.day.cq.wcm.foundation.model.responsivegrid.export.ResponsiveGridExporter, class org.apache.sling.api.resource.AbstractResource]
Caused by: org.mockito.exceptions.base.MockitoException: Could not modify all classes [class java.lang.Object, interface org.apache.sling.api.adapter.Adaptable, class com.day.cq.wcm.foundation.model.responsivegrid.ResponsiveGrid, interface org.apache.sling.api.resource.Resource, class org.apache.sling.api.adapter.SlingAdaptable, interface com.day.cq.wcm.foundation.model.responsivegrid.export.ResponsiveGridExporter, class org.apache.sling.api.resource.AbstractResource]
Caused by: java.lang.IllegalStateException:
Byte Buddy could not instrument all classes within the mock's type hierarchy
This problem should never occur for javac-compiled classes. This problem has been observed for classes that are:
Caused by: java.lang.NoClassDefFoundError: Lcom/adobe/granite/toggle/api/ToggleRouter;
Caused by: java.lang.ClassNotFoundException: com.adobe.granite.toggle.api.ToggleRouter
`
The text was updated successfully, but these errors were encountered: