### Question:
UserConverter implements ToServerConverter<ClientUser, User, ToServerConversionOptions>, ToClientConverter<User, ClientUser, ToClientConversionOptions> { @Override public User toServer(ClientUser clientObject, User user, ToServerConversionOptions options) throws IllegalParameterValueException, MandatoryParameterNotFoundException { if (clientObject.getTenantId() != null) user.setTenantId(clientObject.getTenantId()); if (clientObject.getUsername() != null) user.setUsername(clientObject.getUsername()); if (clientObject.getEmailAddress() != null) user.setEmailAddress(clientObject.getEmailAddress()); if (clientObject.getFullName() != null) user.setFullName(clientObject.getFullName()); if (clientObject.isEnabled() != null) user.setEnabled(clientObject.isEnabled()); if (clientObject.isExternallyDefined() != null) user.setExternallyDefined(clientObject.isExternallyDefined()); if (clientObject.getPassword() != null) { if (user.getPassword()!= null && !clientObject.getPassword().equals(user.getPassword())){ user.setPreviousPasswordChangeTime(new Date()); } String pwd = tryDecryptPwdFromJCryption(clientObject.getPassword()); user.setPassword(pwd); } if (clientObject.getRoleSet() != null) { Set<Role> newRoles = new HashSet<Role>(); for (ClientRole role: clientObject.getRoleSet()){ newRoles.add(roleConverter.toServer(role, null)); } user.setRoles(newRoles); } return user; }  @Override ClientUser toClient(User user, ToClientConversionOptions options); @Override User toServer(ClientUser clientObject, User user, ToServerConversionOptions options); @Override User toServer(ClientUser clientObject, ToServerConversionOptions options); @Override String getServerResourceType(); @Override String getClientResourceType();  }### Answer:
@Test public void testToServer() throws Exception { User converted = converter.toServer(client, null); assertEquals(converted.getFullName(), client.getFullName()); assertEquals(converted.getEmailAddress(), client.getEmailAddress()); assertEquals(converted.getPassword(), client.getPassword()); assertEquals(converted.getTenantId(), client.getTenantId()); assertEquals(converted.getUsername(), client.getUsername()); assertEquals((Boolean)converted.isEnabled(), client.isEnabled()); assertEquals((Boolean)converted.isExternallyDefined(), client.isExternallyDefined()); assertTrue(converted.getRoles().contains(serverRole)); }
@Test public void testToServer_update() throws Exception { User converted = converter.toServer(client, server, null); assertEquals(converted.getFullName(), client.getFullName()); assertEquals(converted.getEmailAddress(), client.getEmailAddress()); assertEquals(converted.getPassword(), client.getPassword()); assertEquals(converted.getTenantId(), client.getTenantId()); assertEquals(converted.getUsername(), client.getUsername()); assertEquals((Boolean)converted.isEnabled(), client.isEnabled()); assertEquals((Boolean)converted.isExternallyDefined(), client.isExternallyDefined()); assertTrue(converted.getRoles().contains(serverRole)); }
@Test(enabled = false) public void testToServer_setsTimeOnPassChange() throws Exception { User converted = converter.toServer(client, server, null); assertNotNull(converted.getPreviousPasswordChangeTime()); }