### Question:
WorkerService implements WorkerServiceI { @Override public Worker editWorker(String login, Worker editedWorker) throws BaseException { Worker worker = workerRepository.findWorkerByLogin(login); if (worker == null) { throw new WorkerDontExistsException("Edited worker dont exists"); } return workerRepository.updateWorker(new Worker(login, editedWorker.getName(), editedWorker.getSurname(), editedWorker.getEmail())); } @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 editWorker_Success() { try { Worker editedWorker = nonExisitngWorker(); Worker result = workerService.editWorker(EXISTING_LOGIN, editedWorker); assertEquals(EXISTING_LOGIN, result.getLogin()); assertEquals(OTHER_NAME, result.getName()); assertEquals(OTHER_SURNAME, result.getSurname()); assertEquals(OTHER_EMAIL, result.getEmail()); assertEquals(1, getWorkerRepositoryStub().getWorkerList().size()); } catch (Exception e) { fail(String.format("Error in editing worker: %s", e.getMessage())); } }
@Test(expected = WorkerDontExistsException.class) public void editWorker_WorkerDontExist() throws BaseException { workerService.editWorker(NON_EXISTING_LOGIN, null); }