public void testWorkerValid() throws ValidationException,
InstanceNotFoundException {
IResourceDAO resourceDAOMock = createMock(IResourceDAO.class);
ICriterionDAO criterionServiceMock = createMock(ICriterionDAO.class);
Worker workerToReturn = Worker.create();
workerToReturn.setFirstName("firstName");
workerToReturn.setSurname("surname");
workerToReturn.setNif("232344243");
// expectations
List<Criterion> criterions = new ArrayList<Criterion>();
expect(
criterionServiceMock
.findByType(PredefinedCriterionTypes.LOCATION))
.andReturn(criterions).anyTimes();
expect(resourceDAOMock.find(workerToReturn.getId()))
.andReturn(workerToReturn);
resourceDAOMock.save(workerToReturn);
workerToReturn.checkNotOverlaps();
replay(resourceDAOMock, criterionServiceMock);
// perform actions
WorkerModel workerModel = new WorkerModel(resourceDAOMock,
criterionServiceMock);