use of io.gravitee.rest.api.portal.rest.model.Application in project gravitee-management-rest-api by gravitee-io.
the class ApplicationMapperTest method testConvertFromAppEntityNoSettings.
@Test
public void testConvertFromAppEntityNoSettings() {
Application responseApplication = applicationMapper.convert(applicationEntity, uriInfo);
checkApplication(now, responseApplication, AppSettingsEnum.NO_SETTINGS);
}
use of io.gravitee.rest.api.portal.rest.model.Application in project gravitee-management-rest-api by gravitee-io.
the class ApplicationMapperTest method testConvertFromAppEntitySimpleApp.
@Test
public void testConvertFromAppEntitySimpleApp() {
ApplicationSettings settings = new ApplicationSettings();
SimpleApplicationSettings simpleAppEntitySetings = new SimpleApplicationSettings();
simpleAppEntitySetings.setClientId(APPLICATION_SIMPLE_CLIENT_ID);
simpleAppEntitySetings.setType(APPLICATION_SIMPLE_TYPE);
settings.setApp(simpleAppEntitySetings);
applicationEntity.setSettings(settings);
Application responseApplication = applicationMapper.convert(applicationEntity, uriInfo);
checkApplication(now, responseApplication, AppSettingsEnum.SIMPLE_SETTINGS);
}
use of io.gravitee.rest.api.portal.rest.model.Application in project gravitee-management-rest-api by gravitee-io.
the class ApplicationMapperTest method testConvertFromAppListItem.
@Test
public void testConvertFromAppListItem() {
Application responseApplication = applicationMapper.convert(applicationListItem, uriInfo);
checkApplication(now, responseApplication, AppSettingsEnum.NO_SETTINGS);
}
use of io.gravitee.rest.api.portal.rest.model.Application in project gravitee-management-rest-api by gravitee-io.
the class ApplicationMapperTest method testConvertFromAppEntityOAuthClient.
@Test
public void testConvertFromAppEntityOAuthClient() {
ApplicationSettings settings = new ApplicationSettings();
OAuthClientSettings oAuthClientEntitySettings = new OAuthClientSettings();
oAuthClientEntitySettings.setApplicationType(APPLICATION_OAUTH_APPLICATION_TYPE);
oAuthClientEntitySettings.setClientId(APPLICATION_OAUTH_CLIENT_ID);
oAuthClientEntitySettings.setClientSecret(APPLICATION_OAUTH_CLIENT_SECRET);
oAuthClientEntitySettings.setClientUri(APPLICATION_OAUTH_CLIENT_URI);
oAuthClientEntitySettings.setGrantTypes(Arrays.asList(APPLICATION_OAUTH_GRANT_TYPE));
oAuthClientEntitySettings.setLogoUri(APPLICATION_OAUTH_LOGO_URI);
oAuthClientEntitySettings.setRedirectUris(Arrays.asList(APPLICATION_OAUTH_REDIRECT_URI));
oAuthClientEntitySettings.setRenewClientSecretSupported(true);
oAuthClientEntitySettings.setResponseTypes(Arrays.asList(APPLICATION_OAUTH_RESPONSE_TYPE));
settings.setoAuthClient(oAuthClientEntitySettings);
applicationEntity.setSettings(settings);
Application responseApplication = applicationMapper.convert(applicationEntity, uriInfo);
checkApplication(now, responseApplication, AppSettingsEnum.OAUTH_SETTINGS);
}
use of io.gravitee.rest.api.portal.rest.model.Application in project gravitee-management-rest-api by gravitee-io.
the class ApplicationMapper method convert.
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));
ApplicationSettings settings = applicationListItem.getSettings();
application.setHasClientId(settings != null && ((settings.getoAuthClient() != null && settings.getoAuthClient().getClientId() != null && !settings.getoAuthClient().getClientId().isEmpty()) || (settings.getApp() != null && settings.getApp().getClientId() != null && !settings.getApp().getClientId().isEmpty())));
return application;
}
Aggregations