-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Issue #70] Template for Rest API with Docker and WireMock
- Loading branch information
Piotr Michalski
committed
Mar 30, 2020
1 parent
d53915d
commit 9483261
Showing
20 changed files
with
1,325 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>sprimber-examples</artifactId> | ||
<groupId>com.griddynamics.qa</groupId> | ||
<version>1.1.3-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>sprimber-rest-template</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.griddynamics.qa</groupId> | ||
<artifactId>sprimber-spring-boot-starter</artifactId> | ||
<version>1.1.3-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<version>3.15.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.squareup.retrofit2</groupId> | ||
<artifactId>retrofit</artifactId> | ||
<version>2.8.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.squareup.retrofit2</groupId> | ||
<artifactId>converter-jackson</artifactId> | ||
<version>2.8.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>1.18.8</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<version>2.0.2.RELEASE</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>repackage</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>io.qameta.allure</groupId> | ||
<artifactId>allure-maven</artifactId> | ||
<version>2.10.0</version> | ||
<configuration> | ||
<resultsDirectory>${project.parent.parent.basedir}/allure-results</resultsDirectory> | ||
<reportVersion>2.7.0</reportVersion> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
37 changes: 37 additions & 0 deletions
37
.../sprimber-rest-template/src/main/java/com/griddynamics/qa/sprimber/test/RestTemplate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
Copyright (c) 2010-2018 Grid Dynamics International, Inc. All Rights Reserved | ||
http://www.griddynamics.com | ||
This library is free software; you can redistribute it and/or modify it under the terms of | ||
the GNU Lesser General Public License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or any later version. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
$Id: | ||
@Project: Sprimber | ||
@Description: Framework that provide bdd engine and bridges for most popular BDD frameworks | ||
*/ | ||
|
||
package com.griddynamics.qa.sprimber.test; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
/** | ||
* @author pmichalski | ||
*/ | ||
|
||
@SpringBootApplication | ||
public class RestTemplate { | ||
|
||
public static void main(String[] args) throws Exception { | ||
SpringApplication.exit(SpringApplication.run(RestTemplate.class)); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...mplate/src/main/java/com/griddynamics/qa/sprimber/test/configuration/DataTableFields.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright (c) 2010-2018 Grid Dynamics International, Inc. All Rights Reserved | ||
http://www.griddynamics.com | ||
This library is free software; you can redistribute it and/or modify it under the terms of | ||
the GNU Lesser General Public License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or any later version. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
$Id: | ||
@Project: Sprimber | ||
@Description: Framework that provide bdd engine and bridges for most popular BDD frameworks | ||
*/ | ||
|
||
package com.griddynamics.qa.sprimber.test.configuration; | ||
|
||
/** | ||
* @author pmichalski | ||
*/ | ||
|
||
public abstract class DataTableFields { | ||
private DataTableFields() { | ||
} | ||
|
||
public static final String REQUEST_ID = "requestId"; | ||
public static final String COUNTRY = "country"; | ||
public static final String CITY = "city"; | ||
public static final String STATUS_CODE = "statusCode"; | ||
} |
35 changes: 35 additions & 0 deletions
35
...emplate/src/main/java/com/griddynamics/qa/sprimber/test/configuration/RestProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
Copyright (c) 2010-2018 Grid Dynamics International, Inc. All Rights Reserved | ||
http://www.griddynamics.com | ||
This library is free software; you can redistribute it and/or modify it under the terms of | ||
the GNU Lesser General Public License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or any later version. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
$Id: | ||
@Project: Sprimber | ||
@Description: Framework that provide bdd engine and bridges for most popular BDD frameworks | ||
*/ | ||
|
||
package com.griddynamics.qa.sprimber.test.configuration; | ||
|
||
import lombok.Data; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
/** | ||
* @author pmichalski | ||
*/ | ||
|
||
@ConfigurationProperties("rest") | ||
@Data | ||
public class RestProperties { | ||
private String baseUrl; | ||
} |
63 changes: 63 additions & 0 deletions
63
.../main/java/com/griddynamics/qa/sprimber/test/configuration/RestTemplateConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
Copyright (c) 2010-2018 Grid Dynamics International, Inc. All Rights Reserved | ||
http://www.griddynamics.com | ||
This library is free software; you can redistribute it and/or modify it under the terms of | ||
the GNU Lesser General Public License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or any later version. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
$Id: | ||
@Project: Sprimber | ||
@Description: Framework that provide bdd engine and bridges for most popular BDD frameworks | ||
*/ | ||
|
||
package com.griddynamics.qa.sprimber.test.configuration; | ||
|
||
import com.griddynamics.qa.sprimber.scope.ScenarioScope; | ||
import com.griddynamics.qa.sprimber.test.repository.WeatherClient; | ||
import com.griddynamics.qa.sprimber.test.storage.WeatherStorage; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import retrofit2.Retrofit; | ||
import retrofit2.converter.jackson.JacksonConverterFactory; | ||
|
||
/** | ||
* @author pmichalski | ||
*/ | ||
|
||
@Configuration | ||
@EnableConfigurationProperties({RestProperties.class}) | ||
@RequiredArgsConstructor | ||
public class RestTemplateConfiguration { | ||
|
||
private final RestProperties restProperties; | ||
|
||
@Bean | ||
public Retrofit weatherServiceRetrofit() { | ||
return new Retrofit.Builder() | ||
.baseUrl(restProperties.getBaseUrl()) | ||
.addConverterFactory(JacksonConverterFactory.create()) | ||
.build(); | ||
} | ||
|
||
@Bean | ||
public WeatherClient weatherClient(Retrofit weatherServiceRetrofit) { | ||
return weatherServiceRetrofit.create(WeatherClient.class); | ||
} | ||
|
||
@Bean | ||
@ScenarioScope | ||
public WeatherStorage weatherStorage() { | ||
return new WeatherStorage(); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...-rest-template/src/main/java/com/griddynamics/qa/sprimber/test/model/WeatherResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
Copyright (c) 2010-2018 Grid Dynamics International, Inc. All Rights Reserved | ||
http://www.griddynamics.com | ||
This library is free software; you can redistribute it and/or modify it under the terms of | ||
the GNU Lesser General Public License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or any later version. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
$Id: | ||
@Project: Sprimber | ||
@Description: Framework that provide bdd engine and bridges for most popular BDD frameworks | ||
*/ | ||
|
||
package com.griddynamics.qa.sprimber.test.model; | ||
|
||
import lombok.Data; | ||
|
||
/** | ||
* @author pmichalski | ||
*/ | ||
|
||
@Data | ||
public class WeatherResponse { | ||
private Double temperature; | ||
private Long humidity; | ||
} |
36 changes: 36 additions & 0 deletions
36
...st-template/src/main/java/com/griddynamics/qa/sprimber/test/repository/WeatherClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright (c) 2010-2018 Grid Dynamics International, Inc. All Rights Reserved | ||
http://www.griddynamics.com | ||
This library is free software; you can redistribute it and/or modify it under the terms of | ||
the GNU Lesser General Public License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or any later version. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
$Id: | ||
@Project: Sprimber | ||
@Description: Framework that provide bdd engine and bridges for most popular BDD frameworks | ||
*/ | ||
|
||
package com.griddynamics.qa.sprimber.test.repository; | ||
|
||
import com.griddynamics.qa.sprimber.test.model.WeatherResponse; | ||
import retrofit2.Call; | ||
import retrofit2.http.GET; | ||
import retrofit2.http.Path; | ||
|
||
/** | ||
* @author pmichalski | ||
*/ | ||
|
||
public interface WeatherClient { | ||
@GET("/currentWeather/{country}/{city}") | ||
Call<WeatherResponse> getCurrentWeather(@Path("country") String country, @Path("city") String city); | ||
} |
Oops, something went wrong.