use of javax.ws.rs.core.UriInfo in project ORCID-Source by ORCID.
the class T1OrcidApiServiceImplLatestMetricsTest method testSearchByQueryJSONResultsReturned.
@Test
public void testSearchByQueryJSONResultsReturned() {
UriInfo uriInfo = mock(UriInfo.class);
t1OrcidApiService.setUriInfo(uriInfo);
MultivaluedMap<String, String> queryMaps = queryParams();
when(uriInfo.getQueryParameters()).thenReturn(queryMaps);
when(mockServiceDelegator.publicSearchByQuery(queryMaps)).thenReturn(orcidWithMultipleResults());
Response response = t1OrcidApiService.searchByQueryJSON("orcid");
assertEquals(200, response.getStatus());
}
use of javax.ws.rs.core.UriInfo in project ORCID-Source by ORCID.
the class T1OrcidApiServiceImplLatestMetricsTest method testSearchByQueryXML.
@Test
public void testSearchByQueryXML() {
UriInfo uriInfo = mock(UriInfo.class);
t1OrcidApiService.setUriInfo(uriInfo);
MultivaluedMap<String, String> queryMaps = queryParams();
when(uriInfo.getQueryParameters()).thenReturn(queryMaps);
when(mockServiceDelegator.publicSearchByQuery(queryMaps)).thenReturn(successResponse);
Response response = t1OrcidApiService.searchByQueryXML("orcid");
assertEquals(200, response.getStatus());
}
use of javax.ws.rs.core.UriInfo in project ORCID-Source by ORCID.
the class T1OrcidApiServiceImplLatestMetricsTest method testSearchByQueryJSON.
@Test
public void testSearchByQueryJSON() {
UriInfo uriInfo = mock(UriInfo.class);
t1OrcidApiService.setUriInfo(uriInfo);
MultivaluedMap<String, String> queryMaps = queryParams();
when(uriInfo.getQueryParameters()).thenReturn(queryMaps);
when(mockServiceDelegator.publicSearchByQuery(queryMaps)).thenReturn(successResponse);
Response response = t1OrcidApiService.searchByQueryJSON("orcid");
assertEquals(200, response.getStatus());
}
use of javax.ws.rs.core.UriInfo in project opennms by OpenNMS.
the class StatusRestService method getBusinessServices.
@GET
@Path("/business-services")
public Response getBusinessServices(@Context final UriInfo uriInfo) {
final QueryParameters queryParameters = QueryParametersBuilder.buildFrom(uriInfo);
final SeverityFilter severityFilter = getSeverityFilter(uriInfo);
final Query query = new Query(queryParameters, severityFilter);
final List<StatusEntity<BusinessService>> services = businessServiceStatusService.getStatus(query);
final int totalCount = businessServiceStatusService.count(query);
final int offset = queryParameters.getOffset();
final List<BusinessServiceDTO> statusEntities = services.stream().map(bs -> {
BusinessServiceDTO statusDTO = new BusinessServiceDTO();
statusDTO.setId(bs.getEntity().getId().intValue());
statusDTO.setName(bs.getEntity().getName());
statusDTO.setSeverity(bs.getStatus());
return statusDTO;
}).collect(Collectors.toList());
final BusinessServiceDTOList list = new BusinessServiceDTOList(statusEntities);
list.setOffset(queryParameters.getOffset());
list.setTotalCount(totalCount);
return createResponse(list, offset, totalCount);
}
use of javax.ws.rs.core.UriInfo in project jersey by jersey.
the class JsonWithPaddingInterceptor method getCallbackName.
/**
* Returns a JavaScript callback name to wrap the JSON entity into. The callback name is determined from the {@link JSONP}
* annotation.
*
* @param jsonp {@link JSONP} annotation to determine the callback name from.
* @return a JavaScript callback name.
*/
private String getCallbackName(final JSONP jsonp) {
String callback = jsonp.callback();
if (!"".equals(jsonp.queryParam())) {
final ContainerRequest containerRequest = containerRequestProvider.get();
final UriInfo uriInfo = containerRequest.getUriInfo();
final MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters();
final List<String> queryParameter = queryParameters.get(jsonp.queryParam());
callback = (queryParameter != null && !queryParameter.isEmpty()) ? queryParameter.get(0) : callback;
}
return callback;
}
Aggregations