BIG CHANGEMENT, correction de la configuration, nouveau test)
This commit is contained in:
@@ -21,32 +21,46 @@ public class ConfigurationImpl implements Configuration {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
for(Part pt: selectedParts){
|
boolean test = true;
|
||||||
|
for(Part pt1: selectedParts){
|
||||||
|
boolean test_Requirement = true;
|
||||||
|
boolean test_Incompabilities = true;
|
||||||
|
System.out.println("name : " + pt1.getType().getName());
|
||||||
//Verifier Requirements
|
//Verifier Requirements
|
||||||
for(PartType require : compatibilityManager.getRequirements(pt.getType())){
|
for(PartType require : compatibilityManager.getRequirements(pt1.getType())){
|
||||||
|
test_Requirement = false;
|
||||||
|
System.out.println("\tRequirement : " + require.getName());
|
||||||
//if(!selectedParts.contains(require)) return false;
|
//if(!selectedParts.contains(require)) return false;
|
||||||
//IN V2, instead of verify if it's in selectedParts,
|
//IN V2, instead of verify if it's in selectedParts,
|
||||||
//we will compare its type and selectedParts
|
//we will compare its type and selectedParts
|
||||||
//boolean no_error = true;
|
//boolean no_error = true;
|
||||||
|
for(Part pt2 : selectedParts){
|
||||||
for(Part selectPart : selectedParts){
|
System.out.println("\t\tname : " + pt2.getType().getName());
|
||||||
if (selectPart.getType().equals(require)){
|
if (pt2.getType().equals(require)){
|
||||||
return false;
|
test_Requirement = true;
|
||||||
//no_error= true;
|
//no_error= true;
|
||||||
//break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(test_Requirement) System.out.println("\tok");
|
||||||
|
else System.out.println("\tnot ok");
|
||||||
//Verifier Incompabilities
|
//Verifier Incompabilities
|
||||||
for(PartType incompa : compatibilityManager.getIncompatibilities(pt.getType())){
|
for(PartType incompa : compatibilityManager.getIncompatibilities(pt1.getType())){
|
||||||
|
System.out.println("\tIncompatibility : " + incompa.getName());
|
||||||
for (Part selectPart : selectedParts){
|
for (Part selectPart : selectedParts){
|
||||||
if(selectPart.getType().equals(incompa)){
|
if(selectPart.getType().equals(incompa)){
|
||||||
return false;
|
test_Incompabilities = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(test_Incompabilities) System.out.println("\tok");
|
||||||
|
else System.out.println("\tnot ok");
|
||||||
|
System.out.println(test_Requirement + " " + test_Incompabilities);
|
||||||
|
test = test && test_Requirement && test_Incompabilities;
|
||||||
}
|
}
|
||||||
return true;
|
return test;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPriceTotal(){
|
public int getPriceTotal(){
|
||||||
@@ -86,11 +100,13 @@ public class ConfigurationImpl implements Configuration {
|
|||||||
if(pt.getCategory().equals(category_chosenPart)){
|
if(pt.getCategory().equals(category_chosenPart)){
|
||||||
System.out.println("Il y a une pièce dans la même catégorie dans la configuration");
|
System.out.println("Il y a une pièce dans la même catégorie dans la configuration");
|
||||||
selectedParts.remove(pt);
|
selectedParts.remove(pt);
|
||||||
selectedParts.add(((PartTypeImpl)chosenPart).newInstance());
|
break;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
selectedParts.add( ((PartTypeImpl)chosenPart).newInstance() );
|
PartImpl newPart = ((PartTypeImpl)chosenPart).newInstance();
|
||||||
|
newPart.setType(chosenPart);
|
||||||
|
selectedParts.add(newPart);
|
||||||
|
//System.out.println(chosenPart.getName() + " : size = " + selectedParts.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -118,4 +134,15 @@ public class ConfigurationImpl implements Configuration {
|
|||||||
public void clear() {
|
public void clear() {
|
||||||
this.selectedParts.clear();;
|
this.selectedParts.clear();;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Part getPart(Category part){
|
||||||
|
Part engine = null;
|
||||||
|
for( Part pt: selectedParts){
|
||||||
|
if(pt.getCategory() == part){
|
||||||
|
engine = pt;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return engine;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,13 +18,12 @@ public class PartImpl implements Part {
|
|||||||
private PartType type;
|
private PartType type;
|
||||||
private int price;
|
private int price;
|
||||||
|
|
||||||
public PartImpl(PartType type, int price){
|
/*public PartImpl(PartType type){
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.price = price;
|
}*/
|
||||||
}
|
|
||||||
|
|
||||||
private class Property {
|
private class Property {
|
||||||
public final Supplier<String> getter;
|
public final Supplier<String> getter;
|
||||||
public final Consumer<String> setter;
|
public final Consumer<String> setter;
|
||||||
public final Set<String> possibleValues;
|
public final Set<String> possibleValues;
|
||||||
|
|
||||||
@@ -51,7 +50,10 @@ public class PartImpl implements Part {
|
|||||||
Objects.requireNonNull(propertyName);
|
Objects.requireNonNull(propertyName);
|
||||||
|
|
||||||
if (properties.containsKey(propertyName)) {
|
if (properties.containsKey(propertyName)) {
|
||||||
return Optional.of(properties.get(propertyName).getter.get());
|
String value = properties.get(propertyName).getter.get();
|
||||||
|
if(value != null){
|
||||||
|
return Optional.of(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
@@ -79,10 +81,16 @@ public class PartImpl implements Part {
|
|||||||
public Category getCategory(){
|
public Category getCategory(){
|
||||||
return this.type.getCategory();
|
return this.type.getCategory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PartType getType(){
|
public PartType getType(){
|
||||||
return this.type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setType(PartType type){
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
public int getPrice(){
|
public int getPrice(){
|
||||||
return this.price;
|
return this.price;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ import src.fr.impl.PartImpl;
|
|||||||
import src.fr.impl.PartTypeImpl;
|
import src.fr.impl.PartTypeImpl;
|
||||||
|
|
||||||
public class Engine extends PartImpl {
|
public class Engine extends PartImpl {
|
||||||
public Engine(String name, CategoryImpl category, int price){
|
/*public Engine(String name, CategoryImpl category, int price){
|
||||||
super(new PartTypeImpl(name,Engine.class, category),price);
|
super(new PartTypeImpl(name,Engine.class, category),price);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public Engine(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,12 +21,16 @@ public class Exterior extends PartImpl {
|
|||||||
|
|
||||||
private String color;
|
private String color;
|
||||||
|
|
||||||
public Exterior(String name, CategoryImpl category, int price){
|
/*public Exterior(String name, CategoryImpl category, int price){
|
||||||
super(new PartTypeImpl(name,Engine.class, category),price);
|
super(new PartTypeImpl(name,Engine.class, category),price);
|
||||||
|
|
||||||
Set<String> l = new HashSet<String>();
|
Set<String> l = new HashSet<String>();
|
||||||
l.add("red");
|
l.add("red");
|
||||||
this.addProperty("color", () -> getColor(), c -> setColor(c), colorSet);
|
this.addProperty("color", () -> getColor(), c -> setColor(c), colorSet);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public Exterior(){
|
||||||
|
this.addProperty("color", () -> getColor(), c -> setColor(c), colorSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,12 @@ public class Interior extends PartImpl {
|
|||||||
String color;
|
String color;
|
||||||
String material;
|
String material;
|
||||||
|
|
||||||
public Interior(String name, CategoryImpl category, int price){
|
/*public Interior(String name, CategoryImpl category, int price){
|
||||||
super(new PartTypeImpl(name,Engine.class, category), price);
|
super(new PartTypeImpl(name,Engine.class, category), price);
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public Interior(){
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getColor(){
|
public String getColor(){
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ import src.fr.impl.PartImpl;
|
|||||||
import src.fr.impl.PartTypeImpl;
|
import src.fr.impl.PartTypeImpl;
|
||||||
|
|
||||||
public class Transmission extends PartImpl {
|
public class Transmission extends PartImpl {
|
||||||
public Transmission(String name, CategoryImpl category, int price){
|
/*public Transmission(String name, CategoryImpl category, int price){
|
||||||
super(new PartTypeImpl(name,Engine.class, category),price);
|
super(new PartTypeImpl(name,Engine.class, category),price);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public Transmission(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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