Compare commits
2 commits
65f4ba4a00
...
b64917bb5a
| Author | SHA1 | Date | |
|---|---|---|---|
| b64917bb5a | |||
| 4fd1457843 |
9 changed files with 66 additions and 70 deletions
13
panier/src/main/java/org/example/Accounting.java
Normal file
13
panier/src/main/java/org/example/Accounting.java
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
package org.example;
|
||||||
|
|
||||||
|
public class Accounting {
|
||||||
|
private String accounting;
|
||||||
|
|
||||||
|
public Accounting(String pAccounting) {
|
||||||
|
this.accounting = pAccounting;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void process(String contenu) {
|
||||||
|
System.out.println("comptabilité:" + contenu.toString().toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
22
panier/src/main/java/org/example/Cart.java
Normal file
22
panier/src/main/java/org/example/Cart.java
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
package org.example;
|
||||||
|
|
||||||
|
public class Cart {
|
||||||
|
private StockManagement stock;
|
||||||
|
private Accounting accounting;
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
public Cart(StockManagement pStock, Accounting pAccounting) {
|
||||||
|
this.stock = pStock;
|
||||||
|
this.accounting = pAccounting;
|
||||||
|
this.content = new String ("Contenu du panier");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return this.content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initiateOrder() {
|
||||||
|
this.stock.process(this.content);
|
||||||
|
this.accounting.process(this.content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
package org.example;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class Comptabilite {
|
|
||||||
private String comptabilite;
|
|
||||||
|
|
||||||
public Comptabilite(String pComptabilite) {
|
|
||||||
this.comptabilite = pComptabilite;
|
|
||||||
}
|
|
||||||
public void traite(String contenu) {
|
|
||||||
System.out.println("comptabilité:" + contenu.toString().toLowerCase());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
package org.example;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class GestionDeStock {
|
|
||||||
private String gestionStock;
|
|
||||||
|
|
||||||
public GestionDeStock(String pGestionStock) {
|
|
||||||
this.gestionStock = pGestionStock;
|
|
||||||
}
|
|
||||||
public void traite(String contenu) {
|
|
||||||
|
|
||||||
System.out.println("G.DES.STOCKS:" + contenu.toString().toUpperCase());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
package org.example;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
public class Panier {
|
|
||||||
private GestionDeStock stock;
|
|
||||||
private Comptabilite compta;
|
|
||||||
private String contenu;
|
|
||||||
|
|
||||||
public Panier (GestionDeStock pStock, Comptabilite pCompta) {
|
|
||||||
this.stock = pStock;
|
|
||||||
this.compta = pCompta;
|
|
||||||
this.contenu = new String ("Contenu du panier");
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getContenu() {
|
|
||||||
return this.contenu;
|
|
||||||
};
|
|
||||||
|
|
||||||
public void declencherCommande() {
|
|
||||||
this.stock.traite(this.contenu);
|
|
||||||
this.compta.traite(this.contenu);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
13
panier/src/main/java/org/example/StockManagement.java
Normal file
13
panier/src/main/java/org/example/StockManagement.java
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
package org.example;
|
||||||
|
|
||||||
|
public class StockManagement {
|
||||||
|
private String stockManagement;
|
||||||
|
|
||||||
|
public StockManagement(String pStockManagement) {
|
||||||
|
this.stockManagement = pStockManagement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void process(String contenu) {
|
||||||
|
System.out.println("G.DES.STOCKS:" + contenu.toString().toUpperCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,15 +7,15 @@ import java.io.PrintStream;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
class ComptabiliteTest {
|
class AccountingTest {
|
||||||
@Test
|
@Test
|
||||||
void testTraite() {
|
void testProcess() {
|
||||||
Comptabilite compta = new Comptabilite("Compta1");
|
Accounting compta = new Accounting("Compta1");
|
||||||
|
|
||||||
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
|
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
|
||||||
System.setOut(new PrintStream(outContent));
|
System.setOut(new PrintStream(outContent));
|
||||||
|
|
||||||
compta.traite("Test Contenu");
|
compta.process("Test Contenu");
|
||||||
|
|
||||||
assertEquals("comptabilité:test contenu\n", outContent.toString());
|
assertEquals("comptabilité:test contenu\n", outContent.toString());
|
||||||
|
|
||||||
|
|
@ -7,26 +7,26 @@ import java.io.PrintStream;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
class PanierTest {
|
class CartTest {
|
||||||
@Test
|
@Test
|
||||||
void testGetContenu() {
|
void testGetContenu() {
|
||||||
GestionDeStock stock = new GestionDeStock("Stock1");
|
StockManagement stock = new StockManagement("Stock1");
|
||||||
Comptabilite compta = new Comptabilite("Compta1");
|
Accounting compta = new Accounting("Compta1");
|
||||||
Panier panier = new Panier(stock, compta);
|
Cart cart = new Cart(stock, compta);
|
||||||
|
|
||||||
assertEquals("Contenu du panier", panier.getContenu());
|
assertEquals("Contenu du panier", cart.getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDeclencherCommande() {
|
void testInitiateOrder() {
|
||||||
GestionDeStock stock = new GestionDeStock("Stock1");
|
StockManagement stock = new StockManagement("Stock1");
|
||||||
Comptabilite compta = new Comptabilite("Compta1");
|
Accounting compta = new Accounting("Compta1");
|
||||||
Panier panier = new Panier(stock, compta);
|
Cart cart = new Cart(stock, compta);
|
||||||
|
|
||||||
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
|
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
|
||||||
System.setOut(new PrintStream(outContent));
|
System.setOut(new PrintStream(outContent));
|
||||||
|
|
||||||
panier.declencherCommande();
|
cart.initiateOrder();
|
||||||
|
|
||||||
String expectedOutput = "G.DES.STOCKS:CONTENU DU PANIER\ncomptabilité:contenu du panier\n";
|
String expectedOutput = "G.DES.STOCKS:CONTENU DU PANIER\ncomptabilité:contenu du panier\n";
|
||||||
assertEquals(expectedOutput, outContent.toString());
|
assertEquals(expectedOutput, outContent.toString());
|
||||||
|
|
@ -7,15 +7,15 @@ import java.io.PrintStream;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
class GestionDeStockTest {
|
class StockManagementTest {
|
||||||
@Test
|
@Test
|
||||||
void testTraite() {
|
void testProcess() {
|
||||||
GestionDeStock stock = new GestionDeStock("Stock1");
|
StockManagement stock = new StockManagement("Stock1");
|
||||||
|
|
||||||
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
|
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
|
||||||
System.setOut(new PrintStream(outContent));
|
System.setOut(new PrintStream(outContent));
|
||||||
|
|
||||||
stock.traite("Test Contenu");
|
stock.process("Test Contenu");
|
||||||
|
|
||||||
assertEquals("G.DES.STOCKS:TEST CONTENU\n", outContent.toString());
|
assertEquals("G.DES.STOCKS:TEST CONTENU\n", outContent.toString());
|
||||||
|
|
||||||
Loading…
Add table
Reference in a new issue