[POO Note]

- Ajout de compareTo à Agence
- Ajout du test unitaire pour Agence
- Fix test unitaire EmprunteurTest
This commit is contained in:
Tanguy Herbron 2018-11-30 17:49:55 +01:00
parent 9210f0c93d
commit 1c9cd2f21a
10 changed files with 201 additions and 91 deletions

View File

@ -2,7 +2,15 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="619befff-b456-45da-9393-c820ac461b67" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/test/java/AgenceTest.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/entity/Administrateur.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/entity/Administrateur.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/entity/Agence.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/entity/Agence.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/entity/Emprunteur.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/entity/Emprunteur.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/test/java/EmprunteurTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/EmprunteurTest.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/entity/Administrateur.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/entity/Administrateur.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/entity/Agence.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/entity/Agence.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/test-classes/EmprunteurTest.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/test-classes/EmprunteurTest.class" afterDir="false" />
</list>
<ignored path="$PROJECT_DIR$/out/" />
<ignored path="$PROJECT_DIR$/target/" />
@ -22,24 +30,24 @@
</usages-collector>
<usages-collector id="statistics.file.extensions.edit">
<counts>
<entry key="java" value="6039" />
<entry key="java" value="6887" />
<entry key="xml" value="7" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.edit">
<counts>
<entry key="JAVA" value="6039" />
<entry key="JAVA" value="6887" />
<entry key="XML" value="7" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.open">
<counts>
<entry key="java" value="56" />
<entry key="java" value="58" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.open">
<counts>
<entry key="JAVA" value="56" />
<entry key="JAVA" value="58" />
</counts>
</usages-collector>
</session>
@ -49,8 +57,20 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/test/java/AdministrateurTest.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="192">
<caret line="79" column="114" selection-start-line="79" selection-start-column="114" selection-end-line="79" selection-end-column="114" />
<state relative-caret-position="2771">
<caret line="175" column="64" selection-start-line="175" selection-start-column="64" selection-end-line="175" selection-end-column="64" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/test/java/AgenceTest.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="364">
<caret line="33" column="54" selection-start-line="33" selection-start-column="54" selection-end-line="33" selection-end-column="54" />
<folding>
<element signature="imports" expanded="true" />
</folding>
@ -61,8 +81,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/entity/Emprunteur.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="340">
<caret line="20" column="29" selection-start-line="20" selection-start-column="29" selection-end-line="20" selection-end-column="29" />
<state relative-caret-position="425">
<caret line="28" column="5" selection-start-line="28" selection-start-column="5" selection-end-line="28" selection-end-column="5" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#162#163#0" expanded="true" />
@ -76,6 +96,20 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/test/java/EmprunteurTest.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="238">
<caret line="14" column="25" lean-forward="true" selection-start-line="14" selection-start-column="25" selection-end-line="14" selection-end-column="25" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#425#426#0" expanded="true" />
<element signature="e#462#463#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/material/UC.java">
<provider selected="true" editor-type-id="text-editor">
@ -106,11 +140,11 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/entity/Administrateur.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="418">
<caret line="122" column="47" selection-start-line="122" selection-start-column="47" selection-end-line="122" selection-end-column="47" />
<state relative-caret-position="265">
<caret line="118" column="5" selection-start-line="118" selection-start-column="5" selection-end-line="118" selection-end-column="5" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#2369#2370#0" expanded="true" />
@ -119,8 +153,8 @@
<element signature="e#2538#2539#0" expanded="true" />
<element signature="e#2610#2611#0" expanded="true" />
<element signature="e#2663#2664#0" expanded="true" />
<element signature="e#3314#3315#0" expanded="true" />
<element signature="e#3356#3357#0" expanded="true" />
<element signature="e#3380#3381#0" expanded="true" />
<element signature="e#3434#3435#0" expanded="true" />
</folding>
</state>
</provider>
@ -129,12 +163,14 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/entity/Agence.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="132">
<caret line="16" column="28" selection-start-line="16" selection-start-column="28" selection-end-line="16" selection-end-column="28" />
<state relative-caret-position="867">
<caret line="51" column="45" selection-start-line="51" selection-start-column="45" selection-end-line="51" selection-end-column="45" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#325#326#0" expanded="true" />
<element signature="e#356#357#0" expanded="true" />
<element signature="e#1011#1012#0" expanded="true" />
<element signature="e#1101#1102#0" expanded="true" />
</folding>
</state>
</provider>
@ -184,8 +220,6 @@
<option value="$PROJECT_DIR$/src/main/java/Emprunteur.java" />
<option value="$PROJECT_DIR$/src/main/java/Empruntable.java" />
<option value="$PROJECT_DIR$/src/main/java/materiel/UC.java" />
<option value="$PROJECT_DIR$/src/main/java/entity/Emprunteur.java" />
<option value="$PROJECT_DIR$/src/test/java/EmprunteurTest.java" />
<option value="$PROJECT_DIR$/src/main/java/material/Imprimante.java" />
<option value="$PROJECT_DIR$/src/main/java/material/Router.java" />
<option value="$PROJECT_DIR$/src/main/java/material/UniteCentrale.java" />
@ -197,11 +231,14 @@
<option value="$PROJECT_DIR$/src/main/java/material/TELPortable.java" />
<option value="$PROJECT_DIR$/src/main/java/material/VideoProjecteur.java" />
<option value="$PROJECT_DIR$/src/main/java/entity/Entreprise.java" />
<option value="$PROJECT_DIR$/src/main/java/entity/Agence.java" />
<option value="$PROJECT_DIR$/src/main/java/material/UC.java" />
<option value="$PROJECT_DIR$/src/main/java/entity/Empruntable.java" />
<option value="$PROJECT_DIR$/src/test/java/AdministrateurTest.java" />
<option value="$PROJECT_DIR$/src/main/java/entity/Administrateur.java" />
<option value="$PROJECT_DIR$/src/main/java/entity/Agence.java" />
<option value="$PROJECT_DIR$/src/main/java/entity/Emprunteur.java" />
<option value="$PROJECT_DIR$/src/test/java/EmprunteurTest.java" />
<option value="$PROJECT_DIR$/src/test/java/AgenceTest.java" />
</list>
</option>
</component>
@ -282,7 +319,7 @@
</panes>
</component>
<component name="PropertiesComponent">
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1543595835467" />
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1543596542656" />
</component>
<component name="RecentsManager">
<key name="CreateClassDialog.RecentsKey">
@ -301,7 +338,7 @@
</list>
</option>
</component>
<component name="RunManager" selected="JUnit.AdministrateurTest">
<component name="RunManager" selected="JUnit.AgenceTest">
<configuration name="AdministrateurTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="POOtpnote" />
<option name="PACKAGE_NAME" value="" />
@ -310,6 +347,14 @@
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="AgenceTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="POOtpnote" />
<option name="PACKAGE_NAME" value="" />
<option name="MAIN_CLASS_NAME" value="AgenceTest" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="EmprunteurTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="POOtpnote" />
<option name="PACKAGE_NAME" value="" />
@ -321,11 +366,13 @@
<list>
<item itemvalue="JUnit.EmprunteurTest" />
<item itemvalue="JUnit.AdministrateurTest" />
<item itemvalue="JUnit.AgenceTest" />
</list>
<recent_temporary>
<list>
<item itemvalue="JUnit.AdministrateurTest" />
<item itemvalue="JUnit.AgenceTest" />
<item itemvalue="JUnit.EmprunteurTest" />
<item itemvalue="JUnit.AdministrateurTest" />
</list>
</recent_temporary>
</component>
@ -343,15 +390,6 @@
<servers />
</component>
<component name="TestHistory">
<history-entry file="AdministrateurTest - 2018.11.30 at 17h 25m 10s.xml">
<configuration name="AdministrateurTest" configurationId="JUnit" />
</history-entry>
<history-entry file="AdministrateurTest - 2018.11.30 at 17h 25m 38s.xml">
<configuration name="AdministrateurTest" configurationId="JUnit" />
</history-entry>
<history-entry file="AdministrateurTest - 2018.11.30 at 17h 26m 37s.xml">
<configuration name="AdministrateurTest" configurationId="JUnit" />
</history-entry>
<history-entry file="AdministrateurTest - 2018.11.30 at 17h 27m 11s.xml">
<configuration name="AdministrateurTest" configurationId="JUnit" />
</history-entry>
@ -373,6 +411,15 @@
<history-entry file="AdministrateurTest - 2018.11.30 at 17h 31m 57s.xml">
<configuration name="AdministrateurTest" configurationId="JUnit" />
</history-entry>
<history-entry file="AdministrateurTest - 2018.11.30 at 17h 37m 18s.xml">
<configuration name="AdministrateurTest" configurationId="JUnit" />
</history-entry>
<history-entry file="EmprunteurTest - 2018.11.30 at 17h 44m 44s.xml">
<configuration name="EmprunteurTest" configurationId="JUnit" />
</history-entry>
<history-entry file="AgenceTest - 2018.11.30 at 17h 48m 40s.xml">
<configuration name="AgenceTest" configurationId="JUnit" />
</history-entry>
</component>
<component name="TodoView">
<todo-panel id="selected-file">
@ -392,7 +439,7 @@
<window_info id="Capture Tool" order="2" />
<window_info id="Favorites" order="3" side_tool="true" />
<window_info id="Image Layers" order="4" />
<window_info active="true" content_ui="combo" id="Project" order="5" visible="true" weight="0.24948454" />
<window_info content_ui="combo" id="Project" order="5" visible="true" weight="0.24948454" />
<window_info id="Structure" order="6" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Terminal" order="0" />
<window_info anchor="bottom" id="Event Log" order="1" side_tool="true" />
@ -400,7 +447,7 @@
<window_info anchor="bottom" id="Version Control" order="3" />
<window_info anchor="bottom" id="Message" order="4" />
<window_info anchor="bottom" id="Find" order="5" />
<window_info anchor="bottom" id="Run" order="6" visible="true" weight="0.32897863" />
<window_info active="true" anchor="bottom" id="Run" order="6" visible="true" weight="0.32897863" />
<window_info anchor="bottom" id="Debug" order="7" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="8" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="9" weight="0.4" />
@ -433,18 +480,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/test/java/EmprunteurTest.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="187">
<caret line="11" column="20" selection-start-line="11" selection-start-column="20" selection-end-line="11" selection-end-column="20" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#326#327#0" expanded="true" />
<element signature="e#363#364#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/material/UniteCentrale.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
@ -545,18 +580,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/entity/Agence.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="132">
<caret line="16" column="28" selection-start-line="16" selection-start-column="28" selection-end-line="16" selection-end-column="28" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#325#326#0" expanded="true" />
<element signature="e#356#357#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/material/UC.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
@ -583,10 +606,64 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/entity/Administrateur.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="265">
<caret line="118" column="5" selection-start-line="118" selection-start-column="5" selection-end-line="118" selection-end-column="5" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#2369#2370#0" expanded="true" />
<element signature="e#2426#2427#0" expanded="true" />
<element signature="e#2485#2486#0" expanded="true" />
<element signature="e#2538#2539#0" expanded="true" />
<element signature="e#2610#2611#0" expanded="true" />
<element signature="e#2663#2664#0" expanded="true" />
<element signature="e#3380#3381#0" expanded="true" />
<element signature="e#3434#3435#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/entity/Agence.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="867">
<caret line="51" column="45" selection-start-line="51" selection-start-column="45" selection-end-line="51" selection-end-column="45" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#325#326#0" expanded="true" />
<element signature="e#356#357#0" expanded="true" />
<element signature="e#1011#1012#0" expanded="true" />
<element signature="e#1101#1102#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/test/java/EmprunteurTest.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="238">
<caret line="14" column="25" lean-forward="true" selection-start-line="14" selection-start-column="25" selection-end-line="14" selection-end-column="25" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#425#426#0" expanded="true" />
<element signature="e#462#463#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/test/java/AdministrateurTest.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2771">
<caret line="175" column="64" selection-start-line="175" selection-start-column="64" selection-end-line="175" selection-end-column="64" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/entity/Emprunteur.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="340">
<caret line="20" column="29" selection-start-line="20" selection-start-column="29" selection-end-line="20" selection-end-column="29" />
<state relative-caret-position="425">
<caret line="28" column="5" selection-start-line="28" selection-start-column="5" selection-end-line="28" selection-end-column="5" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#162#163#0" expanded="true" />
@ -599,34 +676,16 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/test/java/AdministrateurTest.java">
<entry file="file://$PROJECT_DIR$/src/test/java/AgenceTest.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="192">
<caret line="79" column="114" selection-start-line="79" selection-start-column="114" selection-end-line="79" selection-end-column="114" />
<state relative-caret-position="364">
<caret line="33" column="54" selection-start-line="33" selection-start-column="54" selection-end-line="33" selection-end-column="54" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/entity/Administrateur.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="418">
<caret line="122" column="47" selection-start-line="122" selection-start-column="47" selection-end-line="122" selection-end-column="47" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#2369#2370#0" expanded="true" />
<element signature="e#2426#2427#0" expanded="true" />
<element signature="e#2485#2486#0" expanded="true" />
<element signature="e#2538#2539#0" expanded="true" />
<element signature="e#2610#2611#0" expanded="true" />
<element signature="e#2663#2664#0" expanded="true" />
<element signature="e#3314#3315#0" expanded="true" />
<element signature="e#3356#3357#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>

View File

@ -118,11 +118,6 @@ public class Administrateur extends Employe {
}
}
/*public Agence getAgencePlusMaterielDefectueux()
{
}*/
public void achatDeMateriel(Empruntable empruntable)
{
entreprise.ajouterAuStock(empruntable);

View File

@ -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<Agence> {
private List<Employe> 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());
}
}

View File

@ -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);
}
}

View File

@ -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();
}