correction bug + ajout de test
This commit is contained in:
@@ -13,26 +13,14 @@ th,td{border: 1px solid rgb(160 160 160);padding: 8px 10px;}</style>
|
|||||||
<th>EG210</th>
|
<th>EG210</th>
|
||||||
<th>25000 €</th>
|
<th>25000 €</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<th>Interior</th>
|
|
||||||
<th>IS</th>
|
|
||||||
<th>2500 €</th>
|
|
||||||
<th>color : red</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>Transmission</th>
|
<th>Transmission</th>
|
||||||
<th>TSF7</th>
|
<th>TSF7</th>
|
||||||
<th>15000 €</th>
|
<th>15000 €</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<th>Exterior</th>
|
|
||||||
<th>XS</th>
|
|
||||||
<th>10000 €</th>
|
|
||||||
<th>color : red</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2">Total Price : </th>
|
<th colspan="2">Total Price : </th>
|
||||||
<th>52500 € </th>
|
<th>40000 € </th>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class ConfigurationImpl implements Configuration {
|
|||||||
for(String pr: pt1.getPropertyNames()){
|
for(String pr: pt1.getPropertyNames()){
|
||||||
Optional<String> prOptional = pt1.getProperty(pr);
|
Optional<String> prOptional = pt1.getProperty(pr);
|
||||||
if(!prOptional.isEmpty()){
|
if(!prOptional.isEmpty()){
|
||||||
test = ((PartImpl)pt1).isValidProperty(pr);
|
test = test && ((PartImpl)pt1).isValidProperty(pr);
|
||||||
}
|
}
|
||||||
else test = false;
|
else test = false;
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,9 @@ public class ConfigurationImpl implements Configuration {
|
|||||||
else System.out.println("\tnot ok");
|
else System.out.println("\tnot ok");
|
||||||
System.out.println(test_Requirement + " " + test_Incompabilities);
|
System.out.println(test_Requirement + " " + test_Incompabilities);
|
||||||
test = test && test_Requirement && test_Incompabilities;
|
test = test && test_Requirement && test_Incompabilities;
|
||||||
|
System.out.println("post final : " + test);
|
||||||
}
|
}
|
||||||
|
System.out.println("final : " + test);
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,10 @@ public class Engine extends PartImpl {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setType(PartType type){
|
public void setType(PartType type){
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.price = prices.get(type.getName());
|
if(prices.containsKey(type.getName())){
|
||||||
|
this.price = prices.get(type.getName());
|
||||||
|
}
|
||||||
|
else this.price = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,10 @@ public class Exterior extends PartImpl {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setType(PartType type){
|
public void setType(PartType type){
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.price = prices.get(type.getName());
|
if(prices.containsKey(type.getName())){
|
||||||
|
this.price = prices.get(type.getName());
|
||||||
|
}
|
||||||
|
else this.price = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,8 +47,11 @@ public class Interior extends PartImpl {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setType(PartType type){
|
public void setType(PartType type){
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.price = prices.get(type.getName());
|
if(prices.containsKey(type.getName())){
|
||||||
|
this.price = prices.get(type.getName());
|
||||||
|
}
|
||||||
|
else this.price = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,10 @@ public class Transmission extends PartImpl {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setType(PartType type){
|
public void setType(PartType type){
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.price = prices.get(type.getName());
|
if(prices.containsKey(type.getName())){
|
||||||
|
this.price = prices.get(type.getName());
|
||||||
|
}
|
||||||
|
else this.price = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,6 +206,28 @@ public class test_V1 {
|
|||||||
assertTrue(cm.getIncompatibilities(TSF7).contains(ED110));
|
assertTrue(cm.getIncompatibilities(TSF7).contains(ED110));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_contradiction(){
|
||||||
|
CompatibilityManager cm2 = new CompatibilityManagerImpl();
|
||||||
|
PartType eg= new PartTypeImpl("eg",Engine.class, engine);
|
||||||
|
PartType tr= new PartTypeImpl("Tr", Transmission.class, transmission);
|
||||||
|
|
||||||
|
Set<PartType> egIncompatibilities = new HashSet<PartType>();
|
||||||
|
egIncompatibilities.add(tr);
|
||||||
|
cm.addIncompatibilities(eg, egIncompatibilities);
|
||||||
|
|
||||||
|
Set<PartType> efRequirement = new HashSet<PartType>();
|
||||||
|
efRequirement.add(eg);
|
||||||
|
cm.addRequirements(tr, efRequirement);
|
||||||
|
|
||||||
|
|
||||||
|
assertFalse(cm.getIncompatibilities(eg).contains(eg));
|
||||||
|
assertTrue(cm.getRequirements(tr).contains(eg));
|
||||||
|
assertTrue(cm.getIncompatibilities(tr).contains(tr)); //tr Require eg, eg Incompatible tr, -> eg Incompatible eg
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Configuration
|
//Configuration
|
||||||
|
|
||||||
@@ -320,4 +342,29 @@ public class test_V1 {
|
|||||||
assertTrue(config1.isValid());
|
assertTrue(config1.isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_contradiction_config(){
|
||||||
|
CompatibilityManager cm2 = new CompatibilityManagerImpl();
|
||||||
|
PartType eg= new PartTypeImpl("eg",Engine.class, engine);
|
||||||
|
PartType tr= new PartTypeImpl("Tr", Transmission.class, transmission);
|
||||||
|
PartType ex= new PartTypeImpl("Ex", Exterior.class, exterior);
|
||||||
|
PartType in= new PartTypeImpl("In", Interior.class, interior);
|
||||||
|
|
||||||
|
Set<PartType> egIncompatibilities = new HashSet<PartType>();
|
||||||
|
egIncompatibilities.add(tr);
|
||||||
|
cm2.addIncompatibilities(eg, egIncompatibilities);
|
||||||
|
|
||||||
|
Set<PartType> efRequirement = new HashSet<PartType>();
|
||||||
|
efRequirement.add(eg);
|
||||||
|
cm2.addRequirements(eg, efRequirement);
|
||||||
|
|
||||||
|
ConfigurationImpl config1 = new ConfigurationImpl(cm2);
|
||||||
|
config1.selectPart(eg);
|
||||||
|
config1.selectPart(tr);
|
||||||
|
config1.selectPart(ex);
|
||||||
|
config1.selectPart(in);
|
||||||
|
|
||||||
|
assertFalse(config1.isValid());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user