From 1c9cd2f21a128f90cc164425a1a51cb0c9420353 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Fri, 30 Nov 2018 17:49:55 +0100 Subject: [PATCH] [POO Note] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Ajout de compareTo à Agence - Ajout du test unitaire pour Agence - Fix test unitaire EmprunteurTest --- ENSIM/Java/POOtpnote/.idea/workspace.xml | 217 +++++++++++------- .../src/main/java/entity/Administrateur.java | 5 - .../src/main/java/entity/Agence.java | 22 +- .../src/main/java/entity/Emprunteur.java | 2 +- .../POOtpnote/src/test/java/AgenceTest.java | 37 +++ .../src/test/java/EmprunteurTest.java | 9 +- .../classes/entity/Administrateur.class | Bin 3169 -> 3169 bytes .../target/classes/entity/Agence.class | Bin 1211 -> 1804 bytes .../target/test-classes/AgenceTest.class | Bin 0 -> 1282 bytes .../target/test-classes/EmprunteurTest.class | Bin 1601 -> 1592 bytes 10 files changed, 201 insertions(+), 91 deletions(-) create mode 100644 ENSIM/Java/POOtpnote/src/test/java/AgenceTest.java create mode 100644 ENSIM/Java/POOtpnote/target/test-classes/AgenceTest.class diff --git a/ENSIM/Java/POOtpnote/.idea/workspace.xml b/ENSIM/Java/POOtpnote/.idea/workspace.xml index 4e3f6f3..4f180cf 100644 --- a/ENSIM/Java/POOtpnote/.idea/workspace.xml +++ b/ENSIM/Java/POOtpnote/.idea/workspace.xml @@ -2,7 +2,15 @@ + + + + + + + + @@ -22,24 +30,24 @@ - + - + - + - + @@ -49,8 +57,20 @@ - - + + + + + + + + + + + + + + @@ -61,8 +81,8 @@ - - + + @@ -76,6 +96,20 @@ + + + + + + + + + + + + + + @@ -106,11 +140,11 @@ - + - - + + @@ -119,8 +153,8 @@ - - + + @@ -129,12 +163,14 @@ - - + + + + @@ -184,8 +220,6 @@ @@ -282,7 +319,7 @@ - + @@ -301,7 +338,7 @@ - + + + + @@ -343,15 +390,6 @@ - - - - - - - - - @@ -373,6 +411,15 @@ + + + + + + + + + @@ -392,7 +439,7 @@ - + @@ -400,7 +447,7 @@ - + @@ -433,18 +480,6 @@ - - - - - - - - - - - - @@ -545,18 +580,6 @@ - - - - - - - - - - - - @@ -583,10 +606,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -599,34 +676,16 @@ - + - - + + - - - - - - - - - - - - - - - - - - diff --git a/ENSIM/Java/POOtpnote/src/main/java/entity/Administrateur.java b/ENSIM/Java/POOtpnote/src/main/java/entity/Administrateur.java index 9a82ca5..817c7b9 100644 --- a/ENSIM/Java/POOtpnote/src/main/java/entity/Administrateur.java +++ b/ENSIM/Java/POOtpnote/src/main/java/entity/Administrateur.java @@ -118,11 +118,6 @@ public class Administrateur extends Employe { } } - /*public Agence getAgencePlusMaterielDefectueux() - { - - }*/ - public void achatDeMateriel(Empruntable empruntable) { entreprise.ajouterAuStock(empruntable); diff --git a/ENSIM/Java/POOtpnote/src/main/java/entity/Agence.java b/ENSIM/Java/POOtpnote/src/main/java/entity/Agence.java index dfc0243..33a2837 100644 --- a/ENSIM/Java/POOtpnote/src/main/java/entity/Agence.java +++ b/ENSIM/Java/POOtpnote/src/main/java/entity/Agence.java @@ -3,7 +3,7 @@ package entity; import java.util.ArrayList; import java.util.List; -public class Agence extends Emprunteur { +public class Agence extends Emprunteur implements Comparable { private List employes; private String nom; @@ -31,4 +31,24 @@ public class Agence extends Emprunteur { return stock; } + + public int getNbMaterielDefectueux() + { + int nb = 0; + + for(Empruntable empruntable : listeMateriel()) + { + if(empruntable.isDefectueux()) + { + nb++; + } + } + + return nb; + } + + public int compareTo(Agence o) + { + return (getNbMaterielDefectueux() - o.getNbMaterielDefectueux()); + } } diff --git a/ENSIM/Java/POOtpnote/src/main/java/entity/Emprunteur.java b/ENSIM/Java/POOtpnote/src/main/java/entity/Emprunteur.java index 966b0cb..d8191bd 100644 --- a/ENSIM/Java/POOtpnote/src/main/java/entity/Emprunteur.java +++ b/ENSIM/Java/POOtpnote/src/main/java/entity/Emprunteur.java @@ -3,7 +3,7 @@ package entity; import java.util.ArrayList; import java.util.List; -public class Emprunteur { +public class Emprunteur{ private List stock; diff --git a/ENSIM/Java/POOtpnote/src/test/java/AgenceTest.java b/ENSIM/Java/POOtpnote/src/test/java/AgenceTest.java new file mode 100644 index 0000000..88e92d5 --- /dev/null +++ b/ENSIM/Java/POOtpnote/src/test/java/AgenceTest.java @@ -0,0 +1,37 @@ +import entity.Agence; +import entity.Empruntable; +import entity.Emprunteur; +import material.CasqueAvecMicro; +import material.TELPortable; +import material.UC; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class AgenceTest { + + Agence a1; + Agence a2; + + @Before + public void setUp() { + a1 = new Agence("Le Mans"); + a2 = new Agence("Paris"); + } + + @Test + public void compareAgence() { + Empruntable e1 = new UC(); + Empruntable e2 = new CasqueAvecMicro(); + Empruntable e3 = new TELPortable(); + + e1.declarerDefectueux(); + + a1.ajouterAuStock(e1); + a2.ajouterAuStock(e2); + a2.ajouterAuStock(e3); + + //Test si a1 a plus d'object défectueux que a2 + Assert.assertEquals("compareTo: fail", a1.compareTo(a2) == 1, true); + } +} diff --git a/ENSIM/Java/POOtpnote/src/test/java/EmprunteurTest.java b/ENSIM/Java/POOtpnote/src/test/java/EmprunteurTest.java index 5bbd730..85c226b 100644 --- a/ENSIM/Java/POOtpnote/src/test/java/EmprunteurTest.java +++ b/ENSIM/Java/POOtpnote/src/test/java/EmprunteurTest.java @@ -4,8 +4,8 @@ import entity.Empruntable; import entity.Emprunteur; import material.UC; import org.junit.Assert; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; +import org.junit.Before; +import org.junit.Test; import java.util.ArrayList; @@ -14,9 +14,8 @@ import java.util.ArrayList; public class EmprunteurTest { static Emprunteur e1; - //TODO Passage de @Before à @BeforeAll + passage de la méthode en static - @BeforeAll - public static void setUp() { + @Before + public void setUp() { e1 = new Emprunteur(); } diff --git a/ENSIM/Java/POOtpnote/target/classes/entity/Administrateur.class b/ENSIM/Java/POOtpnote/target/classes/entity/Administrateur.class index 8ef6e1a059750e7a45b721cec3d2497c525893fb..ce1838309f7a2ad0cec31c4430591efa7386e6bc 100644 GIT binary patch delta 17 YcmaDT@laxe84qhU11CexWNRKZ05xa?>Hq)$ delta 17 YcmaDT@laxe84qg%11Ce{WNRKZ05z@z^Z)<= diff --git a/ENSIM/Java/POOtpnote/target/classes/entity/Agence.class b/ENSIM/Java/POOtpnote/target/classes/entity/Agence.class index 979029651d71789afb7ea85938afab8b0d1732d8..2bf7536526ee3c368b83d5cfb9b01c336f81cb2f 100644 GIT binary patch literal 1804 zcmaJ?U3U{z6y0~yWXNRtmA1h)VzD6PgEk2GMM^am&|(_U7Es?N=`{>aXSya67k%@= zU*H?RfEOQhEh($GmWyY9hW-z6-}z{o;38SMbMLw5?z7K6=T83m_xYay-o@7jX7EuK z)3~amZXgvcR+af$4r};0hfmN@!>2md4H%L6y1^sYblfm7ftzaanU2rZb3?~19bX8X zkh^=1w=a7FQ_Y9g4_2)o*iNl!_ky}WcFXR%R?zpQz|zR}YE!y_9qiX`L2mfJ+(C<3Hq}C zh=nMXH>d>}CkF&(kFidyR6}#y0)pPzj<>sK`EuJ+x+TuBunJCaW2kz!+YcGBuJ*1b z{?uN9%f4SfR_FB)TIG0@cMPoB#@O=uen;N4Rk?G~#)|4j6Gb#l%ws`dX3(Au-?#Qv zkD8c6!NfZ_qhr%V3%7OLG4Un7GO>kifr;TlnYatKT7FuX~QeTG^gkR}iM%8?+1F<||{*#w~S5?GR z7_opf=kpwkq<0F-v|eOP#o#o3mXO0aoac;jVlHWVl|miMv?`vFrNUXnv&tE}jiXBT zM?MwLmDFnG0OP|X7ZQ>aEpnWEjLc6$JbC#~@fV(mR9T=dVBQ*eETT+4RgTMyP&?we z$p3{Et`*Ofn5RaMi~NgGQnSrtHfzLD)iuavs>ZZwTefk{mHNzFMQ!??gK@&>j9wy|SiS6~nO0tYx$V7XoI z+8Z=Z?;dXN2d=;ojuj*$w{zuoFI@!_|6RR)*K_+l|6O~oqr_b;?ymB15ZD>06g3wh z*XX5T6Epr(tfDynFqXN=vSPCbtW6`wTQd1V;h906wG6#RpaH%52K|MG3WqpC8%ROM zh=A)+OgO$kk6)G{en&rXwLE9T!L*I@xS+!?W^qZ&%Qmi{Y~w1fS-5WDhJYbw1%|3Bh`sn-sj{vDSCzH< zj6m;IFYw~)0-1baMZla7Un(8!1?pi^UschvT=nV6RYO<$D>Cx5-Ex}oE3YBoRGXN~ zsu2^nr=j8}n*!sH6IQIN6|dnjrxFBVEMqSWm_oQ{y|j_Ac4#E)F~MSgjYGhy zs;Qa`8v6RCgFV>GP8QiOJ!9JFugh4meZTZ%USOCl9$H86PvvA+R15^d<4tF-H*_V77td}0G zZYVbv7|mBZ&ZRi=g7vaqW3JU)*UadAsa&7qjc%zmW+y6nD=;WG!i0TQlBGCwUkmKb z|8L-h7Xp24&ctd*H5rx*_XKuzxXgv2uVlcnZb?5;kJbeC8w4035(US^`r{Hqzu8%=B)uxC7&PF0&2uGm%oGH#MvdM#k`@dk9`5u<}0cPeaawdOYvAe_ZIQm#;jDI-e7-s!34r3qL9b@Y= vZ2Te)<0+1$+>1?4E$&$?;wa;|RzBt9)C^|d#0hE{ZlgKUeA-!or-9;cJB1YG literal 0 HcmV?d00001 diff --git a/ENSIM/Java/POOtpnote/target/test-classes/EmprunteurTest.class b/ENSIM/Java/POOtpnote/target/test-classes/EmprunteurTest.class index 890fcd8f8b8835a379b5f6bcd9a57aac49836a39..b5c00dde6240f8020c5bd23fdea4b6512e0ce549 100644 GIT binary patch delta 187 zcmX@evx8^CHz6UP{GxRItkS&95`CxCwEUvf$>NL(+yV&U&3=q`nA{i{47( z7#J*pG$WAa-p#-ixt)P|GXu*;AeV_j3P^GRX$A&iAT7cm4P@~^lrqRL$TBcYj$=vW zl>mxK0@X@0=rhPnKEqNks00*I0g9*rp$3B?gXZKI)+wU83>*x445ADMK%GVmS`5Yv LHVh_{S=np=8}A;% delta 196 zcmdnNbC74kH$_FC{GxRItkS&95+GTSS&~|$pIDHo@06OBUzF;YlQWrvQ9)b=yQ*?BT6A(KOCql% z0}oJKia~}!pFwu=VU~J9WuS;EP(+