I am using spock for my test cases and I am stubbing a class as below, inventryDAO has a method getUser which accepts a argument of type PersistableKey.
In the main code the argument is created as below
PersistableKey userKey = new PersistableKey(1)
userKey.setRepresentedObjectClass(User.class);
In my Specification if I write the stub and argument as below, it works fine
User collUser = new User(1);
InventoryDAO inventoryDAO = Stub()
PersistableKey userKey = new PersistableKey(1)
userKey.setRepresentedObjectClass(User.class);
inventoryDAO.getUser(userKey) >> collUser
But what I really want to do is to be able to pass argument without setting the setRepresentedObjectClass, something like this
User collUser = new User(1);
InventoryDAO inventoryDAO = Stub()
PersistableKey userKey = new PersistableKey(1)
inventoryDAO.getUser(userKey) >> collUser
Is it possible to match the argument based on partial values ?