use of alien4cloud.dao.model.GetMultipleDataResult in project alien4cloud by alien4cloud.
the class GroupsStepDefinitions method there_should_be_groups_in_the_response.
@Then("^there should be (\\d+) groups in the response$")
public void there_should_be_groups_in_the_response(int expectedSize) throws Throwable {
RestResponse<GetMultipleDataResult> restResponse = JsonUtil.read(Context.getInstance().takeRestResponse(), GetMultipleDataResult.class);
GetMultipleDataResult searchResp = restResponse.getData();
assertNotNull(searchResp);
assertNotNull(searchResp.getTypes());
assertNotNull(searchResp.getData());
assertEquals(expectedSize, searchResp.getTypes().length);
assertEquals(expectedSize, searchResp.getData().length);
}
use of alien4cloud.dao.model.GetMultipleDataResult in project alien4cloud by alien4cloud.
the class OrchestratorsDefinitionsSteps method Response_should_contains_an_orchestrator_with_name.
@Then("^Response should contains an orchestrator with name \"([^\"]*)\"$")
public void Response_should_contains_an_orchestrator_with_name(String name) throws Throwable {
RestResponse<GetMultipleDataResult> response = JsonUtil.read(Context.getInstance().getRestResponse(), GetMultipleDataResult.class);
boolean contains = false;
for (Object cloudAsMap : response.getData().getData()) {
Orchestrator orchestrator = JsonUtil.readObject(JsonUtil.toString(cloudAsMap), Orchestrator.class);
if (name.equals(orchestrator.getName())) {
contains = true;
}
}
Assert.assertTrue(contains);
}
use of alien4cloud.dao.model.GetMultipleDataResult in project alien4cloud by alien4cloud.
the class ServiceUsageReporter method reportServiceUsage.
@EventListener
private void reportServiceUsage(ServiceUsageRequestEvent serviceChangedEvent) {
GetMultipleDataResult<Deployment> usageResult = alienDAO.buildQuery(Deployment.class).setFilters(fromKeyValueCouples("endDate", null, "serviceResourceIds", serviceChangedEvent.getServiceId())).prepareSearch().search(0, Integer.MAX_VALUE);
if (usageResult.getTotalResults() > 0) {
Usage[] usages = Arrays.stream(usageResult.getData()).map(deployment -> {
ApplicationEnvironment environment = environmentService.getOrFail(deployment.getEnvironmentId());
String usageName = "App (" + deployment.getSourceName() + "), Env (" + environment.getName() + ")";
return new Usage(usageName, "Deployment", deployment.getId(), null);
}).toArray(Usage[]::new);
serviceChangedEvent.addUsages(usages);
}
}
use of alien4cloud.dao.model.GetMultipleDataResult in project alien4cloud by alien4cloud.
the class EsDaoSearchTest method simpleSearchTest.
@Test
public void simpleSearchTest() throws IndexingServiceException, InterruptedException, IOException {
// test simple find all search
GetMultipleDataResult searchResp = dao.find(NodeType.class, null, 10);
assertNotNull(searchResp);
assertEquals(4, searchResp.getTypes().length);
assertEquals(4, searchResp.getData().length);
// test simple find with filters
Map<String, String[]> filters = new HashMap<String, String[]>();
filters.put("capabilities.type", new String[] { "container" });
searchResp = dao.find(NodeType.class, filters, 10);
assertNotNull(searchResp);
assertNotNull(searchResp.getTypes());
assertNotNull(searchResp.getData());
assertEquals(2, searchResp.getTypes().length);
assertEquals(2, searchResp.getData().length);
}
use of alien4cloud.dao.model.GetMultipleDataResult in project alien4cloud by alien4cloud.
the class ApplicationVersionController method search.
/**
* Search application versions for a given application id
*
* @param applicationId the targeted application id
* @param searchRequest
* @return A rest response that contains a {@link FacetedSearchResult} containing application versions for an application id sorted by version
*/
@ApiOperation(value = "Search application versions", notes = "Returns a search result with that contains application versions matching the request. A application version is returned only if the connected user has at least one application role in [ APPLICATION_MANAGER | APPLICATION_USER | APPLICATION_DEVOPS | DEPLOYMENT_MANAGER ]")
@RequestMapping(value = "/search", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
public RestResponse<GetMultipleDataResult<ApplicationVersion>> search(@PathVariable String applicationId, @RequestBody FilteredSearchRequest searchRequest) {
Application application = applicationService.getOrFail(applicationId);
AuthorizationUtil.checkAuthorizationForApplication(application, ApplicationRole.values());
GetMultipleDataResult<ApplicationVersion> searchResult = appVersionService.search(applicationId, searchRequest.getQuery(), searchRequest.getFrom(), searchRequest.getSize());
return RestResponseBuilder.<GetMultipleDataResult<ApplicationVersion>>builder().data(searchResult).build();
}
Aggregations