Search in sources :

Example 1 with LocationModifierReference

use of alien4cloud.model.orchestrators.locations.LocationModifierReference in project alien4cloud by alien4cloud.

the class LocationModifiersController method getAllModifiers.

@ApiOperation(value = "Get all modifiers for a given location.")
@RequestMapping(method = RequestMethod.GET)
public RestResponse<List<LocationModifierReference>> getAllModifiers(@ApiParam(value = "Id of the location for which to get all modifiers.") @PathVariable String locationId) {
    Location location = locationService.getOrFail(locationId);
    List<LocationModifierReference> modifiers = location.getModifiers();
    if (modifiers == null) {
        modifiers = Lists.newArrayList();
    }
    return RestResponseBuilder.<List<LocationModifierReference>>builder().data(modifiers).build();
}
Also used : LocationModifierReference(alien4cloud.model.orchestrators.locations.LocationModifierReference) List(java.util.List) Location(alien4cloud.model.orchestrators.locations.Location) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with LocationModifierReference

use of alien4cloud.model.orchestrators.locations.LocationModifierReference in project alien4cloud by alien4cloud.

the class LocationModifierStep method responseShouldContainsALocationModifierWithPluginIdAndBeanNameAndPhase.

@And("^Response should contains a location modifier with plugin id \"([^\"]*)\" and bean name \"([^\"]*)\" and phase \"([^\"]*)\"$")
public void responseShouldContainsALocationModifierWithPluginIdAndBeanNameAndPhase(String pluginId, String beanName, String phase) throws Throwable {
    RestResponse<List> response = JsonUtil.read(Context.getInstance().getRestResponse(), List.class);
    boolean contains = false;
    for (Object obj : response.getData()) {
        LocationModifierReference modifier = Context.getInstance().getJsonMapper().readValue(Context.getInstance().getJsonMapper().writeValueAsString(obj), LocationModifierReference.class);
        if (pluginId.equals(modifier.getPluginId()) && beanName.equals(modifier.getBeanName()) && phase.equals(modifier.getPhase())) {
            contains = true;
            break;
        }
    }
    Assert.assertTrue(contains);
}
Also used : LocationModifierReference(alien4cloud.model.orchestrators.locations.LocationModifierReference) List(java.util.List) ArrayList(java.util.ArrayList) And(cucumber.api.java.en.And)

Example 3 with LocationModifierReference

use of alien4cloud.model.orchestrators.locations.LocationModifierReference in project alien4cloud by alien4cloud.

the class LocationModifierStep method iCreateALocationModifierWithPluginIdAndBeanNameAndPhaseToTheLocationOfTheOrchestrator.

@When("^I create a location modifier with plugin id \"([^\"]*)\" and bean name \"([^\"]*)\" and phase \"([^\"]*)\" to the location \"([^\"]*)\" of the orchestrator \"([^\"]*)\"$")
public void iCreateALocationModifierWithPluginIdAndBeanNameAndPhaseToTheLocationOfTheOrchestrator(String pluginId, String beanName, String phase, String locationName, String orchestratorName) throws Throwable {
    String orchestratorId = Context.getInstance().getOrchestratorId(orchestratorName);
    String locationId = Context.getInstance().getLocationId(orchestratorId, locationName);
    LocationModifierReference modifier = new LocationModifierReference();
    modifier.setPluginId(pluginId);
    modifier.setBeanName(beanName);
    modifier.setPhase(phase);
    String resp = Context.getRestClientInstance().postJSon(String.format("/rest/v1/orchestrators/%s/locations/%s/modifiers", orchestratorId, locationId), JsonUtil.toString(modifier));
    Context.getInstance().registerRestResponse(resp);
}
Also used : LocationModifierReference(alien4cloud.model.orchestrators.locations.LocationModifierReference) When(cucumber.api.java.en.When)

Example 4 with LocationModifierReference

use of alien4cloud.model.orchestrators.locations.LocationModifierReference in project alien4cloud by alien4cloud.

the class LocationModifierStep method saveLocationModifierOrder.

@And("^Save location modifier order$")
public void saveLocationModifierOrder() throws Throwable {
    if (this.previousModifiersOrder == null) {
        this.previousModifiersOrder = Lists.newArrayList();
    } else {
        this.previousModifiersOrder.clear();
    }
    RestResponse<List> response = JsonUtil.read(Context.getInstance().getRestResponse(), List.class);
    for (Object obj : response.getData()) {
        LocationModifierReference modifier = Context.getInstance().getJsonMapper().readValue(Context.getInstance().getJsonMapper().writeValueAsString(obj), LocationModifierReference.class);
        this.previousModifiersOrder.add(modifier.toString());
    }
}
Also used : LocationModifierReference(alien4cloud.model.orchestrators.locations.LocationModifierReference) List(java.util.List) ArrayList(java.util.ArrayList) And(cucumber.api.java.en.And)

Example 5 with LocationModifierReference

use of alien4cloud.model.orchestrators.locations.LocationModifierReference in project alien4cloud by alien4cloud.

the class LocationModifierStep method theLocationAtIndexShouldHaveTheBeanName.

@And("^the location at index (\\d+) should have the bean name \"([^\"]*)\"$")
public void theLocationAtIndexShouldHaveTheBeanName(int index, String beanName) throws Throwable {
    RestResponse<List> response = JsonUtil.read(Context.getInstance().getRestResponse(), List.class);
    Object obj = response.getData().get(index);
    LocationModifierReference modifier = Context.getInstance().getJsonMapper().readValue(Context.getInstance().getJsonMapper().writeValueAsString(obj), LocationModifierReference.class);
    Assert.assertEquals(beanName, modifier.getBeanName());
}
Also used : LocationModifierReference(alien4cloud.model.orchestrators.locations.LocationModifierReference) List(java.util.List) ArrayList(java.util.ArrayList) And(cucumber.api.java.en.And)

Aggregations

LocationModifierReference (alien4cloud.model.orchestrators.locations.LocationModifierReference)10 List (java.util.List)6 And (cucumber.api.java.en.And)4 ArrayList (java.util.ArrayList)4 Location (alien4cloud.model.orchestrators.locations.Location)3 MetaPropertiesService (alien4cloud.common.MetaPropertiesService)1 LocationMatchingService (alien4cloud.deployment.matching.services.location.LocationMatchingService)1 NotFoundException (alien4cloud.exception.NotFoundException)1 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)1 ILocationMatch (alien4cloud.model.deployment.matching.ILocationMatch)1 LocationService (alien4cloud.orchestrators.locations.services.LocationService)1 PluginManager (alien4cloud.plugin.PluginManager)1 MissingPluginException (alien4cloud.plugin.exception.MissingPluginException)1 PluginUsage (alien4cloud.plugin.model.PluginUsage)1 LocationPolicyValidationService (alien4cloud.topology.validation.LocationPolicyValidationService)1 ToscaContext (alien4cloud.tosca.context.ToscaContext)1 AlienUtils.safe (alien4cloud.utils.AlienUtils.safe)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 When (cucumber.api.java.en.When)1