use of alien4cloud.rest.model.FilteredSearchRequest in project alien4cloud by alien4cloud.
the class ApplicationStepDefinitions method There_is_a_application.
@Given("^There is a \"([^\"]*)\" application$")
public void There_is_a_application(String applicationName) throws Throwable {
FilteredSearchRequest searchRequest = new FilteredSearchRequest(applicationName, 0, 50, null);
String searchResponse = getRestClientInstance().postJSon("/rest/v1/applications/search", JsonUtil.toString(searchRequest));
RestResponse<FacetedSearchResult> response = JsonUtil.read(searchResponse, FacetedSearchResult.class);
boolean hasApplication = false;
for (Object appAsObj : response.getData().getData()) {
Application app = JsonUtil.readObject(JsonUtil.toString(appAsObj), Application.class);
if (applicationName.equals(app.getName())) {
hasApplication = true;
CURRENT_APPLICATION = app;
}
}
if (!hasApplication) {
doCreateApplication(applicationName, appToArchName(applicationName), null, null, true);
}
}
use of alien4cloud.rest.model.FilteredSearchRequest in project alien4cloud by alien4cloud.
the class ApplicationVersionStepDefinitions method I_search_for_application_versions.
@When("^I search for application versions$")
public void I_search_for_application_versions() throws Throwable {
Application app = Context.getInstance().getApplication();
FilteredSearchRequest request = new FilteredSearchRequest();
request.setFrom(0);
request.setSize(10);
Context.getInstance().registerRestResponse(Context.getRestClientInstance().postJSon("/rest/v1/applications/" + app.getId() + "/versions/search", JsonUtil.toString(request)));
}
use of alien4cloud.rest.model.FilteredSearchRequest in project alien4cloud by alien4cloud.
the class AuditLogStepsDefinitions method searchAuditLogs.
private List<AuditTrace> searchAuditLogs(String query, Integer from, int numberOfResult, Map<String, String[]> filters, boolean checkResultSize) throws IOException {
FilteredSearchRequest req = new FilteredSearchRequest(query, from, 10, filters);
String jSon = JsonUtil.toString(req);
String restResponse = Context.getRestClientInstance().postJSon("/rest/v1/audit/search", jSon);
FacetedSearchResult searchResult = JsonUtil.read(restResponse, FacetedSearchResult.class).getData();
if (checkResultSize) {
Assert.assertEquals(numberOfResult, searchResult.getTotalResults());
}
Object[] searchData = searchResult.getData();
List<AuditTrace> actualTraces = Lists.newArrayList();
for (Object jsonData : searchData) {
actualTraces.add(JsonUtil.readObject(JsonUtil.toString(jsonData), AuditTrace.class));
}
return actualTraces;
}
use of alien4cloud.rest.model.FilteredSearchRequest in project alien4cloud by alien4cloud.
the class ApplicationEnvironmentStepDefinitions method getAllApplicationEnvironments.
@When("^I get all application environments for application \"([^\"]*)\"$")
public void getAllApplicationEnvironments(String applicationId) throws Throwable {
FilteredSearchRequest request = new FilteredSearchRequest();
request.setFrom(0);
// This is actually the maximum search size in a4c (1000 by default)
request.setSize(AlienConstants.MAX_ES_SEARCH_SIZE);
Context.getInstance().registerRestResponse(Context.getRestClientInstance().postJSon("/rest/v1/applications/" + applicationId + "/environments/search", JsonUtil.toString(request)));
try {
RestResponse<GetMultipleDataResult> restResponse = JsonUtil.read(Context.getInstance().getRestResponse(), GetMultipleDataResult.class);
ALL_ENVIRONMENTS = new ApplicationEnvironmentDTO[restResponse.getData().getData().length];
TestUtils.convert(restResponse.getData(), ALL_ENVIRONMENTS, ApplicationEnvironmentDTO.class);
CURRENT_ENVIRONMENT_DTO = ALL_ENVIRONMENTS[0];
} catch (IOException e) {
// Registration is optional
}
}
use of alien4cloud.rest.model.FilteredSearchRequest in project alien4cloud by alien4cloud.
the class CrudCSARSStepDefinition method i_can_find_CSAR.
@Given("^I can find (\\d+) CSAR$")
public void i_can_find_CSAR(int expectedSize) throws Throwable {
FilteredSearchRequest req = new FilteredSearchRequest(null, 0, 50, null);
String jSon = jsonMapper.writeValueAsString(req);
String response = Context.getRestClientInstance().postJSon("/rest/v1/csars/search", jSon);
RestResponse<FacetedSearchResult> restResponse = JsonUtil.read(response, FacetedSearchResult.class);
FacetedSearchResult searchResp = restResponse.getData();
assertNotNull(searchResp);
assertNotNull(searchResp.getData());
assertEquals(expectedSize, searchResp.getData().length);
}
Aggregations