Skip to content

Commit 3308597

Browse files
Merge pull request #112 from amido/feat/2355
2 parents 3aeb1cd + 27d51bc commit 3308597

34 files changed

+1344
-1192
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ The Java source code will automatically be reformatted to comply with [Google Ja
6767
You can override the settings in the codebase, for example:<br />
6868
```//@formatter:off```<br />
6969
```manually formatted code```<br />
70-
```///@formatter:on````<br />
70+
```///@formatter:on```<br />
7171

7272
###### Validate the formatting
7373
```

api-tests/pom.xml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
<pact.broker.url></pact.broker.url>
2424
<pact.broker.token></pact.broker.token>
2525
<owasp-dependency-check-plugin.version>5.3.2</owasp-dependency-check-plugin.version>
26+
<fmt-maven-plugin.version>2.10</fmt-maven-plugin.version>
27+
<maven-checkstyle-plugin.version>3.1.1</maven-checkstyle-plugin.version>
28+
<puppycrawl-tools-checkstyle.version>8.35</puppycrawl-tools-checkstyle.version>
29+
<spotbugs-maven-plugin.version>4.0.4</spotbugs-maven-plugin.version>
30+
<spotbugs.version>4.1.1</spotbugs.version>
2631
</properties>
2732

2833
<dependencies>
@@ -296,6 +301,59 @@
296301
</execution>
297302
</executions>
298303
</plugin>
304+
<plugin>
305+
<groupId>com.coveo</groupId>
306+
<artifactId>fmt-maven-plugin</artifactId>
307+
<version>${fmt-maven-plugin.version}</version>
308+
<configuration>
309+
<displayFiles>false</displayFiles>
310+
<verbose>true</verbose>
311+
<filesNamePattern>.*\.java</filesNamePattern>
312+
<additionalSourceDirectories/>
313+
<skip>false</skip>
314+
<skipSortingImports>false</skipSortingImports>
315+
<style>google</style>
316+
</configuration>
317+
</plugin>
318+
<plugin>
319+
<groupId>org.apache.maven.plugins</groupId>
320+
<artifactId>maven-checkstyle-plugin</artifactId>
321+
<version>${maven-checkstyle-plugin.version}</version>
322+
<dependencies>
323+
<!--Specify Dependent checkstyle Edition-->
324+
<dependency>
325+
<groupId>com.puppycrawl.tools</groupId>
326+
<artifactId>checkstyle</artifactId>
327+
<version>${puppycrawl-tools-checkstyle.version}</version>
328+
</dependency>
329+
</dependencies>
330+
<configuration>
331+
<configLocation>google_checks.xml</configLocation>
332+
<encoding>UTF-8</encoding>
333+
<consoleOutput>true</consoleOutput>
334+
<failsOnError>true</failsOnError>
335+
<linkXRef>false</linkXRef>
336+
</configuration>
337+
<executions>
338+
<execution>
339+
<id>validate</id>
340+
<phase>validate</phase>
341+
</execution>
342+
</executions>
343+
</plugin>
344+
<plugin>
345+
<groupId>com.github.spotbugs</groupId>
346+
<artifactId>spotbugs-maven-plugin</artifactId>
347+
<version>${spotbugs-maven-plugin.version}</version>
348+
<dependencies>
349+
<!-- overwrite dependency on spotbugs if you want to specify the version of spotbugs -->
350+
<dependency>
351+
<groupId>com.github.spotbugs</groupId>
352+
<artifactId>spotbugs</artifactId>
353+
<version>${spotbugs.version}</version>
354+
</dependency>
355+
</dependencies>
356+
</plugin>
299357
</plugins>
300358
</build>
301359
</project>

api-tests/src/test/java/com/xxAMIDOxx/xxSTACKSxx/api/CucumberTestSuite.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@
88

99
@RunWith(CucumberWithSerenity.class)
1010
@CucumberOptions(
11-
plugin = {"pretty", "html:target/cucumber"},
12-
features = "src/test/resources/features",
13-
tags = "(not @Ignore) and (@Smoke or @Regression or @Functional)"
14-
)
11+
plugin = {"pretty", "html:target/cucumber"},
12+
features = "src/test/resources/features",
13+
tags = "(not @Ignore) and (@Smoke or @Regression or @Functional)")
1514
public class CucumberTestSuite {
1615

17-
@BeforeClass
18-
public static void setup() {
19-
System.out.println("Delete all data from previous automated test");
20-
Hooks.deleteAllMenusFromPreviousRun();
21-
}
22-
16+
@BeforeClass
17+
public static void setup() {
18+
System.out.println("Delete all data from previous automated test");
19+
Hooks.deleteAllMenusFromPreviousRun();
20+
}
2321
}

api-tests/src/test/java/com/xxAMIDOxx/xxSTACKSxx/api/DeleteAllMenusCleanUp.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66

77
@RunWith(CucumberWithSerenity.class)
88
@CucumberOptions(
9-
plugin = {"pretty", "html:target/cucumber"},
10-
features = "src/test/resources/features",
11-
tags = "@DeleteAllMenusCleanUp"
12-
13-
)
9+
plugin = {"pretty", "html:target/cucumber"},
10+
features = "src/test/resources/features",
11+
tags = "@DeleteAllMenusCleanUp")
1412
public class DeleteAllMenusCleanUp {}
Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
package com.xxAMIDOxx.xxSTACKSxx.api;
22

33
public enum ExceptionMessages {
4+
MENU_ALREADY_EXISTS(
5+
"A Menu with the name '(.*)' already exists for the restaurant with id '(.*)'."),
6+
MENU_DOES_NOT_EXIST("A menu with id '(.*)' does not exist."),
47

5-
MENU_ALREADY_EXISTS("A Menu with the name '(.*)' already exists for the restaurant with id '(.*)'."),
6-
MENU_DOES_NOT_EXIST("A menu with id '(.*)' does not exist."),
8+
CATEGORY_DOES_NOT_EXIST("A category with the id '(.*)' does not exist for menu with id '(.*)'."),
9+
CATEGORY_ALREADY_EXISTS(
10+
"A category with the name '(.*)' already exists for the menu with id '(.*)'."),
711

8-
CATEGORY_DOES_NOT_EXIST("A category with the id '(.*)' does not exist for menu with id '(.*)'."),
9-
CATEGORY_ALREADY_EXISTS("A category with the name '(.*)' already exists for the menu with id '(.*)'."),
12+
ITEM_ALREADY_EXISTS(
13+
"An item with the name '(.*)' already exists for the category '(.*)' in menu with id '(.*)'."),
14+
ITEM_DOES_NOT_EXIST(
15+
"An item with the id '(.*)' does not exists for category with the id '(.*)' and for menu with id '(.*)'.");
1016

17+
private final String message;
1118

12-
ITEM_ALREADY_EXISTS("An item with the name '(.*)' already exists for the category '(.*)' in menu with id '(.*)'."),
13-
ITEM_DOES_NOT_EXIST("An item with the id '(.*)' does not exists for category with the id '(.*)' and for menu with id '(.*)'.");
14-
15-
private final String message;
16-
17-
ExceptionMessages(String message) {
18-
this.message = message;
19-
}
20-
21-
public String getMessage() {
22-
return message;
23-
}
19+
ExceptionMessages(String message) {
20+
this.message = message;
21+
}
2422

23+
public String getMessage() {
24+
return message;
25+
}
2526
}
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
package com.xxAMIDOxx.xxSTACKSxx.api;
22

33
public enum WebServiceEndPoints {
4-
BASE_URL(System.getenv("BASE_URL")),
5-
CATEGORY("/category"),
6-
STATUS("/health"),
7-
MENU("/v1/menu"),
8-
MENU_V2("/v2/menu"),
9-
ITEMS("/items");
4+
BASE_URL(System.getenv("BASE_URL")),
5+
CATEGORY("/category"),
6+
STATUS("/health"),
7+
MENU("/v1/menu"),
8+
MENU_V2("/v2/menu"),
9+
ITEMS("/items");
1010

11-
private final String url;
11+
private final String url;
1212

13-
WebServiceEndPoints(String url) {
14-
this.url = url;
15-
}
13+
WebServiceEndPoints(String url) {
14+
this.url = url;
15+
}
1616

17-
public String getUrl() {
18-
return url;
19-
}
17+
public String getUrl() {
18+
return url;
19+
}
2020
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.xxAMIDOxx.xxSTACKSxx.api.category;
22

33
import com.xxAMIDOxx.xxSTACKSxx.api.models.Category;
4-
54
import java.util.ArrayList;
65
import java.util.Map;
76

87
public class CategoryActions {
98

10-
public static Category mapToCategory(Map<String, String> properties, String id) {
11-
return new Category(id, properties.get("name"), properties.get("description"), new ArrayList<>());
12-
}
9+
public static Category mapToCategory(Map<String, String> properties, String id) {
10+
return new Category(
11+
id, properties.get("name"), properties.get("description"), new ArrayList<>());
12+
}
1313
}

api-tests/src/test/java/com/xxAMIDOxx/xxSTACKSxx/api/category/CategoryRequests.java

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,45 @@
66

77
public class CategoryRequests {
88

9-
String menuUrl = WebServiceEndPoints.BASE_URL.getUrl() + WebServiceEndPoints.MENU.getUrl();
9+
String menuUrl = WebServiceEndPoints.BASE_URL.getUrl() + WebServiceEndPoints.MENU.getUrl();
1010

11-
@Step("Create a new category")
12-
public void createCategory(String body, String menuID) {
13-
SerenityRest.given()
14-
.contentType("application/json")
15-
.header("Content-Type", "application/json")
16-
.body(body)
17-
.when()
18-
.post(menuUrl.concat("/").concat(menuID).concat(WebServiceEndPoints.CATEGORY.getUrl()));
19-
}
11+
@Step("Create a new category")
12+
public void createCategory(String body, String menuID) {
13+
SerenityRest.given()
14+
.contentType("application/json")
15+
.header("Content-Type", "application/json")
16+
.body(body)
17+
.when()
18+
.post(menuUrl.concat("/").concat(menuID).concat(WebServiceEndPoints.CATEGORY.getUrl()));
19+
}
2020

21-
@Step("Update the category")
22-
public void updateCategory(String body, String menuID, String categoryID) {
23-
SerenityRest.given()
24-
.contentType("application/json")
25-
.header("Content-Type", "application/json")
26-
.body(body)
27-
.when()
28-
.put(menuUrl.concat("/").concat(menuID).concat(WebServiceEndPoints.CATEGORY.getUrl())
29-
.concat("/").concat(categoryID));
30-
}
21+
@Step("Update the category")
22+
public void updateCategory(String body, String menuID, String categoryID) {
23+
SerenityRest.given()
24+
.contentType("application/json")
25+
.header("Content-Type", "application/json")
26+
.body(body)
27+
.when()
28+
.put(
29+
menuUrl
30+
.concat("/")
31+
.concat(menuID)
32+
.concat(WebServiceEndPoints.CATEGORY.getUrl())
33+
.concat("/")
34+
.concat(categoryID));
35+
}
3136

32-
@Step("Delete the category")
33-
public void deleteTheCategory(String menuID, String categoryID) {
34-
SerenityRest.given()
35-
.contentType("application/json")
36-
.when()
37-
.delete(menuUrl.concat("/").concat(menuID)
38-
.concat(WebServiceEndPoints.CATEGORY.getUrl())
39-
.concat("/").concat(categoryID));
40-
}
37+
@Step("Delete the category")
38+
public void deleteTheCategory(String menuID, String categoryID) {
39+
SerenityRest.given()
40+
.contentType("application/json")
41+
.when()
42+
.delete(
43+
menuUrl
44+
.concat("/")
45+
.concat(menuID)
46+
.concat(WebServiceEndPoints.CATEGORY.getUrl())
47+
.concat("/")
48+
.concat(categoryID));
49+
}
4150
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package com.xxAMIDOxx.xxSTACKSxx.api.item;
22

33
import com.xxAMIDOxx.xxSTACKSxx.api.models.Item;
4-
54
import java.util.Map;
65

76
public class ItemActions {
8-
public static Item mapToItem(Map<String, String> properties, String itemId) {
9-
return new Item(itemId,
10-
properties.get("name"),
11-
properties.get("description"),
12-
Double.valueOf(properties.get("price")),
13-
Boolean.parseBoolean(properties.get("available")));
14-
}
7+
public static Item mapToItem(Map<String, String> properties, String itemId) {
8+
return new Item(
9+
itemId,
10+
properties.get("name"),
11+
properties.get("description"),
12+
Double.valueOf(properties.get("price")),
13+
Boolean.parseBoolean(properties.get("available")));
14+
}
1515
}

0 commit comments

Comments
 (0)