simply don't instanciate the IdGenerator in the class but reach it in as parameter of the constructor of your class.
So you can implement a Mock-Id-Generator and have control over the ids.
like this: public AbstractPersistentObject(final IIdGenerator idGenerator) { super(); this.id = idGenerator.generateId(this.getClass()); }
public AbstractPersistentObject(final IIdGenerator idGenerator) { super(); this.id = idGenerator.generateId(this.getClass()); }