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();
}
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);
}
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);
}
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());
}
}
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());
}
Aggregations