im trying to Mock below class.
public class testEntityDO extends BasetestDO {
private String entityType;
private testCapabilityDO[] capabilities;
private testEntityDO[] testDOs;
public String getEntityType() {
return entityType;
}
public void setEntityType(String entityType) {
this.entityType = entityType;
}
public testCapabilityDO[] getCapabilities() {
return capabilities;
}
public void setCapabilities(testCapabilityDO[] capabilities) {
this.capabilities = capabilities;
}
public TestEntityDO[] getTestPortDOs() {
return testPortDOs;
}
public void setTestPortDOs(TestEntityDO[] testPortDOs) {
this.testPortDOs = testPortDOs;
}
}
Code to be Mocked:
TestEntityDO[] testEntityMock = testmethod.getTestEntityDO();
Mocking i tried:
TestEntityDO[] testEntityDOMock = PowerMock.createMock(TestEntityDO[].class); // exception is generating at this point
EasyMock.expect(testmethod.getTestEntityDO()).andReturn(testEntityDOMock);
exception trace:
java.lang.IllegalArgumentException: Cannot subclass final class class [Lcom.package.TestEntityDO;
at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:446)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
at net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:317)
class is not a final class. still the exception is pointed as final class. please help me to solve this issue.
You're trying to create a subclass/mock of an array of TestEntityDO
. Arrays are final.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With