correction confif + Junit 5
This commit is contained in:
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"files.watcherExclude": {
|
||||||
|
"**/target": true
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
BIN
lib/junit-platform-console-standalone-1.11.4.jar
Normal file
BIN
lib/junit-platform-console-standalone-1.11.4.jar
Normal file
Binary file not shown.
@@ -191,7 +191,7 @@ public class CompatibilityManagerImpl implements CompatibilityManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
System.out.println("size = " + result.size());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ public class CompatibilityManagerImpl implements CompatibilityManager {
|
|||||||
public Set<PartType> getRequirements(PartType reference) {
|
public Set<PartType> getRequirements(PartType reference) {
|
||||||
Set<PartType> result = new HashSet<>();
|
Set<PartType> result = new HashSet<>();
|
||||||
Femeture_Transivite(reference, result,new HashSet<>(),reference);
|
Femeture_Transivite(reference, result,new HashSet<>(),reference);
|
||||||
|
System.out.println("size = " + result.size());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,24 +4,33 @@ import src.fr.api.Category;
|
|||||||
import src.fr.api.PartType;
|
import src.fr.api.PartType;
|
||||||
import src.fr.api.CompatibilityManager;
|
import src.fr.api.CompatibilityManager;
|
||||||
import src.fr.api.Configuration;
|
import src.fr.api.Configuration;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class ConfigurationImpl implements Configuration {
|
public class ConfigurationImpl implements Configuration {
|
||||||
private Set<PartType> selectedParts;
|
private Set<PartType> selectedParts = new HashSet<PartType> ();
|
||||||
private CompatibilityManager compatibilityManager;
|
private CompatibilityManager compatibilityManager;
|
||||||
private static int NB_CATEGORY = 4;
|
private static int NB_CATEGORY = 4;
|
||||||
|
|
||||||
|
public ConfigurationImpl(CompatibilityManager cm){
|
||||||
|
this.compatibilityManager=cm;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
if (this.isComplete()){
|
if (this.isComplete()){
|
||||||
for(PartType pt: selectedParts){
|
for(PartType pt: selectedParts){
|
||||||
|
System.out.println(pt.getName());
|
||||||
|
|
||||||
//Verifier Requirements
|
//Verifier Requirements
|
||||||
for(PartType require : compatibilityManager.getRequirements(pt)){
|
for(PartType require : compatibilityManager.getRequirements(pt)){
|
||||||
|
System.out.println("\t"+require.getName());
|
||||||
if(!selectedParts.contains(require)) return false;
|
if(!selectedParts.contains(require)) return false;
|
||||||
}
|
}
|
||||||
//Verifier Incompabilities
|
//Verifier Incompabilities
|
||||||
for(PartType incompa : compatibilityManager.getIncompatibilities(pt)){
|
for(PartType incompa : compatibilityManager.getIncompatibilities(pt)){
|
||||||
|
System.out.println("\t"+incompa.getName());
|
||||||
if(selectedParts.contains(incompa)) return false;
|
if(selectedParts.contains(incompa)) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,7 +62,8 @@ public class ConfigurationImpl implements Configuration {
|
|||||||
for( PartType pt: selectedParts){
|
for( PartType pt: selectedParts){
|
||||||
if(pt.getCategory().equals(cat_chosenPart)){
|
if(pt.getCategory().equals(cat_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");
|
||||||
return;
|
selectedParts.remove(pt);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
selectedParts.add(chosenPart);
|
selectedParts.add(chosenPart);
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import static org.junit.Assert.*;
|
|||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
import src.fr.impl.*;
|
import src.fr.impl.*;
|
||||||
import src.fr.api.*;
|
import src.fr.api.*;
|
||||||
@@ -44,11 +46,6 @@ public class test {
|
|||||||
|
|
||||||
CompatibilityManager cm = new CompatibilityManagerImpl();
|
CompatibilityManager cm = new CompatibilityManagerImpl();
|
||||||
|
|
||||||
PartType[] list = {EG100,EG133,EG210,ED110,ED180,EH120,TM5,TM6,TA5,TS6,TSF7,TC120,XC,XM,XS,IN,IH,IS};
|
|
||||||
PartType[] listEn = {EG100,EG133,EG210,ED110,ED180,EH120};
|
|
||||||
PartType[] listTr = {TM5,TM6,TA5,TS6,TSF7,TC120};
|
|
||||||
PartType[] listEx = {XC,XM,XS};
|
|
||||||
PartType[] listIn = {IN,IH,IS};
|
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@@ -211,4 +208,60 @@ public class test {
|
|||||||
assertTrue(cm.getIncompatibilities(TSF7).contains(ED110));
|
assertTrue(cm.getIncompatibilities(TSF7).contains(ED110));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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_isValid_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_isValid(){
|
||||||
|
ConfigurationImpl config1 = new ConfigurationImpl(cm);
|
||||||
|
config1.selectPart(EG210);
|
||||||
|
config1.selectPart(TS6);
|
||||||
|
config1.selectPart(XS);
|
||||||
|
config1.selectPart(IS);
|
||||||
|
|
||||||
|
assertTrue(config1.isValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_isNotValid(){
|
||||||
|
ConfigurationImpl config1 = new ConfigurationImpl(cm);
|
||||||
|
config1.selectPart(EG210);
|
||||||
|
config1.selectPart(TM5);
|
||||||
|
config1.selectPart(XS);
|
||||||
|
config1.selectPart(IH);
|
||||||
|
|
||||||
|
assertTrue(config1.isComplete());
|
||||||
|
assertFalse(config1.isValid());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user