Skip to content

Commit ad8e78f

Browse files
committed
Cucumber Http Response Glue
1 parent 12bcf2f commit ad8e78f

File tree

12 files changed

+188
-1
lines changed

12 files changed

+188
-1
lines changed

all-glue/pom.xml

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
<groupId>com.github.nhojpatrick.cucumber</groupId>
3939
<artifactId>nhojpatrick-cucumber-http-request-glue</artifactId>
4040
</dependency>
41+
<dependency>
42+
<groupId>com.github.nhojpatrick.cucumber</groupId>
43+
<artifactId>nhojpatrick-cucumber-http-response-glue</artifactId>
44+
</dependency>
4145
<dependency>
4246
<groupId>com.github.nhojpatrick.cucumber</groupId>
4347
<artifactId>nhojpatrick-cucumber-json-map-glue</artifactId>

all-glue/src/main/java11/module-info.java

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
requires org.junit.jupiter.api;
44
requires org.slf4j;
55
requires transitive com.github.nhojpatrick.cucumber.http.request.glue;
6+
requires transitive com.github.nhojpatrick.cucumber.http.response.glue;
67
requires transitive com.github.nhojpatrick.cucumber.json.map.glue;
78
requires transitive com.github.nhojpatrick.cucumber.json.transform.glue;
89
requires transitive com.github.nhojpatrick.cucumber.state.glue;

bom/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@
8585
<artifactId>nhojpatrick-cucumber-http-response</artifactId>
8686
<version>${project.version}</version>
8787
</dependency>
88+
<dependency>
89+
<groupId>com.github.nhojpatrick.cucumber</groupId>
90+
<artifactId>nhojpatrick-cucumber-http-response-glue</artifactId>
91+
<version>${project.version}</version>
92+
</dependency>
8893
<dependency>
8994
<groupId>com.github.nhojpatrick.cucumber</groupId>
9095
<artifactId>nhojpatrick-cucumber-json-all</artifactId>

http/pom.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
<module>core</module>
3838
<module>request</module>
3939
<module>request-glue</module>
40-
<module>response</module>
40+
<module>response</module>
41+
<module>response-glue</module>
4142
</modules>
4243
<!--repositories / -->
4344
<!--pluginRepositories / -->

http/response-glue/pom.xml

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<!--modelVersion / -->
4+
<modelVersion>4.0.0</modelVersion>
5+
<!--parent / -->
6+
<parent>
7+
<groupId>com.github.nhojpatrick.cucumber</groupId>
8+
<artifactId>nhojpatrick-cucumber</artifactId>
9+
<version>1.0.2-SNAPSHOT</version>
10+
<relativePath>../../pom.xml</relativePath>
11+
</parent>
12+
<!--groupId / -->
13+
<!--artifactId / -->
14+
<artifactId>nhojpatrick-cucumber-http-response-glue</artifactId>
15+
<!--packaging / -->
16+
<!--name / -->
17+
<!--version / -->
18+
<!--description / -->
19+
<!--url / -->
20+
<!--prerequisites / -->
21+
<!--issueManagement / -->
22+
<!--ciManagement / -->
23+
<!--inceptionYear / -->
24+
<!--mailingLists / -->
25+
<!--developers / -->
26+
<!--contributors / -->
27+
<!--licenses / -->
28+
<!--scm / -->
29+
<!--organization / -->
30+
<!--build / -->
31+
<!--profiles / -->
32+
<!--modules / -->
33+
<!--repositories / -->
34+
<!--pluginRepositories / -->
35+
<!--dependencies / -->
36+
<dependencies>
37+
<dependency>
38+
<groupId>com.github.nhojpatrick.cucumber</groupId>
39+
<artifactId>nhojpatrick-cucumber-http-constants</artifactId>
40+
</dependency>
41+
<dependency>
42+
<groupId>com.github.nhojpatrick.cucumber</groupId>
43+
<artifactId>nhojpatrick-cucumber-http-response</artifactId>
44+
</dependency>
45+
<dependency>
46+
<groupId>com.github.nhojpatrick.cucumber</groupId>
47+
<artifactId>nhojpatrick-cucumber-state</artifactId>
48+
</dependency>
49+
<dependency>
50+
<groupId>com.github.nhojpatrick.hamcrest</groupId>
51+
<artifactId>nhojpatrick-hamcrest-lang</artifactId>
52+
<scope>test</scope>
53+
</dependency>
54+
<dependency>
55+
<groupId>org.apache.logging.log4j</groupId>
56+
<artifactId>log4j-slf4j2-impl</artifactId>
57+
<scope>test</scope>
58+
</dependency>
59+
<dependency>
60+
<groupId>org.hamcrest</groupId>
61+
<artifactId>hamcrest</artifactId>
62+
</dependency>
63+
<dependency>
64+
<groupId>org.junit.jupiter</groupId>
65+
<artifactId>junit-jupiter-api</artifactId>
66+
</dependency>
67+
<dependency>
68+
<groupId>org.junit.jupiter</groupId>
69+
<artifactId>junit-jupiter-engine</artifactId>
70+
<scope>test</scope>
71+
</dependency>
72+
<dependency>
73+
<groupId>org.slf4j</groupId>
74+
<artifactId>slf4j-api</artifactId>
75+
</dependency>
76+
</dependencies>
77+
<!--reports (Deprecated) / -->
78+
<!--reporting / -->
79+
<!--dependencyManagement / -->
80+
<!--distributionManagement / -->
81+
<!--properties / -->
82+
<properties>
83+
<project.Automatic-Module-Name>com.github.nhojpatrick.cucumber.http.response.glue</project.Automatic-Module-Name>
84+
</properties>
85+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.github.nhojpatrick.cucumber.http.response.steps;
2+
3+
import com.github.nhojpatrick.cucumber.core.exceptions.IllegalKeyException;
4+
import com.github.nhojpatrick.cucumber.core.exceptions.IllegalTypeClassException;
5+
import com.github.nhojpatrick.cucumber.core.exceptions.TypeMismatchException;
6+
import com.github.nhojpatrick.cucumber.http.core.model.HttpResponse;
7+
import com.github.nhojpatrick.cucumber.state.RunState;
8+
import com.github.nhojpatrick.cucumber.state.exceptions.NullRunStateException;
9+
import com.github.nhojpatrick.cucumber.state.validation.RunStateValidatorFactory;
10+
import com.google.inject.Inject;
11+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
12+
import io.cucumber.java.en.Given;
13+
14+
import static com.github.nhojpatrick.cucumber.http.constants.HttpConstants.HTTP_RESPONSE_BODY;
15+
import static org.hamcrest.MatcherAssert.assertThat;
16+
import static org.hamcrest.core.Is.is;
17+
import static org.hamcrest.core.IsEqual.equalTo;
18+
19+
public class HttpResponseSteps {
20+
21+
@SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "Accepted will look at changing")
22+
private final RunState runState;
23+
24+
@Inject
25+
public HttpResponseSteps(final RunState runState) {
26+
this.runState = runState;
27+
}
28+
29+
@Given("http response status code of {int}")
30+
public void httpResponseStatusCode(final int expectedStatusCode)
31+
throws IllegalKeyException,
32+
IllegalTypeClassException,
33+
NullRunStateException,
34+
TypeMismatchException {
35+
36+
RunStateValidatorFactory.getInstance()
37+
.withValue(HTTP_RESPONSE_BODY)
38+
.verify(this.runState);
39+
40+
final HttpResponse httpResponse = this.runState.get(HTTP_RESPONSE_BODY, HttpResponse.class);
41+
final int actualStatusCode = httpResponse.getStatusCode();
42+
43+
assertThat("Unexpected http status code", actualStatusCode, is(equalTo(expectedStatusCode)));
44+
}
45+
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.github.nhojpatrick.cucumber.http.response.steps;
2+
3+
public class ModuleInfoHack {
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module com.github.nhojpatrick.cucumber.http.response.glue {
2+
requires com.github.nhojpatrick.cucumber.http.constants;
3+
requires com.google.guice;
4+
requires io.cucumber.java;
5+
requires org.hamcrest;
6+
requires org.junit.jupiter.api;
7+
requires org.slf4j;
8+
requires transitive com.github.nhojpatrick.cucumber.http.response;
9+
requires transitive com.github.nhojpatrick.cucumber.state;
10+
}

http/response-glue/src/test/java/com/github/nhojpatrick/cucumber/http/response/steps/tests/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
open module com.github.nhojpatrick.cucumber.http.response.glue.test {
2+
requires com.github.nhojpatrick.cucumber.http.response.glue;
3+
requires org.apache.logging.log4j;
4+
requires org.hamcrest;
5+
requires transitive org.junit.jupiter.api;
6+
requires transitive org.junit.jupiter.engine;
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Configuration>
3+
<Appenders>
4+
<Console name="Console" target="SYSTEM_OUT">
5+
<PatternLayout pattern="TestConsole %-5p %l %m%n"/>
6+
</Console>
7+
</Appenders>
8+
<Loggers>
9+
<Logger name="com.github.nhojpatrick.cucumber.http.response.steps" level="debug">
10+
<AppenderRef ref="Console"/>
11+
</Logger>
12+
<Logger name="com.github.nhojpatrick" level="info">
13+
<AppenderRef ref="Console"/>
14+
</Logger>
15+
<Root level="error">
16+
<AppenderRef ref="Console"/>
17+
</Root>
18+
</Loggers>
19+
</Configuration>

pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,11 @@
990990
<artifactId>nhojpatrick-cucumber-http-response</artifactId>
991991
<version>${project.version}</version>
992992
</dependency>
993+
<dependency>
994+
<groupId>com.github.nhojpatrick.cucumber</groupId>
995+
<artifactId>nhojpatrick-cucumber-http-response-glue</artifactId>
996+
<version>${project.version}</version>
997+
</dependency>
993998
<dependency>
994999
<groupId>com.github.nhojpatrick.cucumber</groupId>
9951000
<artifactId>nhojpatrick-cucumber-json-all</artifactId>

0 commit comments

Comments
 (0)