Attempt to mock IMendixObject

2
HI! I am trying to write mock IMednix object. The problem arises when I this object to initialize method of the Proxy object. Essentially, in a constructor of the proxy Core.isSubClass method is used to check the type of the IMendix object as below : super(jobMendixObject); if (!Core.isSubClassOf(TYPE_1, jobMendixObject.getType())) throw new IllegalArgumentException("The given object is not a PipsAndSubbies.Job"); This is not an issue since I can make getType() method in my mock mendix object return String "TYPE_1". However in the constructor of the parent of the above proxy project is checking if mock mendix object is of different type : if (!Core.isSubClassOf(TYPE_2, auditableMendixObject.getType())) throw new IllegalArgumentException("The given object is not a PipsAndSubbies.Auditable"); The problem is that getType() method of my mock object is always going to return the same String and I cannot think of the way to dynamically return different values at runtime. Any ideas would be very welcome. Thanks in advance Ivan
asked
1 answers
1

Hi Ivan,

Some suggestions to solve your problem:

  • Maybe your mock object could have a constructor that takes a String type parameter, so it can return the type that you pass to the constructor?
  • Of course, you could also create several subclasses of your mock object, and return different types in these classes.

Hope this helps!

answered