Skip to content

Commit

Permalink
Merge pull request #112 from amido/feat/2355
Browse files Browse the repository at this point in the history
  • Loading branch information
ElvenSpellmaker authored Sep 1, 2020
2 parents 3aeb1cd + 27d51bc commit 3308597
Show file tree
Hide file tree
Showing 34 changed files with 1,344 additions and 1,192 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The Java source code will automatically be reformatted to comply with [Google Ja
You can override the settings in the codebase, for example:<br />
```//@formatter:off```<br />
```manually formatted code```<br />
```///@formatter:on````<br />
```///@formatter:on```<br />

###### Validate the formatting
```
Expand Down
58 changes: 58 additions & 0 deletions api-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
<pact.broker.url></pact.broker.url>
<pact.broker.token></pact.broker.token>
<owasp-dependency-check-plugin.version>5.3.2</owasp-dependency-check-plugin.version>
<fmt-maven-plugin.version>2.10</fmt-maven-plugin.version>
<maven-checkstyle-plugin.version>3.1.1</maven-checkstyle-plugin.version>
<puppycrawl-tools-checkstyle.version>8.35</puppycrawl-tools-checkstyle.version>
<spotbugs-maven-plugin.version>4.0.4</spotbugs-maven-plugin.version>
<spotbugs.version>4.1.1</spotbugs.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -296,6 +301,59 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.coveo</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<version>${fmt-maven-plugin.version}</version>
<configuration>
<displayFiles>false</displayFiles>
<verbose>true</verbose>
<filesNamePattern>.*\.java</filesNamePattern>
<additionalSourceDirectories/>
<skip>false</skip>
<skipSortingImports>false</skipSortingImports>
<style>google</style>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<dependencies>
<!--Specify Dependent checkstyle Edition-->
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${puppycrawl-tools-checkstyle.version}</version>
</dependency>
</dependencies>
<configuration>
<configLocation>google_checks.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<linkXRef>false</linkXRef>
</configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs-maven-plugin.version}</version>
<dependencies>
<!-- overwrite dependency on spotbugs if you want to specify the version of spotbugs -->
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>${spotbugs.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@

@RunWith(CucumberWithSerenity.class)
@CucumberOptions(
plugin = {"pretty", "html:target/cucumber"},
features = "src/test/resources/features",
tags = "(not @Ignore) and (@Smoke or @Regression or @Functional)"
)
plugin = {"pretty", "html:target/cucumber"},
features = "src/test/resources/features",
tags = "(not @Ignore) and (@Smoke or @Regression or @Functional)")
public class CucumberTestSuite {

@BeforeClass
public static void setup() {
System.out.println("Delete all data from previous automated test");
Hooks.deleteAllMenusFromPreviousRun();
}

@BeforeClass
public static void setup() {
System.out.println("Delete all data from previous automated test");
Hooks.deleteAllMenusFromPreviousRun();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

@RunWith(CucumberWithSerenity.class)
@CucumberOptions(
plugin = {"pretty", "html:target/cucumber"},
features = "src/test/resources/features",
tags = "@DeleteAllMenusCleanUp"

)
plugin = {"pretty", "html:target/cucumber"},
features = "src/test/resources/features",
tags = "@DeleteAllMenusCleanUp")
public class DeleteAllMenusCleanUp {}
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
package com.xxAMIDOxx.xxSTACKSxx.api;

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

MENU_ALREADY_EXISTS("A Menu with the name '(.*)' already exists for the restaurant with id '(.*)'."),
MENU_DOES_NOT_EXIST("A menu with id '(.*)' does not exist."),
CATEGORY_DOES_NOT_EXIST("A category with the id '(.*)' does not exist for menu with id '(.*)'."),
CATEGORY_ALREADY_EXISTS(
"A category with the name '(.*)' already exists for the menu with id '(.*)'."),

CATEGORY_DOES_NOT_EXIST("A category with the id '(.*)' does not exist for menu with id '(.*)'."),
CATEGORY_ALREADY_EXISTS("A category with the name '(.*)' already exists for the menu with id '(.*)'."),
ITEM_ALREADY_EXISTS(
"An item with the name '(.*)' already exists for the category '(.*)' in menu with id '(.*)'."),
ITEM_DOES_NOT_EXIST(
"An item with the id '(.*)' does not exists for category with the id '(.*)' and for menu with id '(.*)'.");

private final String message;

ITEM_ALREADY_EXISTS("An item with the name '(.*)' already exists for the category '(.*)' in menu with id '(.*)'."),
ITEM_DOES_NOT_EXIST("An item with the id '(.*)' does not exists for category with the id '(.*)' and for menu with id '(.*)'.");

private final String message;

ExceptionMessages(String message) {
this.message = message;
}

public String getMessage() {
return message;
}
ExceptionMessages(String message) {
this.message = message;
}

public String getMessage() {
return message;
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package com.xxAMIDOxx.xxSTACKSxx.api;

public enum WebServiceEndPoints {
BASE_URL(System.getenv("BASE_URL")),
CATEGORY("/category"),
STATUS("/health"),
MENU("/v1/menu"),
MENU_V2("/v2/menu"),
ITEMS("/items");
BASE_URL(System.getenv("BASE_URL")),
CATEGORY("/category"),
STATUS("/health"),
MENU("/v1/menu"),
MENU_V2("/v2/menu"),
ITEMS("/items");

private final String url;
private final String url;

WebServiceEndPoints(String url) {
this.url = url;
}
WebServiceEndPoints(String url) {
this.url = url;
}

public String getUrl() {
return url;
}
public String getUrl() {
return url;
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.xxAMIDOxx.xxSTACKSxx.api.category;

import com.xxAMIDOxx.xxSTACKSxx.api.models.Category;

import java.util.ArrayList;
import java.util.Map;

public class CategoryActions {

public static Category mapToCategory(Map<String, String> properties, String id) {
return new Category(id, properties.get("name"), properties.get("description"), new ArrayList<>());
}
public static Category mapToCategory(Map<String, String> properties, String id) {
return new Category(
id, properties.get("name"), properties.get("description"), new ArrayList<>());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,45 @@

public class CategoryRequests {

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

@Step("Create a new category")
public void createCategory(String body, String menuID) {
SerenityRest.given()
.contentType("application/json")
.header("Content-Type", "application/json")
.body(body)
.when()
.post(menuUrl.concat("/").concat(menuID).concat(WebServiceEndPoints.CATEGORY.getUrl()));
}
@Step("Create a new category")
public void createCategory(String body, String menuID) {
SerenityRest.given()
.contentType("application/json")
.header("Content-Type", "application/json")
.body(body)
.when()
.post(menuUrl.concat("/").concat(menuID).concat(WebServiceEndPoints.CATEGORY.getUrl()));
}

@Step("Update the category")
public void updateCategory(String body, String menuID, String categoryID) {
SerenityRest.given()
.contentType("application/json")
.header("Content-Type", "application/json")
.body(body)
.when()
.put(menuUrl.concat("/").concat(menuID).concat(WebServiceEndPoints.CATEGORY.getUrl())
.concat("/").concat(categoryID));
}
@Step("Update the category")
public void updateCategory(String body, String menuID, String categoryID) {
SerenityRest.given()
.contentType("application/json")
.header("Content-Type", "application/json")
.body(body)
.when()
.put(
menuUrl
.concat("/")
.concat(menuID)
.concat(WebServiceEndPoints.CATEGORY.getUrl())
.concat("/")
.concat(categoryID));
}

@Step("Delete the category")
public void deleteTheCategory(String menuID, String categoryID) {
SerenityRest.given()
.contentType("application/json")
.when()
.delete(menuUrl.concat("/").concat(menuID)
.concat(WebServiceEndPoints.CATEGORY.getUrl())
.concat("/").concat(categoryID));
}
@Step("Delete the category")
public void deleteTheCategory(String menuID, String categoryID) {
SerenityRest.given()
.contentType("application/json")
.when()
.delete(
menuUrl
.concat("/")
.concat(menuID)
.concat(WebServiceEndPoints.CATEGORY.getUrl())
.concat("/")
.concat(categoryID));
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.xxAMIDOxx.xxSTACKSxx.api.item;

import com.xxAMIDOxx.xxSTACKSxx.api.models.Item;

import java.util.Map;

public class ItemActions {
public static Item mapToItem(Map<String, String> properties, String itemId) {
return new Item(itemId,
properties.get("name"),
properties.get("description"),
Double.valueOf(properties.get("price")),
Boolean.parseBoolean(properties.get("available")));
}
public static Item mapToItem(Map<String, String> properties, String itemId) {
return new Item(
itemId,
properties.get("name"),
properties.get("description"),
Double.valueOf(properties.get("price")),
Boolean.parseBoolean(properties.get("available")));
}
}
Loading

0 comments on commit 3308597

Please sign in to comment.