@Test public void testConvertFromAppListItem() { Application responseApplication = applicationMapper.convert(applicationListItem, uriInfo); checkApplication(now, responseApplication, AppSettingsEnum.NO_SETTINGS); }
public Application convert(ApplicationListItem applicationListItem, UriInfo uriInfo) { final Application application = new Application(); application.setApplicationType(applicationListItem.getType()); application.setCreatedAt(applicationListItem.getCreatedAt().toInstant().atOffset(ZoneOffset.UTC)); application.setDescription(applicationListItem.getDescription()); Set<String> groupEntities = applicationListItem.getGroups(); if (groupEntities != null && !groupEntities.isEmpty()) { List<Group> groups = groupEntities.stream() .map(groupService::findById) .map(groupEntity -> new Group().id(groupEntity.getId()).name(groupEntity.getName())) .collect(Collectors.toList()); application.setGroups(groups); } application.setId(applicationListItem.getId()); application.setName(applicationListItem.getName()); UserEntity primaryOwnerUserEntity = userService.findById(applicationListItem.getPrimaryOwner().getId()); User owner = userMapper.convert(primaryOwnerUserEntity); owner.setLinks(userMapper.computeUserLinks(usersURL(uriInfo.getBaseUriBuilder(), primaryOwnerUserEntity.getId()), primaryOwnerUserEntity.getUpdatedAt())); application.setOwner(owner); application.setUpdatedAt(applicationListItem.getUpdatedAt().toInstant().atOffset(ZoneOffset.UTC)); ApplicationListItemSettings settings = applicationListItem.getSettings(); application.setHasClientId(settings != null && settings.getClientId() != null && !settings.getClientId().isEmpty()); return application; }
ApplicationMapper { public Application convert(ApplicationListItem applicationListItem, UriInfo uriInfo) { final Application application = new Application(); application.setApplicationType(applicationListItem.getType()); application.setCreatedAt(applicationListItem.getCreatedAt().toInstant().atOffset(ZoneOffset.UTC)); application.setDescription(applicationListItem.getDescription()); Set<String> groupEntities = applicationListItem.getGroups(); if (groupEntities != null && !groupEntities.isEmpty()) { List<Group> groups = groupEntities.stream() .map(groupService::findById) .map(groupEntity -> new Group().id(groupEntity.getId()).name(groupEntity.getName())) .collect(Collectors.toList()); application.setGroups(groups); } application.setId(applicationListItem.getId()); application.setName(applicationListItem.getName()); UserEntity primaryOwnerUserEntity = userService.findById(applicationListItem.getPrimaryOwner().getId()); User owner = userMapper.convert(primaryOwnerUserEntity); owner.setLinks(userMapper.computeUserLinks(usersURL(uriInfo.getBaseUriBuilder(), primaryOwnerUserEntity.getId()), primaryOwnerUserEntity.getUpdatedAt())); application.setOwner(owner); application.setUpdatedAt(applicationListItem.getUpdatedAt().toInstant().atOffset(ZoneOffset.UTC)); ApplicationListItemSettings settings = applicationListItem.getSettings(); application.setHasClientId(settings != null && settings.getClientId() != null && !settings.getClientId().isEmpty()); return application; } }
ApplicationMapper { public Application convert(ApplicationListItem applicationListItem, UriInfo uriInfo) { final Application application = new Application(); application.setApplicationType(applicationListItem.getType()); application.setCreatedAt(applicationListItem.getCreatedAt().toInstant().atOffset(ZoneOffset.UTC)); application.setDescription(applicationListItem.getDescription()); Set<String> groupEntities = applicationListItem.getGroups(); if (groupEntities != null && !groupEntities.isEmpty()) { List<Group> groups = groupEntities.stream() .map(groupService::findById) .map(groupEntity -> new Group().id(groupEntity.getId()).name(groupEntity.getName())) .collect(Collectors.toList()); application.setGroups(groups); } application.setId(applicationListItem.getId()); application.setName(applicationListItem.getName()); UserEntity primaryOwnerUserEntity = userService.findById(applicationListItem.getPrimaryOwner().getId()); User owner = userMapper.convert(primaryOwnerUserEntity); owner.setLinks(userMapper.computeUserLinks(usersURL(uriInfo.getBaseUriBuilder(), primaryOwnerUserEntity.getId()), primaryOwnerUserEntity.getUpdatedAt())); application.setOwner(owner); application.setUpdatedAt(applicationListItem.getUpdatedAt().toInstant().atOffset(ZoneOffset.UTC)); ApplicationListItemSettings settings = applicationListItem.getSettings(); application.setHasClientId(settings != null && settings.getClientId() != null && !settings.getClientId().isEmpty()); return application; }  }
ApplicationMapper { public Application convert(ApplicationListItem applicationListItem, UriInfo uriInfo) { final Application application = new Application(); application.setApplicationType(applicationListItem.getType()); application.setCreatedAt(applicationListItem.getCreatedAt().toInstant().atOffset(ZoneOffset.UTC)); application.setDescription(applicationListItem.getDescription()); Set<String> groupEntities = applicationListItem.getGroups(); if (groupEntities != null && !groupEntities.isEmpty()) { List<Group> groups = groupEntities.stream() .map(groupService::findById) .map(groupEntity -> new Group().id(groupEntity.getId()).name(groupEntity.getName())) .collect(Collectors.toList()); application.setGroups(groups); } application.setId(applicationListItem.getId()); application.setName(applicationListItem.getName()); UserEntity primaryOwnerUserEntity = userService.findById(applicationListItem.getPrimaryOwner().getId()); User owner = userMapper.convert(primaryOwnerUserEntity); owner.setLinks(userMapper.computeUserLinks(usersURL(uriInfo.getBaseUriBuilder(), primaryOwnerUserEntity.getId()), primaryOwnerUserEntity.getUpdatedAt())); application.setOwner(owner); application.setUpdatedAt(applicationListItem.getUpdatedAt().toInstant().atOffset(ZoneOffset.UTC)); ApplicationListItemSettings settings = applicationListItem.getSettings(); application.setHasClientId(settings != null && settings.getClientId() != null && !settings.getClientId().isEmpty()); return application; }  Application convert(ApplicationListItem applicationListItem, UriInfo uriInfo); ApplicationLinks computeApplicationLinks(String basePath, OffsetDateTime updateDate); Application convert(ApplicationEntity applicationEntity, UriInfo uriInfo); }
ApplicationMapper { public Application convert(ApplicationListItem applicationListItem, UriInfo uriInfo) { final Application application = new Application(); application.setApplicationType(applicationListItem.getType()); application.setCreatedAt(applicationListItem.getCreatedAt().toInstant().atOffset(ZoneOffset.UTC)); application.setDescription(applicationListItem.getDescription()); Set<String> groupEntities = applicationListItem.getGroups(); if (groupEntities != null && !groupEntities.isEmpty()) { List<Group> groups = groupEntities.stream() .map(groupService::findById) .map(groupEntity -> new Group().id(groupEntity.getId()).name(groupEntity.getName())) .collect(Collectors.toList()); application.setGroups(groups); } application.setId(applicationListItem.getId()); application.setName(applicationListItem.getName()); UserEntity primaryOwnerUserEntity = userService.findById(applicationListItem.getPrimaryOwner().getId()); User owner = userMapper.convert(primaryOwnerUserEntity); owner.setLinks(userMapper.computeUserLinks(usersURL(uriInfo.getBaseUriBuilder(), primaryOwnerUserEntity.getId()), primaryOwnerUserEntity.getUpdatedAt())); application.setOwner(owner); application.setUpdatedAt(applicationListItem.getUpdatedAt().toInstant().atOffset(ZoneOffset.UTC)); ApplicationListItemSettings settings = applicationListItem.getSettings(); application.setHasClientId(settings != null && settings.getClientId() != null && !settings.getClientId().isEmpty()); return application; }  Application convert(ApplicationListItem applicationListItem, UriInfo uriInfo); ApplicationLinks computeApplicationLinks(String basePath, OffsetDateTime updateDate); Application convert(ApplicationEntity applicationEntity, UriInfo uriInfo);  }