Search in sources :

Example 1 with Application

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);
}
Also used : Application(io.gravitee.rest.api.portal.rest.model.Application) Test(org.junit.Test)

Example 2 with Application

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);
}
Also used : ApplicationSettings(io.gravitee.rest.api.model.application.ApplicationSettings) SimpleApplicationSettings(io.gravitee.rest.api.model.application.SimpleApplicationSettings) SimpleApplicationSettings(io.gravitee.rest.api.model.application.SimpleApplicationSettings) Application(io.gravitee.rest.api.portal.rest.model.Application) Test(org.junit.Test)

Example 3 with Application

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);
}
Also used : Application(io.gravitee.rest.api.portal.rest.model.Application) Test(org.junit.Test)

Example 4 with Application

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);
}
Also used : ApplicationSettings(io.gravitee.rest.api.model.application.ApplicationSettings) SimpleApplicationSettings(io.gravitee.rest.api.model.application.SimpleApplicationSettings) OAuthClientSettings(io.gravitee.rest.api.model.application.OAuthClientSettings) Application(io.gravitee.rest.api.portal.rest.model.Application) Test(org.junit.Test)

Example 5 with Application

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;
}
Also used : ApplicationSettings(io.gravitee.rest.api.model.application.ApplicationSettings) OAuthClientSettings(io.gravitee.rest.api.model.application.OAuthClientSettings) Group(io.gravitee.rest.api.portal.rest.model.Group) ApplicationListItem(io.gravitee.rest.api.model.application.ApplicationListItem) GroupService(io.gravitee.rest.api.service.GroupService) Set(java.util.Set) Autowired(org.springframework.beans.factory.annotation.Autowired) SimpleApplicationSettings(io.gravitee.rest.api.model.application.SimpleApplicationSettings) User(io.gravitee.rest.api.portal.rest.model.User) Collectors(java.util.stream.Collectors) Application(io.gravitee.rest.api.portal.rest.model.Application) List(java.util.List) Component(org.springframework.stereotype.Component) OffsetDateTime(java.time.OffsetDateTime) UserService(io.gravitee.rest.api.service.UserService) ZoneOffset(java.time.ZoneOffset) UriInfo(javax.ws.rs.core.UriInfo) PortalApiLinkHelper.usersURL(io.gravitee.rest.api.portal.rest.utils.PortalApiLinkHelper.usersURL) ApplicationEntity(io.gravitee.rest.api.model.ApplicationEntity) UserEntity(io.gravitee.rest.api.model.UserEntity) ApplicationLinks(io.gravitee.rest.api.portal.rest.model.ApplicationLinks) Group(io.gravitee.rest.api.portal.rest.model.Group) ApplicationSettings(io.gravitee.rest.api.model.application.ApplicationSettings) SimpleApplicationSettings(io.gravitee.rest.api.model.application.SimpleApplicationSettings) User(io.gravitee.rest.api.portal.rest.model.User) Application(io.gravitee.rest.api.portal.rest.model.Application) UserEntity(io.gravitee.rest.api.model.UserEntity)

Aggregations

Application (io.gravitee.rest.api.portal.rest.model.Application)11 Test (org.junit.Test)7 ApplicationEntity (io.gravitee.rest.api.model.ApplicationEntity)6 ApplicationSettings (io.gravitee.rest.api.model.application.ApplicationSettings)5 SimpleApplicationSettings (io.gravitee.rest.api.model.application.SimpleApplicationSettings)5 SubscriptionEntity (io.gravitee.rest.api.model.SubscriptionEntity)4 TopHitsAnalytics (io.gravitee.rest.api.model.analytics.TopHitsAnalytics)4 GroupByQuery (io.gravitee.rest.api.model.analytics.query.GroupByQuery)4 ApplicationListItem (io.gravitee.rest.api.model.application.ApplicationListItem)4 OAuthClientSettings (io.gravitee.rest.api.model.application.OAuthClientSettings)4 Response (javax.ws.rs.core.Response)4 UserEntity (io.gravitee.rest.api.model.UserEntity)3 ApplicationsResponse (io.gravitee.rest.api.portal.rest.model.ApplicationsResponse)3 ErrorResponse (io.gravitee.rest.api.portal.rest.model.ErrorResponse)3 Collectors (java.util.stream.Collectors)3 ApiEntity (io.gravitee.rest.api.model.api.ApiEntity)2 ApiQuery (io.gravitee.rest.api.model.api.ApiQuery)2 SubscriptionQuery (io.gravitee.rest.api.model.subscription.SubscriptionQuery)2 ApplicationLinks (io.gravitee.rest.api.portal.rest.model.ApplicationLinks)2 Group (io.gravitee.rest.api.portal.rest.model.Group)2