Search in sources :

Example 1 with FilteredSearchRequest

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);
    }
}
Also used : FilteredSearchRequest(alien4cloud.rest.model.FilteredSearchRequest) TestUtils.nullAsString(alien4cloud.it.utils.TestUtils.nullAsString) Application(alien4cloud.model.application.Application) FacetedSearchResult(alien4cloud.dao.model.FacetedSearchResult) Given(cucumber.api.java.en.Given)

Example 2 with FilteredSearchRequest

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)));
}
Also used : FilteredSearchRequest(alien4cloud.rest.model.FilteredSearchRequest) Application(alien4cloud.model.application.Application) When(cucumber.api.java.en.When)

Example 3 with FilteredSearchRequest

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;
}
Also used : FilteredSearchRequest(alien4cloud.rest.model.FilteredSearchRequest) AuditTrace(alien4cloud.audit.model.AuditTrace) FacetedSearchResult(alien4cloud.dao.model.FacetedSearchResult)

Example 4 with FilteredSearchRequest

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
    }
}
Also used : FilteredSearchRequest(alien4cloud.rest.model.FilteredSearchRequest) IOException(java.io.IOException) GetMultipleDataResult(alien4cloud.dao.model.GetMultipleDataResult) When(cucumber.api.java.en.When)

Example 5 with FilteredSearchRequest

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);
}
Also used : FilteredSearchRequest(alien4cloud.rest.model.FilteredSearchRequest) FacetedSearchResult(alien4cloud.dao.model.FacetedSearchResult) Given(cucumber.api.java.en.Given)

Aggregations

FilteredSearchRequest (alien4cloud.rest.model.FilteredSearchRequest)12 FacetedSearchResult (alien4cloud.dao.model.FacetedSearchResult)5 When (cucumber.api.java.en.When)5 GetMultipleDataResult (alien4cloud.dao.model.GetMultipleDataResult)2 TestUtils.nullAsString (alien4cloud.it.utils.TestUtils.nullAsString)2 Application (alien4cloud.model.application.Application)2 Given (cucumber.api.java.en.Given)2 AuditTrace (alien4cloud.audit.model.AuditTrace)1 Repository (alien4cloud.model.repository.Repository)1 AvailableTopologyRepositories (alien4cloud.repository.model.AvailableTopologyRepositories)1 AvailableTopologyRepository (alien4cloud.repository.model.AvailableTopologyRepository)1 RepositoryPluginComponent (alien4cloud.repository.model.RepositoryPluginComponent)1 ApplicationEnvironmentDTO (alien4cloud.rest.application.model.ApplicationEnvironmentDTO)1 Then (cucumber.api.java.en.Then)1 ApiOperation (io.swagger.annotations.ApiOperation)1 IOException (java.io.IOException)1 DeploymentArtifact (org.alien4cloud.tosca.model.definitions.DeploymentArtifact)1 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)1 Topology (org.alien4cloud.tosca.model.templates.Topology)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1