My favorites | Sign in
Project Home Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 1: Inheritance problem
1 person starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----


 
Reported by ccha...@gmail.com, Jan 25, 2012
What steps will reproduce the problem?

abstract class AbstractBase extends Serializable {
...
}

class Operator extends AbstractBase {
...
}

abstract class DataFixture {

	private static JPAMock jpaMock = new JPAMock(null);

	static {
		jpaMock.clearAll();
	}

	public static Operator createOperator() {
		Operator operator = jpaMock.mock(Operator.class);
		return operator;
	}

	public static void main(String[] args) {

		System.out.println(createOperator());
	}

}


What do you see instead?

Exception in thread "main" java.lang.RuntimeException: Is Serializable an abstract class or interface? Try setup jpaMock.when(Serializable).thenInstance(?)
	at jpamock.instance.NewInstance.newInstance(NewInstance.java:24)
	at jpamock.instance.SmartMap.get(SmartMap.java:15)
	at jpamock.instance.FluentApi$2.propertyCallBack(FluentApi.java:72)
	at jpamock.persitence.RecursiveSearch.startReal(RecursiveSearch.java:49)
	at jpamock.persitence.RecursiveSearch.startReal(RecursiveSearch.java:63)
	at jpamock.persitence.RecursiveSearch.startReal(RecursiveSearch.java:50)
	at jpamock.persitence.RecursiveSearch.startReal(RecursiveSearch.java:63)
	at jpamock.persitence.RecursiveSearch.startReal(RecursiveSearch.java:50)
	at jpamock.persitence.RecursiveSearch.startReal(RecursiveSearch.java:63)
	at jpamock.persitence.RecursiveSearch.startReal(RecursiveSearch.java:50)
	at jpamock.persitence.RecursiveSearch.startReal(RecursiveSearch.java:63)
	at jpamock.persitence.RecursiveSearch.startReal(RecursiveSearch.java:50)
	at jpamock.persitence.RecursiveSearch.startReal(RecursiveSearch.java:63)
	at jpamock.persitence.RecursiveSearch.startReal(RecursiveSearch.java:50)
	at jpamock.persitence.RecursiveSearch.start(RecursiveSearch.java:25)
	at jpamock.instance.FluentApi.getValue(FluentApi.java:63)
	at jpamock.instance.JPAMock.mock(JPAMock.java:36)
	at net.mlat.ims.domain.operator.DataFixture.createOperator(DataFixture.java:14)
	at net.mlat.ims.domain.operator.DataFixture.main(DataFixture.java:20)


Jan 26, 2012
Project Member #1 celiovasconcelos@gmail.com
Setup you test case with something like this:

jpaMock.when(Order.class, "mySerializableProperty").thenInject(new MyClassThatImplementsSerializable());
Jan 26, 2012
#2 ccha...@gmail.com
Thanks, that solved my problem
May 29, 2013
#3 joeamo...@gmail.com
Hello, 

I am trying to do the same thing but I still get the above error.

Report extends AbstractEntity<ID extends Serializable> implements Serializable

I'm trying to do this:
jpaMock.when(Report.class, "serialVersionUID").thenInject(Report.class);
Report report = jpaMock.mock(Report.class);

But I still get the error. Can you help me with what I am doing wrong?

Thanks!
May 29, 2013
#4 joeamo...@gmail.com
It looks like I am able to get it to work like so:
        jpaMock = new JPAMock(entityManager.getEntityManagerFactory());
        jpaMock.when(Serializable.class).thenInject(new Report());
        Report report = jpaMock.mock(Report.class);

However, I am getting an error when I try to use my HSQL DB for testing (disableConstaints not implemented for HSQL Database Engine). I am opening a new issue for it.

Powered by Google Project Hosting