use of io.gravitee.rest.api.model.ApplicationEntity in project gravitee-management-rest-api by gravitee-io.
the class ApplicationMetadataServiceImpl method checkReferenceMetadataFormat.
@Override
protected void checkReferenceMetadataFormat(MetadataFormat format, String value, MetadataReferenceType referenceType, String referenceId) {
final ApplicationEntity applicationEntity = applicationService.findById(referenceId);
metadataService.checkMetadataFormat(format, value, referenceType, applicationEntity);
}
use of io.gravitee.rest.api.model.ApplicationEntity in project gravitee-management-rest-api by gravitee-io.
the class ApiSubscribersResourceTest method shouldGetApiSubscribersAsPrimaryOwnerAlphaSorted.
@Test
public void shouldGetApiSubscribersAsPrimaryOwnerAlphaSorted() {
TopHitsAnalytics mockAnalytics = new TopHitsAnalytics();
Map<String, Long> mockedValues = new HashMap<>();
mockedValues.put("A", 0L);
mockedValues.put("C", 0L);
mockedValues.put("B", 0L);
mockAnalytics.setValues(mockedValues);
doReturn(mockAnalytics).when(analyticsService).execute(any(GroupByQuery.class));
SubscriptionEntity subA1 = new SubscriptionEntity();
subA1.setApplication("A");
subA1.setApi(API);
SubscriptionEntity subB1 = new SubscriptionEntity();
subB1.setApplication("B");
subB1.setApi(API);
SubscriptionEntity subC1 = new SubscriptionEntity();
subC1.setApplication("C");
subC1.setApi(API);
doReturn(Arrays.asList(subB1, subC1, subA1)).when(subscriptionService).search(any());
ApplicationEntity appA = new ApplicationEntity();
appA.setId("A");
appA.setName("A");
doReturn(appA).when(applicationService).findById("A");
doReturn(new Application().id("A").name("A")).when(applicationMapper).convert(eq(appA), any());
ApplicationEntity appB = new ApplicationEntity();
appB.setId("B");
appB.setName("B");
doReturn(appB).when(applicationService).findById("B");
doReturn(new Application().id("B").name("B")).when(applicationMapper).convert(eq(appB), any());
ApplicationEntity appC = new ApplicationEntity();
appC.setId("C");
appC.setName("C");
doReturn(appC).when(applicationService).findById("C");
doReturn(new Application().id("C").name("C")).when(applicationMapper).convert(eq(appC), any());
final Response response = target(API).path("subscribers").request().get();
assertEquals(OK_200, response.getStatus());
final ApplicationsResponse applicationsResponse = response.readEntity(ApplicationsResponse.class);
assertNotNull(applicationsResponse);
assertEquals(3, applicationsResponse.getData().size());
assertEquals("A", applicationsResponse.getData().get(0).getId());
assertEquals("B", applicationsResponse.getData().get(1).getId());
assertEquals("C", applicationsResponse.getData().get(2).getId());
}
use of io.gravitee.rest.api.model.ApplicationEntity in project gravitee-management-rest-api by gravitee-io.
the class ApiSubscribersResourceTest method shouldGetApiSubscribersAsPrimaryOwner.
@Test
public void shouldGetApiSubscribersAsPrimaryOwner() {
TopHitsAnalytics mockAnalytics = new TopHitsAnalytics();
Map<String, Long> mockedValues = new HashMap<>();
mockedValues.put("A", 10L);
mockedValues.put("B", 20L);
mockedValues.put("C", 30L);
mockAnalytics.setValues(mockedValues);
doReturn(mockAnalytics).when(analyticsService).execute(any(GroupByQuery.class));
SubscriptionEntity subA1 = new SubscriptionEntity();
subA1.setApplication("A");
subA1.setApi(API);
SubscriptionEntity subB1 = new SubscriptionEntity();
subB1.setApplication("B");
subB1.setApi(API);
SubscriptionEntity subC1 = new SubscriptionEntity();
subC1.setApplication("C");
subC1.setApi(API);
doReturn(Arrays.asList(subB1, subC1, subA1)).when(subscriptionService).search(any());
ApplicationEntity appA = new ApplicationEntity();
appA.setId("A");
doReturn(appA).when(applicationService).findById("A");
doReturn(new Application().id("A")).when(applicationMapper).convert(eq(appA), any());
ApplicationEntity appB = new ApplicationEntity();
appB.setId("B");
doReturn(appB).when(applicationService).findById("B");
doReturn(new Application().id("B")).when(applicationMapper).convert(eq(appB), any());
ApplicationEntity appC = new ApplicationEntity();
appC.setId("C");
doReturn(appC).when(applicationService).findById("C");
doReturn(new Application().id("C")).when(applicationMapper).convert(eq(appC), any());
final Response response = target(API).path("subscribers").request().get();
assertEquals(OK_200, response.getStatus());
final ApplicationsResponse applicationsResponse = response.readEntity(ApplicationsResponse.class);
assertNotNull(applicationsResponse);
assertEquals(3, applicationsResponse.getData().size());
assertEquals("C", applicationsResponse.getData().get(0).getId());
assertEquals("B", applicationsResponse.getData().get(1).getId());
assertEquals("A", applicationsResponse.getData().get(2).getId());
}
use of io.gravitee.rest.api.model.ApplicationEntity in project gravitee-management-rest-api by gravitee-io.
the class AnalyticsServiceImpl method getApplicationMetadata.
private Map<String, String> getApplicationMetadata(String application) {
Map<String, String> metadata = new HashMap<>();
try {
if (application.equals(UNKNOWN_SERVICE) || application.equals(UNKNOWN_SERVICE_MAPPED)) {
metadata.put(METADATA_NAME, METADATA_UNKNOWN_APPLICATION_NAME);
metadata.put(METADATA_UNKNOWN, Boolean.TRUE.toString());
} else {
ApplicationEntity applicationEntity = applicationService.findById(application);
metadata.put(METADATA_NAME, applicationEntity.getName());
if (ApplicationStatus.ARCHIVED.toString().equals(applicationEntity.getStatus())) {
metadata.put(METADATA_DELETED, Boolean.TRUE.toString());
}
}
} catch (ApplicationNotFoundException anfe) {
metadata.put(METADATA_DELETED, Boolean.TRUE.toString());
metadata.put(METADATA_NAME, METADATA_DELETED_APPLICATION_NAME);
}
return metadata;
}
use of io.gravitee.rest.api.model.ApplicationEntity in project gravitee-management-rest-api by gravitee-io.
the class ApplicationAlertServiceTest method getApplication.
private ApplicationEntity getApplication() {
ApplicationEntity application = new ApplicationEntity();
application.setId(APPLICATION_ID);
application.setName(APPLICATION_NAME);
application.setGroups(new HashSet<>());
return application;
}
Aggregations