|
|
|
|
@@ -1,274 +0,0 @@
|
|
|
|
|
package src.fr.test;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
}
|