@Test public void shouldBeAbleToConvertAnAccountRepresentationIntoANewAccount() { Role role = role().save(); AccountRepresentation representation = AccountDSL.account().withRoles(roleConversionService.convert(role)).build(); Account account = accountConversionService.convert(representation); assertThat(account.getUsername()).isEqualTo(representation.getUsername()); assertThat(account.getPassword()).isEqualTo(representation.getPassword()); assertThat(account.getRoles()).hasSize(1); assertThat(account.getRoles()).contains(role); }
public AccountRepresentation convert(Account account) { AccountRepresentation representation = new AccountRepresentation(); representation.setId(account.getId()); representation.setCreated(account.getCreated()); representation.setUpdated(account.getUpdated()); representation.setUsername(account.getUsername()); representation.setLocked(account.isLocked()); representation.setRoles(account.getRoles().stream().map(role -> roleConversionService.convert(role)).collect(Collectors.toSet())); return representation; }
AccountConversionService { public AccountRepresentation convert(Account account) { AccountRepresentation representation = new AccountRepresentation(); representation.setId(account.getId()); representation.setCreated(account.getCreated()); representation.setUpdated(account.getUpdated()); representation.setUsername(account.getUsername()); representation.setLocked(account.isLocked()); representation.setRoles(account.getRoles().stream().map(role -> roleConversionService.convert(role)).collect(Collectors.toSet())); return representation; } }
AccountConversionService { public AccountRepresentation convert(Account account) { AccountRepresentation representation = new AccountRepresentation(); representation.setId(account.getId()); representation.setCreated(account.getCreated()); representation.setUpdated(account.getUpdated()); representation.setUsername(account.getUsername()); representation.setLocked(account.isLocked()); representation.setRoles(account.getRoles().stream().map(role -> roleConversionService.convert(role)).collect(Collectors.toSet())); return representation; } @Autowired  AccountConversionService(RoleService roleService, RoleConversionService roleConversionService); }
AccountConversionService { public AccountRepresentation convert(Account account) { AccountRepresentation representation = new AccountRepresentation(); representation.setId(account.getId()); representation.setCreated(account.getCreated()); representation.setUpdated(account.getUpdated()); representation.setUsername(account.getUsername()); representation.setLocked(account.isLocked()); representation.setRoles(account.getRoles().stream().map(role -> roleConversionService.convert(role)).collect(Collectors.toSet())); return representation; } @Autowired  AccountConversionService(RoleService roleService, RoleConversionService roleConversionService); AccountRepresentation convert(Account account); Account convert(AccountRepresentation representation); Account convert(AccountRepresentation representation, Account account); }
AccountConversionService { public AccountRepresentation convert(Account account) { AccountRepresentation representation = new AccountRepresentation(); representation.setId(account.getId()); representation.setCreated(account.getCreated()); representation.setUpdated(account.getUpdated()); representation.setUsername(account.getUsername()); representation.setLocked(account.isLocked()); representation.setRoles(account.getRoles().stream().map(role -> roleConversionService.convert(role)).collect(Collectors.toSet())); return representation; } @Autowired  AccountConversionService(RoleService roleService, RoleConversionService roleConversionService); AccountRepresentation convert(Account account); Account convert(AccountRepresentation representation); Account convert(AccountRepresentation representation, Account account);  }