Search in sources :

Example 6 with MetaPropConfiguration

use of alien4cloud.model.common.MetaPropConfiguration in project alien4cloud by alien4cloud.

the class TagConfigurationStepDefinitions method I_load_several_configuration_tags.

@Given("^I load several configuration tags$")
public void I_load_several_configuration_tags() throws Throwable {
    String tagConfigurationsJson = FileUtil.readTextFile(Paths.get(CONFIGURATION_TAGS));
    List<MetaPropConfiguration> tagsArray = JsonUtil.readObject(tagConfigurationsJson);
    // registering all configuration tags
    for (Object tag : tagsArray) {
        // register in ES
        MetaPropConfiguration tagObject = JsonUtil.readObject(JsonUtil.toString(tag), MetaPropConfiguration.class);
        String tagConfigurationJson = JsonUtil.toString(tagObject);
        String response = Context.getRestClientInstance().postJSon("/rest/v1/metaproperties", tagConfigurationJson);
        TagConfigurationSaveResponse tagReceived = JsonUtil.read(response, TagConfigurationSaveResponse.class).getData();
        // register in context
        tagObject.setId(tagReceived.getId());
        Context.getInstance().registerConfigurationTag(tagObject.getName(), tagObject);
    }
    Assert.assertNotNull(Context.getInstance().getConfigurationTags());
}
Also used : MetaPropConfiguration(alien4cloud.model.common.MetaPropConfiguration) TagConfigurationSaveResponse(alien4cloud.rest.tags.TagConfigurationSaveResponse) Given(cucumber.api.java.en.Given)

Example 7 with MetaPropConfiguration

use of alien4cloud.model.common.MetaPropConfiguration in project alien4cloud by alien4cloud.

the class PropertiesDefinitionsSteps method I_fill_the_value_for_tag.

@When("^I fill the value \"([^\"]*)\" for \"([^\"]*)\" tag to check$")
public void I_fill_the_value_for_tag(String value, String configurationTagName) throws Throwable {
    MetaPropConfiguration tag = Context.getInstance().getConfigurationTag(configurationTagName);
    PropertyValidationRequest propertyCheckRequest = new PropertyValidationRequest(value, configurationTagName, tag, null);
    Context.getInstance().registerRestResponse(Context.getRestClientInstance().postJSon("/rest/v1/properties/check", JsonUtil.toString(propertyCheckRequest)));
}
Also used : MetaPropConfiguration(alien4cloud.model.common.MetaPropConfiguration) PropertyValidationRequest(alien4cloud.rest.internal.model.PropertyValidationRequest) When(cucumber.api.java.en.When)

Example 8 with MetaPropConfiguration

use of alien4cloud.model.common.MetaPropConfiguration in project alien4cloud by alien4cloud.

the class TagConfigurationController method removeConfiguration.

@ApiOperation(value = "Remove tag configuration.")
@RequestMapping(value = "/{tagConfigurationId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
@Audit
public RestResponse<Void> removeConfiguration(@PathVariable String tagConfigurationId) {
    MetaPropConfiguration configuration = dao.findById(MetaPropConfiguration.class, tagConfigurationId);
    if (configuration == null) {
        throw new NotFoundException("Configuration is not found");
    }
    switch(configuration.getTarget().toString()) {
        case "application":
            removeMetaPropertyFromResources(Application.class, dao, configuration);
            break;
        case "location":
            removeMetaPropertyFromResources(Location.class, dao, configuration);
            break;
        // TODO : case environment
        default:
            break;
    }
    dao.delete(MetaPropConfiguration.class, tagConfigurationId);
    return RestResponseBuilder.<Void>builder().build();
}
Also used : MetaPropConfiguration(alien4cloud.model.common.MetaPropConfiguration) NotFoundException(alien4cloud.exception.NotFoundException) Audit(alien4cloud.audit.annotation.Audit) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with MetaPropConfiguration

use of alien4cloud.model.common.MetaPropConfiguration in project alien4cloud by alien4cloud.

the class TagConfigurationStepDefinitions method I_delete_the_tag_configuration.

@When("^I delete the tag configuration \"([^\"]*)\"$")
public void I_delete_the_tag_configuration(String tagName) throws Throwable {
    // delete in ES
    MetaPropConfiguration tagConfiguration = Context.getInstance().getConfigurationTags().get(tagName);
    Context.getInstance().registerRestResponse(Context.getRestClientInstance().delete("/rest/v1/metaproperties/" + tagConfiguration.getId()));
    // delete in context
    Context.getInstance().getConfigurationTags().remove(tagName);
}
Also used : MetaPropConfiguration(alien4cloud.model.common.MetaPropConfiguration) When(cucumber.api.java.en.When)

Example 10 with MetaPropConfiguration

use of alien4cloud.model.common.MetaPropConfiguration in project alien4cloud by alien4cloud.

the class TagConfigurationStepDefinitions method The_tag_configuration_must_not_exist_in_ALIEN.

@Then("^The tag configuration \"([^\"]*)\" must not exist in ALIEN$")
public void The_tag_configuration_must_not_exist_in_ALIEN(String tagName) throws Throwable {
    // not present in the context only
    MetaPropConfiguration tagConfiguration = Context.getInstance().getConfigurationTags().get(tagName);
    Assert.assertNull(tagConfiguration);
}
Also used : MetaPropConfiguration(alien4cloud.model.common.MetaPropConfiguration) Then(cucumber.api.java.en.Then)

Aggregations

MetaPropConfiguration (alien4cloud.model.common.MetaPropConfiguration)10 NotFoundException (alien4cloud.exception.NotFoundException)3 When (cucumber.api.java.en.When)3 PropertyValidationRequest (alien4cloud.rest.internal.model.PropertyValidationRequest)2 Given (cucumber.api.java.en.Given)2 Audit (alien4cloud.audit.annotation.Audit)1 MissingCSARDependenciesException (alien4cloud.exception.MissingCSARDependenciesException)1 TagConfigurationSaveResponse (alien4cloud.rest.tags.TagConfigurationSaveResponse)1 Then (cucumber.api.java.en.Then)1 ApiOperation (io.swagger.annotations.ApiOperation)1 CSARDependency (org.alien4cloud.tosca.model.CSARDependency)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1