BIG CHANGEMENT, correction de la configuration, nouveau test)
This commit is contained in:
@@ -1,243 +0,0 @@
|
||||
package src.fr.test;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import src.fr.impl.*;
|
||||
import src.fr.impl.Parts.*;
|
||||
import src.fr.api.*;
|
||||
|
||||
|
||||
public class test {
|
||||
CategoryImpl engine = new CategoryImpl("Engine");
|
||||
CategoryImpl transmission = new CategoryImpl("Transmission");
|
||||
CategoryImpl exterior = new CategoryImpl("Exterior");
|
||||
CategoryImpl interior = new CategoryImpl("Interior");
|
||||
|
||||
|
||||
|
||||
|
||||
PartType EG100PartType = new PartTypeImpl("EG100",Engine.class,engine);
|
||||
|
||||
Engine EG100 = new Engine("EG100",engine,19000);
|
||||
Engine EG133 = new Engine("EG133",engine,2200);
|
||||
Engine EG210= new Engine("EG210", engine,25000);
|
||||
Engine ED110= new Engine("ED110", engine,18000);
|
||||
Engine ED180= new Engine("ED180", engine,20000);
|
||||
Engine EH120= new Engine("EH120", engine,25000);
|
||||
|
||||
Transmission TM5= new Transmission("TM5", transmission,2000);
|
||||
Transmission TM6= new Transmission("TM6", transmission,4000);
|
||||
Transmission TA5= new Transmission("TA5", transmission,7000);
|
||||
Transmission TS6= new Transmission("TS6", transmission,10000);
|
||||
Transmission TSF7= new Transmission("TSF7", transmission,15000);
|
||||
Transmission TC120= new Transmission("TC120", transmission,5000);
|
||||
|
||||
Exterior XC= new Exterior("XC", exterior,0);
|
||||
Exterior XM= new Exterior("XM", exterior,1000);
|
||||
Exterior XS= new Exterior("XS", exterior,10000);
|
||||
|
||||
Interior IN= new Interior("IN", interior,0);
|
||||
Interior IH= new Interior("IH", interior,800);
|
||||
Interior IS= new Interior("IS", interior,2500);
|
||||
|
||||
|
||||
|
||||
|
||||
CompatibilityManager cm = new CompatibilityManagerImpl();
|
||||
@Before
|
||||
public void init(){
|
||||
Set<PartType> EH120Requirement = new HashSet<PartType>();
|
||||
EH120Requirement.add(TC120.getType());
|
||||
|
||||
Set<PartType> TA5Incompatibilities = new HashSet<PartType>();
|
||||
TA5Incompatibilities.add(EG100.getType());
|
||||
|
||||
Set<PartType> TSF7Incompatibilities = new HashSet<PartType>();
|
||||
TSF7Incompatibilities.add(EG100.getType());
|
||||
TSF7Incompatibilities.add(EG133.getType());
|
||||
TSF7Incompatibilities.add(ED110.getType());
|
||||
|
||||
Set<PartType> TC120Requirement = new HashSet<PartType>();
|
||||
TC120Requirement.add(EH120.getType());
|
||||
|
||||
Set<PartType> XCIncompatibilities = new HashSet<PartType>();
|
||||
XCIncompatibilities.add(EG210.getType());
|
||||
|
||||
Set<PartType> XMIncompatibilities = new HashSet<PartType>();
|
||||
XMIncompatibilities.add(EG100.getType());
|
||||
|
||||
Set<PartType> XSIncompatibilities = new HashSet<PartType>();
|
||||
XSIncompatibilities.add(EG100.getType());
|
||||
Set<PartType> XSRequirement = new HashSet<PartType>();
|
||||
XSRequirement.add(IS.getType());
|
||||
|
||||
Set<PartType> ISIncompatibilities = new HashSet<PartType>();
|
||||
ISIncompatibilities.add(EG100.getType());
|
||||
ISIncompatibilities.add(TM5.getType());
|
||||
Set<PartType> ISRequirement = new HashSet<PartType>();
|
||||
ISRequirement.add(XS.getType());
|
||||
|
||||
cm.addRequirements(EH120.getType(), EH120Requirement);
|
||||
cm.addIncompatibilities(TA5.getType(), TA5Incompatibilities);
|
||||
cm.addIncompatibilities(TSF7.getType(), TSF7Incompatibilities);
|
||||
cm.addRequirements(TC120.getType(), TC120Requirement);
|
||||
cm.addIncompatibilities(XC.getType(), XCIncompatibilities);
|
||||
cm.addIncompatibilities(XM.getType(), XMIncompatibilities);
|
||||
cm.addIncompatibilities(XS.getType(), XSIncompatibilities);
|
||||
cm.addRequirements(XS.getType(), XSRequirement);
|
||||
cm.addIncompatibilities(IS.getType(), ISIncompatibilities);
|
||||
cm.addRequirements(IS.getType(), ISRequirement);
|
||||
|
||||
|
||||
|
||||
//EG100.setProperty("prix","5€");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test_Incompatibilities_Simple_1(){
|
||||
assertTrue(cm.getIncompatibilities(TA5.getType()).contains(EG100.getType()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void test_multiple_Incompatibilities_Simple_2(){
|
||||
assertTrue(
|
||||
cm.getIncompatibilities(TSF7.getType()).contains(EG100.getType())&&
|
||||
cm.getIncompatibilities(TSF7.getType()).contains(EG133.getType())&&
|
||||
cm.getIncompatibilities(TSF7.getType()).contains(ED110.getType())
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_Requirements_3(){
|
||||
assertTrue(cm.getRequirements(EH120.getType()).contains(TC120.getType()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* A <-> B
|
||||
* if A -> B then B -> A
|
||||
*/
|
||||
@Test
|
||||
public void test_Incompatibilities_Complex_4(){
|
||||
System.out.println("size EG100 incompatibilities : "+cm.getIncompatibilities(EG100.getType()).size());
|
||||
assertTrue(cm.getIncompatibilities(EG100.getType()).contains(IS.getType()));
|
||||
assertTrue(cm.getIncompatibilities(EG100.getType()).contains(XS.getType()));
|
||||
}
|
||||
|
||||
/*
|
||||
* if A require B
|
||||
* then A is incompatible with all incompatible of B
|
||||
*/
|
||||
@Test
|
||||
public void test_Require_Incompatibilities_Complex_5(){
|
||||
assertTrue(cm.getIncompatibilities(XS.getType()).contains(EG100.getType()));
|
||||
System.out.println("size XS incompatibilities : " + cm.getIncompatibilities(XS.getType()).size());
|
||||
assertTrue(cm.getIncompatibilities(XS.getType()).contains(TM5.getType()));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Require Require Require
|
||||
* if A -> B && B -> C then A -> C
|
||||
*/
|
||||
@Test
|
||||
public void test_Incompatibilities_Complex_7(){
|
||||
cm.addRequirements(TC120.getType(), Set.of(XC.getType()));
|
||||
assertTrue(cm.getRequirements(TC120.getType()).contains(XC.getType()));
|
||||
assertTrue(cm.getRequirements(EH120.getType()).contains(XC.getType()));
|
||||
cm.removeRequirement(TC120.getType(), XC.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_Empty_Requirements_5(){
|
||||
assertTrue(cm.getRequirements(ED180.getType()).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_Remove_and_restore_Incompatibilities_6(){
|
||||
assertTrue(cm.getIncompatibilities(XM.getType()).contains(EG100.getType()));
|
||||
cm.removeIncompatibility(XM.getType(), EG100.getType());
|
||||
assertFalse(cm.getIncompatibilities(XM.getType()).contains(EG100.getType()));
|
||||
Set<PartType> setEG100 = new HashSet<PartType>();
|
||||
setEG100.add(EG100.getType());
|
||||
cm.addIncompatibilities(XM.getType(), setEG100);
|
||||
assertTrue(cm.getIncompatibilities(XM.getType()).contains(EG100.getType()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_Remove_Empty_7(){
|
||||
assertTrue(cm.getIncompatibilities(EH120.getType()).isEmpty());
|
||||
cm.removeIncompatibility(EH120.getType(), EG100.getType());
|
||||
assertTrue(cm.getIncompatibilities(EH120.getType()).isEmpty()); }
|
||||
|
||||
@Test
|
||||
public void test_Remove_and_restore_Requirements_8(){
|
||||
assertTrue(cm.getRequirements(EH120.getType()).contains(TC120.getType()));
|
||||
cm.removeRequirement(EH120.getType(), TC120.getType());
|
||||
assertFalse(cm.getRequirements(EH120.getType()).contains(TC120.getType()));
|
||||
Set<PartType> setTC120 = new HashSet<PartType>();
|
||||
setTC120.add(TC120.getType());
|
||||
cm.addRequirements(EH120.getType(), setTC120);
|
||||
assertTrue(cm.getRequirements(EH120.getType()).contains(TC120.getType()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_remove_incompatibilities_but_no_removable(){
|
||||
assertTrue(cm.getIncompatibilities(EG100.getType()).contains(IS.getType()));
|
||||
cm.removeIncompatibility(EG100.getType(), IS.getType());
|
||||
assertTrue(cm.getIncompatibilities(EG100.getType()).contains(IS.getType()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_Add_and_restore_Incompatibilities_9(){
|
||||
assertTrue(cm.getIncompatibilities(TSF7.getType()).contains(EG100.getType()));
|
||||
assertTrue(cm.getIncompatibilities(TSF7.getType()).contains(EG133.getType()));
|
||||
assertTrue(cm.getIncompatibilities(TSF7.getType()).contains(ED110.getType()));
|
||||
cm.removeIncompatibility(TSF7.getType(), EG100.getType());
|
||||
assertFalse(cm.getIncompatibilities(TSF7.getType()).contains(EG100.getType()));
|
||||
assertTrue(cm.getIncompatibilities(TSF7.getType()).contains(EG133.getType()));
|
||||
assertTrue(cm.getIncompatibilities(TSF7.getType()).contains(ED110.getType()));
|
||||
Set<PartType> setEG100 = new HashSet<PartType>();
|
||||
setEG100.add(EG100.getType());
|
||||
cm.addIncompatibilities(TSF7.getType(), setEG100);
|
||||
assertTrue(cm.getIncompatibilities(TSF7.getType()).contains(EG100.getType()));
|
||||
assertTrue(cm.getIncompatibilities(TSF7.getType()).contains(EG133.getType()));
|
||||
assertTrue(cm.getIncompatibilities(TSF7.getType()).contains(ED110.getType()));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test_PropertyInteriorColor(){
|
||||
XS.setProperty("color","red");
|
||||
assertTrue(XS.getProperty("color").get()=="red");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test_prixTotal1(){
|
||||
ConfigurationImpl config1 = new ConfigurationImpl(cm);
|
||||
//config1.selectPart(EG210.getType());
|
||||
//config1.selectPart(TSF7.getType());
|
||||
//config1.selectPart(XS.getType());
|
||||
//config1.selectPart(IS.getType());
|
||||
|
||||
assertTrue(true);
|
||||
|
||||
//assertTrue(config1.isComplete());
|
||||
//assertTrue(config1.isValid());
|
||||
}
|
||||
|
||||
}
|
||||
286
src/fr/test/testV2_PT.java
Normal file
286
src/fr/test/testV2_PT.java
Normal file
@@ -0,0 +1,286 @@
|
||||
package src.fr.test;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import src.fr.impl.*;
|
||||
import src.fr.impl.Parts.*;
|
||||
import src.fr.api.*;
|
||||
|
||||
|
||||
public class testV2_PT {
|
||||
// CategoryImpl engine = new CategoryImpl("Engine");
|
||||
// CategoryImpl transmission = new CategoryImpl("Transmission");
|
||||
// CategoryImpl exterior = new CategoryImpl("Exterior");
|
||||
// CategoryImpl interior = new CategoryImpl("Interior");
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// PartType EG100PartType = new PartTypeImpl("EG100",Engine.class,engine);
|
||||
//
|
||||
//
|
||||
// Engine EG100 = new Engine();
|
||||
// Engine EG133 = new Engine();
|
||||
// Engine EG210= new Engine();
|
||||
// Engine ED110= new Engine();
|
||||
// Engine ED180= new Engine();
|
||||
// Engine EH120= new Engine();
|
||||
//
|
||||
// Transmission TM5= new Transmission("TM5", transmission,2000);
|
||||
// Transmission TM6= new Transmission("TM6", transmission,4000);
|
||||
// Transmission TA5= new Transmission("TA5", transmission,7000);
|
||||
// Transmission TS6= new Transmission("TS6", transmission,10000);
|
||||
// Transmission TSF7= new Transmission("TSF7", transmission,15000);
|
||||
// Transmission TC120= new Transmission("TC120", transmission,5000);
|
||||
//
|
||||
// Exterior XC= new Exterior("XC", exterior,0);
|
||||
// Exterior XM= new Exterior("XM", exterior,1000);
|
||||
// Exterior XS= new Exterior("XS", exterior,10000);
|
||||
//
|
||||
// Interior IN= new Interior("IN", interior,0);
|
||||
// Interior IH= new Interior("IH", interior,800);
|
||||
// Interior IS= new Interior("IS", interior,2500);
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// CompatibilityManager cm = new CompatibilityManagerImpl();
|
||||
// @Before
|
||||
// public void init(){
|
||||
// Set<PartType> EH120Requirement = new HashSet<PartType>();
|
||||
// EH120Requirement.add(TC120.getType());
|
||||
//
|
||||
// Set<PartType> TA5Incompatibilities = new HashSet<PartType>();
|
||||
// TA5Incompatibilities.add(EG100.getType());
|
||||
//
|
||||
// Set<PartType> TSF7Incompatibilities = new HashSet<PartType>();
|
||||
// TSF7Incompatibilities.add(EG100.getType());
|
||||
// TSF7Incompatibilities.add(EG133.getType());
|
||||
// TSF7Incompatibilities.add(ED110.getType());
|
||||
//
|
||||
// Set<PartType> TC120Requirement = new HashSet<PartType>();
|
||||
// TC120Requirement.add(EH120.getType());
|
||||
//
|
||||
// Set<PartType> XCIncompatibilities = new HashSet<PartType>();
|
||||
// XCIncompatibilities.add(EG210.getType());
|
||||
//
|
||||
// Set<PartType> XMIncompatibilities = new HashSet<PartType>();
|
||||
// XMIncompatibilities.add(EG100.getType());
|
||||
//
|
||||
// Set<PartType> XSIncompatibilities = new HashSet<PartType>();
|
||||
// XSIncompatibilities.add(EG100.getType());
|
||||
// Set<PartType> XSRequirement = new HashSet<PartType>();
|
||||
// XSRequirement.add(IS.getType());
|
||||
//
|
||||
// Set<PartType> ISIncompatibilities = new HashSet<PartType>();
|
||||
// ISIncompatibilities.add(EG100.getType());
|
||||
// ISIncompatibilities.add(TM5.getType());
|
||||
// Set<PartType> ISRequirement = new HashSet<PartType>();
|
||||
// ISRequirement.add(XS.getType());
|
||||
//
|
||||
// cm.addRequirements(EH120.getType(), EH120Requirement);
|
||||
// cm.addIncompatibilities(TA5.getType(), TA5Incompatibilities);
|
||||
// cm.addIncompatibilities(TSF7.getType(), TSF7Incompatibilities);
|
||||
// cm.addRequirements(TC120.getType(), TC120Requirement);
|
||||
// cm.addIncompatibilities(XC.getType(), XCIncompatibilities);
|
||||
// cm.addIncompatibilities(XM.getType(), XMIncompatibilities);
|
||||
// cm.addIncompatibilities(XS.getType(), XSIncompatibilities);
|
||||
// cm.addRequirements(XS.getType(), XSRequirement);
|
||||
// cm.addIncompatibilities(IS.getType(), ISIncompatibilities);
|
||||
// cm.addRequirements(IS.getType(), ISRequirement);
|
||||
//
|
||||
//
|
||||
//
|
||||
// //EG100.setProperty("prix","5€");
|
||||
//
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// public void test_Incompatibilities_Simple_1(){
|
||||
// assertTrue(cm.getIncompatibilities(TA5.getType()).contains(EG100.getType()));
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// public void test_multiple_Incompatibilities_Simple_2(){
|
||||
// assertTrue(
|
||||
// cm.getIncompatibilities(TSF7.getType()).contains(EG100.getType())&&
|
||||
// cm.getIncompatibilities(TSF7.getType()).contains(EG133.getType())&&
|
||||
// cm.getIncompatibilities(TSF7.getType()).contains(ED110.getType())
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void test_Requirements_3(){
|
||||
// assertTrue(cm.getRequirements(EH120.getType()).contains(TC120.getType()));
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// /*
|
||||
// * A <-> B
|
||||
// * if A -> B then B -> A
|
||||
// */
|
||||
// @Test
|
||||
// public void test_Incompatibilities_Complex_4(){
|
||||
// System.out.println("size EG100 incompatibilities : "+cm.getIncompatibilities(EG100.getType()).size());
|
||||
// assertTrue(cm.getIncompatibilities(EG100.getType()).contains(IS.getType()));
|
||||
// assertTrue(cm.getIncompatibilities(EG100.getType()).contains(XS.getType()));
|
||||
// }
|
||||
//
|
||||
// /*
|
||||
// * if A require B
|
||||
// * then A is incompatible with all incompatible of B
|
||||
// */
|
||||
// @Test
|
||||
// public void test_Require_Incompatibilities_Complex_5(){
|
||||
// assertTrue(cm.getIncompatibilities(XS.getType()).contains(EG100.getType()));
|
||||
// System.out.println("size XS incompatibilities : " + cm.getIncompatibilities(XS.getType()).size());
|
||||
// assertTrue(cm.getIncompatibilities(XS.getType()).contains(TM5.getType()));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /*
|
||||
// * Require Require Require
|
||||
// * if A -> B && B -> C then A -> C
|
||||
// */
|
||||
// @Test
|
||||
// public void test_Incompatibilities_Complex_7(){
|
||||
// cm.addRequirements(TC120.getType(), Set.of(XC.getType()));
|
||||
// assertTrue(cm.getRequirements(TC120.getType()).contains(XC.getType()));
|
||||
// assertTrue(cm.getRequirements(EH120.getType()).contains(XC.getType()));
|
||||
// cm.removeRequirement(TC120.getType(), XC.getType());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void test_Empty_Requirements_5(){
|
||||
// assertTrue(cm.getRequirements(ED180.getType()).isEmpty());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void test_Remove_and_restore_Incompatibilities_6(){
|
||||
// assertTrue(cm.getIncompatibilities(XM.getType()).contains(EG100.getType()));
|
||||
// cm.removeIncompatibility(XM.getType(), EG100.getType());
|
||||
// assertFalse(cm.getIncompatibilities(XM.getType()).contains(EG100.getType()));
|
||||
// Set<PartType> setEG100 = new HashSet<PartType>();
|
||||
// setEG100.add(EG100.getType());
|
||||
// cm.addIncompatibilities(XM.getType(), setEG100);
|
||||
// assertTrue(cm.getIncompatibilities(XM.getType()).contains(EG100.getType()));
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void test_Remove_Empty_7(){
|
||||
// assertTrue(cm.getIncompatibilities(EH120.getType()).isEmpty());
|
||||
// cm.removeIncompatibility(EH120.getType(), EG100.getType());
|
||||
// assertTrue(cm.getIncompatibilities(EH120.getType()).isEmpty()); }
|
||||
//
|
||||
// @Test
|
||||
// public void test_Remove_and_restore_Requirements_8(){
|
||||
// assertTrue(cm.getRequirements(EH120.getType()).contains(TC120.getType()));
|
||||
// cm.removeRequirement(EH120.getType(), TC120.getType());
|
||||
// assertFalse(cm.getRequirements(EH120.getType()).contains(TC120.getType()));
|
||||
// Set<PartType> setTC120 = new HashSet<PartType>();
|
||||
// setTC120.add(TC120.getType());
|
||||
// cm.addRequirements(EH120.getType(), setTC120);
|
||||
// assertTrue(cm.getRequirements(EH120.getType()).contains(TC120.getType()));
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void test_remove_incompatibilities_but_no_removable(){
|
||||
// assertTrue(cm.getIncompatibilities(EG100.getType()).contains(IS.getType()));
|
||||
// cm.removeIncompatibility(EG100.getType(), IS.getType());
|
||||
// assertTrue(cm.getIncompatibilities(EG100.getType()).contains(IS.getType()));
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void test_Add_and_restore_Incompatibilities_9(){
|
||||
// assertTrue(cm.getIncompatibilities(TSF7.getType()).contains(EG100.getType()));
|
||||
// assertTrue(cm.getIncompatibilities(TSF7.getType()).contains(EG133.getType()));
|
||||
// assertTrue(cm.getIncompatibilities(TSF7.getType()).contains(ED110.getType()));
|
||||
// cm.removeIncompatibility(TSF7.getType(), EG100.getType());
|
||||
// assertFalse(cm.getIncompatibilities(TSF7.getType()).contains(EG100.getType()));
|
||||
// assertTrue(cm.getIncompatibilities(TSF7.getType()).contains(EG133.getType()));
|
||||
// assertTrue(cm.getIncompatibilities(TSF7.getType()).contains(ED110.getType()));
|
||||
// Set<PartType> setEG100 = new HashSet<PartType>();
|
||||
// setEG100.add(EG100.getType());
|
||||
// cm.addIncompatibilities(TSF7.getType(), setEG100);
|
||||
// assertTrue(cm.getIncompatibilities(TSF7.getType()).contains(EG100.getType()));
|
||||
// assertTrue(cm.getIncompatibilities(TSF7.getType()).contains(EG133.getType()));
|
||||
// assertTrue(cm.getIncompatibilities(TSF7.getType()).contains(ED110.getType()));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// public void test_PropertyInteriorColor(){
|
||||
// XS.setProperty("color","red");
|
||||
// assertTrue(XS.getProperty("color").get()=="red");
|
||||
// assertFalse(XS.getProperty("color").get()!="red");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// public void test_isComplete(){
|
||||
// ConfigurationImpl config1 = new ConfigurationImpl(cm);
|
||||
// config1.selectPart(EG210.getType());
|
||||
// config1.selectPart(TSF7.getType());
|
||||
// config1.selectPart(XS.getType());
|
||||
// config1.selectPart(IS.getType());
|
||||
//
|
||||
// assertTrue(config1.isComplete());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void test_isValide(){
|
||||
// ConfigurationImpl config1 = new ConfigurationImpl(cm);
|
||||
// config1.selectPart(EG210.getType());
|
||||
// config1.selectPart(TM5.getType());
|
||||
// config1.selectPart(XS.getType());
|
||||
// config1.selectPart(IS.getType());
|
||||
//
|
||||
// assertTrue(config1.isComplete());
|
||||
// assertTrue(config1.isValid());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void test_isNotValide(){
|
||||
// ConfigurationImpl config1 = new ConfigurationImpl(cm);
|
||||
// config1.selectPart(EG210.getType());
|
||||
// config1.selectPart(TSF7.getType());
|
||||
// config1.selectPart(XS.getType());
|
||||
// config1.selectPart(IH.getType());
|
||||
//
|
||||
// assertFalse(config1.isValid());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void test_prixTotal1(){
|
||||
// ConfigurationImpl config1 = new ConfigurationImpl(cm);
|
||||
// config1.selectPart(EG210.getType());
|
||||
// config1.selectPart(TSF7.getType());
|
||||
// config1.selectPart(XS.getType());
|
||||
// config1.selectPart(IS.getType());
|
||||
//
|
||||
// System.out.println(config1.getPriceTotal());
|
||||
// assertTrue(config1.getPriceTotal()==52500);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// public void test_69(){
|
||||
// ConfigurationImpl config1 = new ConfigurationImpl(cm);
|
||||
// config1.selectPart(EG210.getType());
|
||||
//
|
||||
// assertFalse(false);
|
||||
//
|
||||
// }
|
||||
}
|
||||
218
src/fr/test/test_V2.java
Normal file
218
src/fr/test/test_V2.java
Normal file
@@ -0,0 +1,218 @@
|
||||
package src.fr.test;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import src.fr.impl.*;
|
||||
import src.fr.impl.Parts.*;
|
||||
import src.fr.api.*;
|
||||
|
||||
public class test_V2 {
|
||||
CategoryImpl engine = new CategoryImpl("Engine");
|
||||
CategoryImpl transmission = new CategoryImpl("Transmission");
|
||||
CategoryImpl exterior = new CategoryImpl("Exterior");
|
||||
CategoryImpl interior = new CategoryImpl("Interior");
|
||||
|
||||
//PartType
|
||||
PartType EG100= new PartTypeImpl("EG100",Engine.class, engine);
|
||||
PartType EG133= new PartTypeImpl("EG133",Engine.class, engine);
|
||||
PartType EG210= new PartTypeImpl("EG210",Engine.class, engine);
|
||||
PartType ED110= new PartTypeImpl("ED110",Engine.class, engine);
|
||||
PartType ED180= new PartTypeImpl("ED180",Engine.class, engine);
|
||||
PartType EH120= new PartTypeImpl("EH120",Engine.class, engine);
|
||||
|
||||
PartType TM5= new PartTypeImpl("TM5", Transmission.class ,transmission);
|
||||
PartType TM6= new PartTypeImpl("TM6", Transmission.class ,transmission);
|
||||
PartType TA5= new PartTypeImpl("TA5", Transmission.class ,transmission);
|
||||
PartType TS6= new PartTypeImpl("TS6", Transmission.class ,transmission);
|
||||
PartType TSF7= new PartTypeImpl("TSF7", Transmission.class ,transmission);
|
||||
PartType TC120= new PartTypeImpl("TC120", Transmission.class ,transmission);
|
||||
|
||||
PartType XC= new PartTypeImpl("XC", Exterior.class,exterior);
|
||||
PartType XM= new PartTypeImpl("XM", Exterior.class,exterior);
|
||||
PartType XS= new PartTypeImpl("XS", Exterior.class,exterior);
|
||||
|
||||
PartType IN= new PartTypeImpl("IN", Interior.class ,interior);
|
||||
PartType IH= new PartTypeImpl("IH", Interior.class ,interior);
|
||||
PartType IS= new PartTypeImpl("IS", Interior.class ,interior);
|
||||
|
||||
CompatibilityManager cm = new CompatibilityManagerImpl();
|
||||
|
||||
|
||||
@Before
|
||||
public void init(){
|
||||
Set<PartType> EH120Requirement = new HashSet<PartType>();
|
||||
EH120Requirement.add(TC120);
|
||||
|
||||
Set<PartType> TA5Incompatibilities = new HashSet<PartType>();
|
||||
TA5Incompatibilities.add(EG100);
|
||||
|
||||
Set<PartType> TSF7Incompatibilities = new HashSet<PartType>();
|
||||
TSF7Incompatibilities.add(EG100);
|
||||
TSF7Incompatibilities.add(EG133);
|
||||
TSF7Incompatibilities.add(ED110);
|
||||
|
||||
Set<PartType> TC120Requirement = new HashSet<PartType>();
|
||||
TC120Requirement.add(EH120);
|
||||
|
||||
Set<PartType> XCIncompatibilities = new HashSet<PartType>();
|
||||
XCIncompatibilities.add(EG210);
|
||||
|
||||
Set<PartType> XMIncompatibilities = new HashSet<PartType>();
|
||||
XMIncompatibilities.add(EG100);
|
||||
|
||||
Set<PartType> XSIncompatibilities = new HashSet<PartType>();
|
||||
XSIncompatibilities.add(EG100);
|
||||
Set<PartType> XSRequirement = new HashSet<PartType>();
|
||||
XSRequirement.add(IS);
|
||||
|
||||
Set<PartType> ISIncompatibilities = new HashSet<PartType>();
|
||||
ISIncompatibilities.add(EG100);
|
||||
ISIncompatibilities.add(TM5);
|
||||
Set<PartType> ISRequirement = new HashSet<PartType>();
|
||||
ISRequirement.add(XS);
|
||||
|
||||
cm.addRequirements(EH120, EH120Requirement);
|
||||
cm.addIncompatibilities(TA5, TA5Incompatibilities);
|
||||
cm.addIncompatibilities(TSF7, TSF7Incompatibilities);
|
||||
cm.addRequirements(TC120, TC120Requirement);
|
||||
cm.addIncompatibilities(XC, XCIncompatibilities);
|
||||
cm.addIncompatibilities(XM, XMIncompatibilities);
|
||||
cm.addIncompatibilities(XS, XSIncompatibilities);
|
||||
cm.addRequirements(XS, XSRequirement);
|
||||
cm.addIncompatibilities(IS, ISIncompatibilities);
|
||||
cm.addRequirements(IS, ISRequirement);
|
||||
|
||||
|
||||
|
||||
//EG100.setProperty("prix","5€");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test_isComplete(){
|
||||
ConfigurationImpl config1 = new ConfigurationImpl(cm);
|
||||
config1.selectPart(EG210);
|
||||
config1.selectPart(TM5);
|
||||
config1.selectPart(XS);
|
||||
config1.selectPart(IS);
|
||||
|
||||
assertTrue(config1.isComplete());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_isNotComplete(){
|
||||
ConfigurationImpl config1 = new ConfigurationImpl(cm);
|
||||
config1.selectPart(EG210);
|
||||
config1.selectPart(TM5);
|
||||
config1.selectPart(XS);
|
||||
|
||||
assertFalse(config1.isComplete());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_isNotComplete_empty_cm(){
|
||||
CompatibilityManager cm2 = new CompatibilityManagerImpl();
|
||||
ConfigurationImpl config1 = new ConfigurationImpl(cm2);
|
||||
config1.selectPart(EG210);
|
||||
config1.selectPart(TM5);
|
||||
config1.selectPart(XS);
|
||||
|
||||
assertFalse(config1.isComplete());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_isValide_empty_cm(){
|
||||
CompatibilityManager cm2 = new CompatibilityManagerImpl();
|
||||
ConfigurationImpl config1 = new ConfigurationImpl(cm2);
|
||||
config1.selectPart(EG210);
|
||||
config1.selectPart(TM5);
|
||||
config1.selectPart(XS);
|
||||
config1.selectPart(IS);
|
||||
|
||||
assertTrue(config1.isValid());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_isValide1(){
|
||||
ConfigurationImpl config1 = new ConfigurationImpl(cm);
|
||||
config1.selectPart(EG210);
|
||||
config1.selectPart(TSF7);
|
||||
config1.selectPart(XS);
|
||||
config1.selectPart(IS);
|
||||
|
||||
assertTrue(config1.isValid());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test_isValide2(){
|
||||
ConfigurationImpl config1 = new ConfigurationImpl(cm);
|
||||
config1.selectPart(EG210);
|
||||
config1.selectPart(TSF7);
|
||||
config1.selectPart(XS);
|
||||
config1.selectPart(IS);
|
||||
config1.selectPart(TS6);
|
||||
|
||||
assertTrue(config1.isValid());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_isNotValide1(){
|
||||
ConfigurationImpl config1 = new ConfigurationImpl(cm);
|
||||
config1.selectPart(EG100);
|
||||
config1.selectPart(TSF7);
|
||||
config1.selectPart(XS);
|
||||
config1.selectPart(IS);
|
||||
|
||||
assertFalse(config1.isValid());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_isNotValide2(){
|
||||
ConfigurationImpl config1 = new ConfigurationImpl(cm);
|
||||
config1.selectPart(EG210);
|
||||
config1.selectPart(TSF7);
|
||||
config1.selectPart(XS);
|
||||
config1.selectPart(XS);
|
||||
|
||||
assertFalse(config1.isValid());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test_Property(){
|
||||
ConfigurationImpl config1 = new ConfigurationImpl(cm);
|
||||
config1.selectPart(EG210);
|
||||
config1.selectPart(TSF7);
|
||||
config1.selectPart(XS);
|
||||
config1.selectPart(IS);
|
||||
|
||||
config1.getPart(exterior).setProperty("color","red");
|
||||
|
||||
assertTrue(config1.getPart(exterior).getProperty("color").get()=="red");
|
||||
assertTrue(config1.isValid());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_NotProperty(){
|
||||
ConfigurationImpl config1 = new ConfigurationImpl(cm);
|
||||
config1.selectPart(EG210);
|
||||
config1.selectPart(TSF7);
|
||||
config1.selectPart(XS);
|
||||
config1.selectPart(IS);
|
||||
|
||||
|
||||
assertTrue(config1.getPart(exterior).getProperty("color").isEmpty());
|
||||
assertTrue(config1.isValid());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user