### Question:
MotechUserRepository { public User newUser(WebStaff webStaff) { User user = new User(); user.setSystemId(identifierGenerator.generateStaffId()); user.setGender(MotechConstants.GENDER_UNKNOWN_OPENMRS); PersonName name = new PersonName(webStaff.getFirstName(), null, webStaff.getLastName()); user.addName(name); String phoneValue = webStaff.getPhone() == null ? "" : webStaff.getPhone(); String typeValue = webStaff.getType() == null ? "" : webStaff.getType(); createPhoneNumber(user, phoneValue); createType(user, typeValue); Role role = userService.getRole(OpenmrsConstants.PROVIDER_ROLE); user.addRole(role); return user; } MotechUserRepository(IdentifierGenerator identifierGenerator, UserService userService, PersonService personService, MotechUsers motechUsers); User newUser(WebStaff webStaff); User updateUser(User staff, WebStaff webStaff); MotechUserTypes userTypes();  }### Answer:
@Test public void testNewUser() throws Exception { PersonService personService = mock(PersonService.class); IdentifierGenerator identifierGenerator = mock(IdentifierGenerator.class); UserService userService = mock(UserService.class); Role role = mock(Role.class); PersonAttributeType phoneNumberAttributeType = new PersonAttributeType(); phoneNumberAttributeType.setId(1); PersonAttributeType staffTypeAttributeType = new PersonAttributeType(); staffTypeAttributeType.setId(2); when(identifierGenerator.generateStaffId()).thenReturn("27"); when(personService.getPersonAttributeTypeByName(PersonAttributeTypeEnum.PERSON_ATTRIBUTE_PHONE_NUMBER.getAttributeName())).thenReturn(phoneNumberAttributeType); when(personService.getPersonAttributeTypeByName(PersonAttributeTypeEnum.PERSON_ATTRIBUTE_STAFF_TYPE.getAttributeName())).thenReturn(staffTypeAttributeType); when(userService.getRole("Provider")).thenReturn(role); MotechUserRepository motechUserRepository = new MotechUserRepository(identifierGenerator, userService, personService, motechUsers); User user = motechUserRepository.newUser(new WebStaff("Jenny", "Jones ", "1001", "CHO")); verify(identifierGenerator).generateStaffId(); verify(personService).getPersonAttributeTypeByName("Phone Number"); verify(personService).getPersonAttributeTypeByName("Staff Type"); verify(userService).getRole("Provider"); assertThat(user.getSystemId(), equalTo("27")); }