Women in Technology

Hear us Roar

  Don't Let Hibernate Steal Your Identity
Subject:   What about unit testing?
Date:   2006-12-04 01:54:22
From:   MartinPallmann
Response to: What about unit testing?

No Problem,

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) {
this.id = idGenerator.generateId(this.getClass());