|
| 1 | +package com.ericsson.ei.systemtest.testexecutionflow; |
| 2 | + |
| 3 | +import static org.junit.Assert.assertEquals; |
| 4 | +import static org.junit.Assert.assertTrue; |
| 5 | + |
| 6 | +import java.util.ArrayList; |
| 7 | + |
| 8 | +import org.junit.Ignore; |
| 9 | +import org.slf4j.Logger; |
| 10 | +import org.slf4j.LoggerFactory; |
| 11 | +import org.springframework.test.context.support.AbstractTestExecutionListener; |
| 12 | + |
| 13 | +import com.ericsson.ei.systemtest.utils.Config; |
| 14 | +import com.ericsson.ei.systemtest.utils.StepsUtils; |
| 15 | +import com.ericsson.eiffelcommons.utils.ResponseEntity; |
| 16 | + |
| 17 | +import cucumber.api.java.en.Given; |
| 18 | +import cucumber.api.java.en.Then; |
| 19 | +import cucumber.api.java.en.When; |
| 20 | + |
| 21 | +@Ignore |
| 22 | +public class TestExecutionFlowSteps extends AbstractTestExecutionListener{ |
| 23 | + private static final Logger LOGGER = LoggerFactory.getLogger(TestExecutionFlowSteps.class); |
| 24 | + private static final String JENKINS_TOKEN = "123"; |
| 25 | + private static final String JENKINS_JOB_XML = "jenkinsJobTemplate.xml"; |
| 26 | + |
| 27 | + private ArrayList<String> jenkinsJobNames = new ArrayList<String>(); |
| 28 | + private Config config = new Config(); |
| 29 | + |
| 30 | + @Given("^configurations are provided$") |
| 31 | + public void configurations_are_provided() { |
| 32 | + config.initEIFrontend(); |
| 33 | + config.initEIBackend(); |
| 34 | + config.initJenkinsConfig(); |
| 35 | + config.initRemRemConfig(); |
| 36 | + } |
| 37 | + |
| 38 | + @Given("^a jenkins job '\\\"([^\\\"]*)\\\"' from '\"([^\"]*)\"' is created$") |
| 39 | + public void a_jenkins_job_from_is_created(String jenkinsJobName, String scriptFileName) throws Throwable { |
| 40 | + boolean success = StepsUtils.createJenkinsJob( |
| 41 | + jenkinsJobName, |
| 42 | + scriptFileName, |
| 43 | + config.getJenkinsBaseUrl(), |
| 44 | + config.getJenkinsUsername(), |
| 45 | + config.getJenkinsPassword(), |
| 46 | + JENKINS_TOKEN, |
| 47 | + JENKINS_JOB_XML, |
| 48 | + config.getRemremBaseUrl() |
| 49 | + ); |
| 50 | + |
| 51 | + if (success) { |
| 52 | + jenkinsJobNames.add(jenkinsJobName); |
| 53 | + } |
| 54 | + |
| 55 | + assertTrue("Failed to create jenkins job.", success); |
| 56 | + } |
| 57 | + |
| 58 | + @Then("^subscriptions and jenkins jobs should be removed$") |
| 59 | + public void subscriptions_and_jenkins_jobs_should_be_removed() throws Throwable { |
| 60 | + StepsUtils.deleteJenkinsJobs(jenkinsJobNames); |
| 61 | + StepsUtils.deleteSubscriptions(config.getEiFrontendBaseUrl(), config.getEiBackendBaseUrl()); |
| 62 | + } |
| 63 | + |
| 64 | + @Given("^subscription object \"([^\"]*)\" is created which will trigger \"([^\"]*)\"$") |
| 65 | + public void subscription_is_created(String subscriptionName, String jenkinsJobName) throws Throwable { |
| 66 | + StepsUtils.createSubscription(subscriptionName, jenkinsJobName, config.getJenkinsUsername(), config.getJenkinsPassword(), config.getJenkinsBaseUrl()); |
| 67 | + } |
| 68 | + |
| 69 | + @When("^notification with key \"([^\"]*)\" and value \"([^\"]*)\" is added to \"([^\"]*)\"$") |
| 70 | + public void notification_with_key_and_value_is_added_to(String key, String value, String subscriptionName) throws Throwable { |
| 71 | + StepsUtils.addNotificationToSubscription(key, value, subscriptionName); |
| 72 | + } |
| 73 | + |
| 74 | + @When("^condition with jmespath \"([^\"]*)\" is added to \"([^\"]*)\"$") |
| 75 | + public void condition_with_jmespath_is_added_to(String jmesPath, String subscriptionName) throws Throwable { |
| 76 | + StepsUtils.addConditionToRequirement(jmesPath, subscriptionName); |
| 77 | + } |
| 78 | + |
| 79 | + @Then("^we send the \"([^\"]*)\" to eiffel intelligence for creation\\.$") |
| 80 | + public void we_send_the_to_eiffel_intelligence_for_creation(String subscriptionName) throws Throwable { |
| 81 | + ResponseEntity response = StepsUtils.sendSubscriptionToEiffelIntelligence(subscriptionName, config.getEiFrontendBaseUrl(), config.getEiBackendBaseUrl()); |
| 82 | + |
| 83 | + assertEquals("Failed to create subscription. Response: " + response.getBody(), 200, response.getStatusCode()); |
| 84 | + } |
| 85 | +} |
0 commit comments