Skip to content
Snippets Groups Projects
Commit 115264ce authored by roxanne.grant's avatar roxanne.grant
Browse files

created an idService in class http to increment id at each new scenario

parent 00a083d2
No related branches found
No related tags found
No related merge requests found
......@@ -19,22 +19,27 @@ public class http {
private static OrderService orderService;
private static AccountService accountService;
private static StockService stockService;
private static int idService;
public static void main(String[] args) {
http.orderService = new OrderService("localhost");
http.accountService = new AccountService("localhost");
http.stockService = new StockService("localhost");
http.idService = 0;
SpringApplication.run(http.class, args);
}
public static int getId() { return http.idService; }
public static void incrementId() { http.idService++; }
@RequestMapping("/order")
public Order order(
@RequestParam(value = "idAccount", defaultValue = "1") int idAccount,
@RequestParam(value = "idProduct", defaultValue = "1") int idProduct,
@RequestParam(value = "quantity", defaultValue = "1") int quantity ) {
int idOrder = 5;
Order o = new Order(idOrder, idAccount);
http.incrementId();
Order o = new Order(http.getId(), idAccount);
o.addProduct(idProduct, quantity);
Event oc = new EventOrderCreated(o.id(), "hello", idAccount, o.getProducts());
......@@ -45,8 +50,8 @@ public class http {
@RequestMapping("/orderNotExistingProducts")
public Order orderNotExistingProducts() {
int idAccount = 1;
int idOrder = 5;
Order o = new Order(idOrder, idAccount);
http.incrementId();
Order o = new Order(http.getId(), idAccount);
o.addProduct(1, 4);
o.addProduct(999, 4);
Event oc = new EventOrderCreated(o.id(), "hello", idAccount, o.getProducts());
......@@ -56,7 +61,8 @@ public class http {
@RequestMapping("/createAccount")
public String createAccount(@RequestParam(value = "name", defaultValue = "Orphée") String name) {
accountService.send(new EventCreateAccount(1, "Creating the account", name));
http.incrementId();
accountService.send(new EventCreateAccount(http.getId(), "Creating the account", name));
return name;
}
......@@ -64,7 +70,8 @@ public class http {
public String createAccount(
@RequestParam(value = "idAccount", defaultValue = "1") int idAccount,
@RequestParam(value = "amount", defaultValue = "1") double amount) {
accountService.send(new EventCreditAnAccount(5, "Crediting account", idAccount, amount));
http.incrementId();
accountService.send(new EventCreditAnAccount(http.getId(), "Crediting account", idAccount, amount));
return null;
}
......@@ -72,8 +79,8 @@ public class http {
@RequestMapping("/createProduct")
public Product createProduct(@RequestParam(value = "name", defaultValue = "poire") String name,
@RequestParam(value = "price", defaultValue = "1") double price) {
stockService.send(new EventCreateProduct(1, "Creating the product", name, price));
http.incrementId();
stockService.send(new EventCreateProduct(http.getId(), "Creating the product", name, price));
return null;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment