@Test public void shouldBeAbleToConvertAnAccountIntoAnAccountRepresentation() { Account account = account().withRole(role().build()).build(); AccountRepresentation representation = accountConversionService.convert(account); assertThat(representation.getId()).isEqualTo(account.getId()); assertThat(representation.getCreated()).isEqualTo(account.getCreated()); assertThat(representation.getUpdated()).isEqualTo(account.getUpdated()); assertThat(representation.getUsername()).isEqualTo(account.getUsername()); assertThat(representation.getPassword()).isNull(); assertThat(representation.getRoles()).hasSize(1); }
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);  }