### Question:
WorkerService implements WorkerServiceI { @Override public Worker createWorker(Worker worker) throws BaseException { if (workerRepository.findWorkerByLogin(worker.getLogin()) != null) { throw new WorkerExistsException("Worker already exists"); } return workerRepository.saveWorker(worker); } @Inject  WorkerService(WorkerRepositoryI workerRepository); @Override Worker createWorker(Worker worker); @Override Worker editWorker(String login, Worker editedWorker); @Override Worker deleteWorker(String login); @Override Worker findWorkerByLogin(String login);  }### Answer:
@Test public void createWorker_Success() { try { Worker newWorker = nonExisitngWorker(); Worker result = workerService.createWorker(newWorker); assertEquals(newWorker.getLogin(), result.getLogin()); assertEquals(newWorker.getName(), result.getName()); assertEquals(newWorker.getSurname(), result.getSurname()); assertEquals(newWorker.getEmail(), result.getEmail()); assertEquals(2, getWorkerRepositoryStub().getWorkerList().size()); } catch (Exception e) { fail(String.format("Error in creating worker: %s", e.getMessage())); } }
@Test(expected = WorkerExistsException.class) public void createWorker_WorkerExist() throws BaseException { workerService.createWorker(exisitngWorker()); }