From a0083d1776b95c758d3daaec4ed3d697d3dbd904 Mon Sep 17 00:00:00 2001
From: Thierry Vuilleumier <thierry.vuilleumier@etu.hesge.ch>
Date: Sun, 3 Feb 2019 23:05:47 +0100
Subject: [PATCH] delete toString() method when sysout is called

---
 .../java/ch/hepia/account/AccountService.java     | 12 ++++++------
 .../main/java/ch/hepia/order/OrderService.java    | 15 ++++++---------
 .../main/java/ch/hepia/stock/StockService.java    | 12 ++++++------
 3 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/services/src/main/java/ch/hepia/account/AccountService.java b/services/src/main/java/ch/hepia/account/AccountService.java
index 3377d9b..21e68f6 100644
--- a/services/src/main/java/ch/hepia/account/AccountService.java
+++ b/services/src/main/java/ch/hepia/account/AccountService.java
@@ -68,18 +68,18 @@ public class AccountService{
                                 EventCreateAccount e = (EventCreateAccount) obj;
                                 accountsDB.addAccount(new Account(accountsDB.nextID(), e.name(), 0.0));
                                 send(new EventAccountCreated(e.id(), "The account is created"));
-                                System.out.println(e.toString());
+                                System.out.println(e);
                             }
                             //------------------------------------------
                             if(obj instanceof EventAccountDoesntExist){
                                 EventAccountDoesntExist e = (EventAccountDoesntExist) obj;
-                                System.out.println(e.toString());
+                                System.out.println(e);
                                 send(new EventOrderCancelled(e.id(), "Account used in order doesn't exist"));
                             }
                             //------------------------------------------
                             if (obj instanceof EventAccountCreated){
                                 EventAccountCreated e = (EventAccountCreated) obj;
-                                System.out.println(e.toString());
+                                System.out.println(e);
                             }
                             //------------------------------------------
                             if (obj instanceof EventCreditAnAccount){
@@ -91,7 +91,7 @@ public class AccountService{
                                 else{
                                     send(new EventAccountDoesntExist(e.id(), "The account doesn't exist"));
                                 }
-                                System.out.println(e.toString());
+                                System.out.println(e);
                             }
                             //------------------------------------------
                             if (obj instanceof EventOrderPlaced){
@@ -105,14 +105,14 @@ public class AccountService{
                                 } else {
                                     send(new EventAccountDoesntExist(e.id(), "The account doesn't exist"));
                                 }
-                                System.out.println(e.toString());
+                                System.out.println(e);
                             }
                             //------------------------------------------
                             if(obj instanceof EventOrderPrepared){
                                 EventOrderPrepared e = (EventOrderPrepared) obj;
                                 accountsDB.withdrawCreditAccount(e.idAccount(), e.price());
                                 send(new EventCreditWithdrawn(e.id(), "The account credit has been withdrawn"));
-                                System.out.println(e.toString());
+                                System.out.println(e);
                             }
                         }
                     } catch (JMSException e) {
diff --git a/services/src/main/java/ch/hepia/order/OrderService.java b/services/src/main/java/ch/hepia/order/OrderService.java
index c4442b3..6a49b21 100644
--- a/services/src/main/java/ch/hepia/order/OrderService.java
+++ b/services/src/main/java/ch/hepia/order/OrderService.java
@@ -64,35 +64,35 @@ public class OrderService{
                             if (obj instanceof EventOrderCreated){
                                 EventOrderCreated e = (EventOrderCreated) obj;
                                 ordersDB.add(new Order(e.id(), e.idAccount(), e.products()));
-                                System.out.println(e.toString());
+                                System.out.println(e);
                             }
                             //------------------------------------------
                             if (obj instanceof EventCreditRefused){
                                 EventCreditRefused e = (EventCreditRefused) obj;
                                 send(new EventOrderCancelled(e.id(), "Credit is too low"));
-                                System.out.println(e.toString());
+                                System.out.println(e);
                             }
                             //------------------------------------------
                             if (obj instanceof EventProductOutOfStock){
                                 EventProductOutOfStock e = (EventProductOutOfStock) obj;
                                 send(new EventOrderCancelled(e.id(), "There are not enough products"));
-                                System.out.println(e.toString());
+                                System.out.println(e);
                             }
                             //------------------------------------------
                             if (obj instanceof EventCreditWithdrawn){
                                 EventCreditWithdrawn e = (EventCreditWithdrawn) obj;
                                 send(new EventOrderSent(e.id(), "Order is sent"));
-                                System.out.println(e.toString());
+                                System.out.println(e);
                             }
                             //----------------------------------------------
                             if (obj instanceof EventOrderSent){
                                 EventOrderSent e = (EventOrderSent) obj;
-                                System.out.println(e.toString());
+                                System.out.println(e);
                             }
                             //------------------------------------------------
                             if (obj instanceof EventOrderCancelled){
                                 EventOrderCancelled e = (EventOrderCancelled) obj;
-                                System.out.println(e.toString());
+                                System.out.println(e);
                             }
                         }
                     } catch (JMSException e) {
@@ -101,9 +101,6 @@ public class OrderService{
                 }
             });
 
-            // TextMessage txtMessage = session.createTextMessage("Test");
-            // producer.send(txtMessage);
-
         } catch (JMSException e) {
             e.printStackTrace();
         }
diff --git a/services/src/main/java/ch/hepia/stock/StockService.java b/services/src/main/java/ch/hepia/stock/StockService.java
index 206c39d..6448427 100644
--- a/services/src/main/java/ch/hepia/stock/StockService.java
+++ b/services/src/main/java/ch/hepia/stock/StockService.java
@@ -72,19 +72,19 @@ public class StockService {
                                 // des produits
                                 stockDB.addQuantity(idProduct, 0); // ajout au stock avec quantité 0
                                 send(new EventProductCreated(e.id(), "The product is created"));
-                                System.out.println(e.toString());
+                                System.out.println(e);
                                 // productsDB.database.forEach(i -> System.out.println(i.name() + i.price()));
                             }
                             // ------------------------------------------
                             if (obj instanceof EventProductDoesntExist) {
                                 EventProductDoesntExist e = (EventProductDoesntExist) obj;
-                                System.out.println(e.toString());
+                                System.out.println(e);
                                 send(new EventOrderCancelled(e.id(), "Products in order don't exist"));
                             }
                             // ------------------------------------------
                             if (obj instanceof EventProductCreated) {
                                 EventProductCreated e = (EventProductCreated) obj;
-                                System.out.println(e.toString());
+                                System.out.println(e);
                             }
                             // ------------------------------------------
                             if (obj instanceof EventAddProductQuantity) {
@@ -97,12 +97,12 @@ public class StockService {
                                     send(new EventProductDoesntExist(e.id(), "Product doesn't exist"));
                                 }
                                 
-                                System.out.println(e.toString());
+                                System.out.println(e);
                             }
 
                             if(obj instanceof EventProductQuantityAdded){
                                 EventProductQuantityAdded e = (EventProductQuantityAdded) obj;
-                                System.out.println(e.toString());
+                                System.out.println(e);
                             }
 
                             // ------------------------------------------
@@ -123,7 +123,7 @@ public class StockService {
                                     send(new EventOrderPrepared(e.id(), "Order is prepared", e.idAccount(), e.price()));
                                 else
                                     send(new EventProductOutOfStock(e.id(), "We are out of stock"));
-                                System.out.println(e.toString());
+                                System.out.println(e);
 
                             }
                         }
-- 
GitLab