77import java .util .List ;
88
99import org .junit .Ignore ;
10- import org .slf4j .Logger ;
11- import org .slf4j .LoggerFactory ;
1210import org .springframework .test .context .support .AbstractTestExecutionListener ;
1311
1412import com .ericsson .ei .systemtest .utils .Config ;
2018import cucumber .api .java .en .When ;
2119
2220@ Ignore
23- public class ArtifactFlowSteps extends AbstractTestExecutionListener {
24- private static final Logger LOGGER = LoggerFactory .getLogger (ArtifactFlowSteps .class );
21+ public class ArtifactFlowSteps extends AbstractTestExecutionListener {
2522 private static final String JENKINS_TOKEN = "123" ;
26- private static final String JENKINS_JOB_XML = "jenkinsJobTemplate.xml" ;
2723
2824 private ArrayList <String > jenkinsJobNames = new ArrayList <String >();
2925 private Config config = new Config ();
@@ -36,7 +32,28 @@ public void configurations_are_provided() {
3632 config .initRemRemConfig ();
3733 }
3834
39- @ Given ("^a jenkins job '\\ \" ([^\\ \" ]*)\\ \" ' from '\" ([^\" ]*)\" ' is created with parameters: (.*)$" )
35+ @ Given ("^subscription object \" ([^\" ]*)\" is created which will trigger \" ([^\" ]*)\" (.*)$" )
36+ public void subscription_is_created (String subscriptionName , String nameOfTriggeredJob , String hasParameters ) throws Throwable {
37+ StepsUtils .createSubscription (subscriptionName , nameOfTriggeredJob , config .getJenkinsUsername (), config .getJenkinsPassword (),
38+ config .getJenkinsBaseUrl (), !hasParameters .isEmpty ());
39+ }
40+
41+ @ Given ("^the jenkins job \" ([^\" ]*)\" is triggered$" )
42+ public void the_jenkins_job_is_triggered (String jenkinsJobToTrigger ) throws Throwable {
43+ StepsUtils .triggerJenkinsJob (jenkinsJobToTrigger , JENKINS_TOKEN );
44+ }
45+
46+ @ When ("^notification with key \" ([^\" ]*)\" and value \" ([^\" ]*)\" is added to \" ([^\" ]*)\" $" )
47+ public void notification_with_key_and_value_is_added_to (String key , String value , String subscriptionName ) throws Throwable {
48+ StepsUtils .addNotificationToSubscription (key , value , subscriptionName );
49+ }
50+
51+ @ When ("^condition with jmespath \" ([^\" ]*)\" is added to \" ([^\" ]*)\" $" )
52+ public void condition_with_jmespath_is_added_to (String jmesPath , String subscriptionName ) throws Throwable {
53+ StepsUtils .addConditionToRequirement (jmesPath , subscriptionName );
54+ }
55+
56+ @ Then ("^a jenkins job \" ([^\" ]*)\" from \" ([^\" ]*)\" is created with parameters: (.*)$" )
4057 public void a_jenkins_job_from_is_created (String jenkinsJobName , String scriptFileName , List <String > parameters ) throws Throwable {
4158 boolean success = StepsUtils .createJenkinsJob (
4259 jenkinsJobName ,
@@ -56,41 +73,21 @@ public void a_jenkins_job_from_is_created(String jenkinsJobName, String scriptFi
5673 assertTrue ("Failed to create jenkins job." , success );
5774 }
5875
59- @ Then ("^subscriptions and jenkins jobs should be removed$" )
60- public void subscriptions_and_jenkins_jobs_should_be_removed () throws Throwable {
61- StepsUtils .deleteJenkinsJobs (jenkinsJobNames );
62- StepsUtils .deleteSubscriptions (config .getEiFrontendBaseUrl (), config .getEiBackendBaseUrl ());
63- }
64-
65- @ Given ("^subscription object \" ([^\" ]*)\" is created which will trigger \" ([^\" ]*)\" $" )
66- public void subscription_is_created (String subscriptionName , String nameOfTriggeredJob ) throws Throwable {
67- StepsUtils .createSubscription (subscriptionName , nameOfTriggeredJob , config .getJenkinsUsername (), config .getJenkinsPassword (), config .getJenkinsBaseUrl ());
68- }
69-
70- @ When ("^notification with key \" ([^\" ]*)\" and value \" ([^\" ]*)\" is added to \" ([^\" ]*)\" $" )
71- public void notification_with_key_and_value_is_added_to (String key , String value , String subscriptionName ) throws Throwable {
72- StepsUtils .addNotificationToSubscription (key , value , subscriptionName );
73- }
74-
75- @ When ("^condition with jmespath \" ([^\" ]*)\" is added to \" ([^\" ]*)\" $" )
76- public void condition_with_jmespath_is_added_to (String jmesPath , String subscriptionName ) throws Throwable {
77- StepsUtils .addConditionToRequirement (jmesPath , subscriptionName );
78- }
79-
8076 @ Then ("^we send the \" ([^\" ]*)\" to eiffel intelligence for creation\\ .$" )
8177 public void we_send_the_to_eiffel_intelligence_for_creation (String subscriptionName ) throws Throwable {
8278 ResponseEntity response = StepsUtils .sendSubscriptionToEiffelIntelligence (subscriptionName , config .getEiFrontendBaseUrl (), config .getEiBackendBaseUrl ());
8379
8480 assertEquals ("Failed to create subscription. Response: " + response .getBody (), 200 , response .getStatusCode ());
8581 }
8682
87- @ Given ("^the jenkins job \" ([^\" ]*)\" is triggered$" )
88- public void the_jenkins_job_is_triggered (String jenkinsJobToTrigger ) throws Throwable {
89- StepsUtils .triggerJenkinsJob (jenkinsJobToTrigger , JENKINS_TOKEN );
90- }
91-
92- @ When ("^all jenkins jobs has been triggered$" )
83+ @ Then ("^all jenkins jobs has been triggered$" )
9384 public void the_jenkins_job_has_been_triggered () throws Throwable {
9485 StepsUtils .hasJenkinsJobsBeenTriggered (jenkinsJobNames , config .getJobTimeoutMilliseconds ());
9586 }
96- }
87+
88+ @ Then ("^subscriptions and jenkins jobs should be removed$" )
89+ public void subscriptions_and_jenkins_jobs_should_be_removed () throws Throwable {
90+ StepsUtils .deleteJenkinsJobs (jenkinsJobNames );
91+ StepsUtils .deleteSubscriptions (config .getEiFrontendBaseUrl (), config .getEiBackendBaseUrl ());
92+ }
93+ }
0 commit comments