13 Commits

Author SHA1 Message Date
Rochas
04fdcc5d22 correction test 2024-12-20 21:24:43 +01:00
Rochas
1569746582 read me terminé + nouveau test 2024-12-20 21:01:30 +01:00
Rochas
01970a625a début du read me 2024-12-20 19:04:22 +01:00
Rochas Thibaut
5260d58c96 Add README.md 2024-12-20 17:12:15 +00:00
Rochas
4198d7a407 assertion Junit 5 2024-12-20 14:54:23 +01:00
Rochas
beeef622b3 Merge branch 'dev_v1' of https://gitlab2.istic.univ-rennes1.fr/tuvu/cartailor into dev_v1 2024-12-20 14:53:57 +01:00
Rochas
44fe20e95c assertion Junit 5 2024-12-20 14:53:47 +01:00
Vu Tuan Minh
4880ae8b3f Update Configuration.java 2024-12-20 12:17:45 +00:00
Minh VU
6a495edaa0 add description in interface 2024-12-20 12:26:21 +01:00
Rochas
1cb536a785 correction de BeforeEach avec Junit5 2024-12-20 00:05:31 +01:00
Rochas
45d796afc6 correction confif + Junit 5 2024-12-19 23:42:06 +01:00
trochas
b8d9eb5771 modification des test mineur 2024-11-13 10:13:28 +01:00
Minh VU
141cfdf4ff improve 2024-11-11 17:50:57 +01:00
14 changed files with 233 additions and 42 deletions

5
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,5 @@
{
"files.watcherExclude": {
"**/target": true
}
}

8
README.md Normal file
View File

@@ -0,0 +1,8 @@
V1:
Nous testons d'abord le CompatibilityManager. On fait un BeforeEach pour initialiser un CompatibilityManager (celui vu en TD)
On teste si les Incompatibilities et Requirements sont bien récupérables à partir du CompatibilityManager avec les fonctions getIncompatibilities et getRequirements. GetIncompatibilities et getRequirements doivent donner toutes les Part incompatibles ou Require, même si elles n'ont pas été données directement à la Part testée. On doit donc aussi vérifier la contradiction : A a besoin de B mais B est incompatible avec A, alors A est incompatible avec lui-même.
On teste aussi la configuration, en vérifiant si une configuration est complète et si elle est validée (dans notre implémentation V1, une configuration validée est forcément complète, mais pas forcément l'inverse).
nous ne savons pas pourquoi mais dans notre projet les tests avec couverture ne fonctionnent pas, les tets sont bien testé, mais il tourne dans le vide et ne donne jamais le résultat de la couverture...

Binary file not shown.

Binary file not shown.

View File

@@ -7,12 +7,38 @@ public interface Configuration {
* @return true if there is no compatibility issue between PartType else false
*/
boolean isValid();
/*
* @return true if the configuration is valid and done
*/
boolean isComplete();
/*
* @return the list of the PartType in the configuration
*/
Set<PartType> getSelectedParts();
/*
* Select a PartType to add to the configuration
* @param chosenPart : the PartType that we wish to add to the configuration
*/
void selectPart(PartType chosenPart);
/*
* @return the PartType that we chose earlier which has Category we choose
* @param catgeory : Category that we want to know about the PartType can be null
*/
PartType getSelectionForCategory(Category category);
/*
* DeSelect PartType has Catgerory catgoryToClear to delete from the configuration
* @param categoryToClear : the PartType has categoryToClear Category
* that we wish to delete from the configuration
*/
void unselectPartType(Category categoryToClear);
/*
* Remove all PartType from configuation
*/
void clear();
}

View File

@@ -1,8 +1,24 @@
package src.fr.api;
import java.util.Set;
public interface Configurator {
/*
* @return the list of the Category in the configurator
*/
Set<Category> getCategories();
/*
* @return the list of the Category in the configurator
* @param category: category that we want to see all PartType in that category
*/
Set<PartType> getVariants(Category category);
/*
* @return the configuration
*/
Configuration getConfiguration();
/*
* @return compabilitychecker
*/
CompatibilityChecker getCompatibilityChecker();
}

View File

@@ -1,5 +1,12 @@
package src.fr.api;
public interface PartType {
/*
* @return name of this PartType
*/
String getName();
/*
* @return the category of this PartType
*/
Category getCategory();
}

View File

@@ -1,7 +1,7 @@
package src.fr.impl;
import src.fr.api.Category;
public class CategoryImpl implements src.fr.api.Category {
public class CategoryImpl implements Category {
private String name;
public CategoryImpl(String name){

View File

@@ -1,13 +1,12 @@
package src.fr.impl;
//import java.util.HashMap;
import java.util.Set;
import src.fr.api.PartType;
import src.fr.api.CompatibilityManager;
import src.fr.api.CompatibilityChecker;
public class CompatibilityCheckerImpl implements src.fr.api.CompatibilityChecker {
public class CompatibilityCheckerImpl implements CompatibilityChecker {
private CompatibilityManager compatibilityManager;
public CompatibilityCheckerImpl( CompatibilityManager compatibilityManager){
@@ -23,6 +22,4 @@ public class CompatibilityCheckerImpl implements src.fr.api.CompatibilityChecker
public Set<PartType> getRequirements(PartType reference) {
return this.compatibilityManager.getRequirements(reference);
}
}

View File

@@ -6,8 +6,9 @@ import java.util.HashSet;
import java.util.Set;
import java.util.Objects;
import src.fr.api.PartType;
import src.fr.api.CompatibilityManager;
public class CompatibilityManagerImpl implements src.fr.api.CompatibilityManager {
public class CompatibilityManagerImpl implements CompatibilityManager {
private HashMap<PartType, Set<PartType>> incompatibilities;
private HashMap<PartType, Set<PartType>> requirements;
@@ -190,7 +191,7 @@ public class CompatibilityManagerImpl implements src.fr.api.CompatibilityManager
}
}
System.out.println("size = " + result.size());
return result;
}
@@ -199,7 +200,7 @@ public class CompatibilityManagerImpl implements src.fr.api.CompatibilityManager
public Set<PartType> getRequirements(PartType reference) {
Set<PartType> result = new HashSet<>();
Femeture_Transivite(reference, result,new HashSet<>(),reference);
System.out.println("size = " + result.size());
return result;
}
}

View File

@@ -3,25 +3,34 @@ package src.fr.impl;
import src.fr.api.Category;
import src.fr.api.PartType;
import src.fr.api.CompatibilityManager;
import src.fr.api.Configuration;
import java.util.HashSet;
import java.util.Set;
public class ConfigurationImpl implements src.fr.api.Configuration {
private Set<PartType> selectedParts;
public class ConfigurationImpl implements Configuration {
private Set<PartType> selectedParts = new HashSet<PartType> ();
private CompatibilityManager compatibilityManager;
private static int NB_CATEGORY = 4;
public ConfigurationImpl(CompatibilityManager cm){
this.compatibilityManager=cm;
}
@Override
public boolean isValid() {
if (this.isComplete()){
for(PartType pt: selectedParts){
System.out.println(pt.getName());
//Verifier Requirements
for(PartType require : compatibilityManager.getRequirements(pt)){
System.out.println("\t"+require.getName());
if(!selectedParts.contains(require)) return false;
}
//Verifier Incompabilities
for(PartType incompa : compatibilityManager.getIncompatibilities(pt)){
System.out.println("\t"+incompa.getName());
if(selectedParts.contains(incompa)) return false;
}
}
@@ -53,7 +62,8 @@ public class ConfigurationImpl implements src.fr.api.Configuration {
for( PartType pt: selectedParts){
if(pt.getCategory().equals(cat_chosenPart)){
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);

View File

@@ -4,11 +4,12 @@ import src.fr.api.Category;
import src.fr.api.CompatibilityChecker;
import src.fr.api.Configuration;
import src.fr.api.PartType;
import src.fr.api.Configurator;
import java.util.HashSet;
import java.util.Set;
public class ConfiguratorImpl implements src.fr.api.Configurator {
public class ConfiguratorImpl implements Configurator {
private Set<Category> categories;
private Set<PartType> partTypes;
private Configuration configuration;

View File

@@ -1,8 +1,9 @@
package src.fr.impl;
import src.fr.api.Category;
import src.fr.api.PartType;
public class PartTypeImpl implements src.fr.api.PartType {
public class PartTypeImpl implements PartType {
private String name;
private Category category;

View File

@@ -1,12 +1,13 @@
package src.fr.test;
import java.util.Set;
import java.util.HashSet;
import static org.junit.Assert.assertFalse;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;
import src.fr.impl.*;
import src.fr.api.*;
@@ -42,18 +43,15 @@ public class test {
PartType IH= new PartTypeImpl("IH", Interior);
PartType IS= new PartTypeImpl("IS", Interior);
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};
CompatibilityManager cm;
@Before
@BeforeEach
public void init(){
cm = new CompatibilityManagerImpl();
Set<PartType> EH120Requirement = new HashSet<PartType>();
EH120Requirement.add(TC120);
@@ -149,12 +147,6 @@ public class test {
@Test
public void test_Incompatibilities_Complex_7(){
cm.addRequirements(TC120, Set.of(XC));
System.out.print(cm.getRequirements(TC120).size());
for(PartType p : cm.getRequirements(TC120)){
System.out.print(p.getName());
}
System.out.println("TC120 requirment size : " + cm.getRequirements(TC120).contains(XC));
assertTrue(cm.getRequirements(TC120).contains(XC));
assertTrue(cm.getRequirements(EH120).contains(XC));
cm.removeRequirement(TC120, XC);
@@ -178,12 +170,9 @@ public class test {
@Test
public void test_Remove_Empty_7(){
//Wrong test
//assertTrue(cm.getIncompatibilities(EG100).isEmpty());
// je crois on a TA5, TSF7, XM, XS et IS, faut tester
cm.removeIncompatibility(EG100, EG100);
assertFalse(cm.getIncompatibilities(EG100).contains(EG100));
}
assertTrue(cm.getIncompatibilities(EH120).isEmpty());
cm.removeIncompatibility(EH120, EG100);
assertTrue(cm.getIncompatibilities(EH120).isEmpty()); }
@Test
public void test_Remove_and_restore_Requirements_8(){
@@ -196,6 +185,13 @@ public class test {
assertTrue(cm.getRequirements(EH120).contains(TC120));
}
@Test
public void test_remove_incompatibilities_but_no_removable(){
assertTrue(cm.getIncompatibilities(EG100).contains(IS));
cm.removeIncompatibility(EG100, IS);
assertTrue(cm.getIncompatibilities(EG100).contains(IS));
}
@Test
public void test_Add_and_restore_Incompatibilities_9(){
assertTrue(cm.getIncompatibilities(TSF7).contains(EG100));
@@ -212,5 +208,128 @@ public class test {
assertTrue(cm.getIncompatibilities(TSF7).contains(EG133));
assertTrue(cm.getIncompatibilities(TSF7).contains(ED110));
}
@Test
public void test_contradiction(){
CompatibilityManager cm2 = new CompatibilityManagerImpl();
PartType eg= new PartTypeImpl("Eg", Engine);
PartType tr= new PartTypeImpl("Tr", Transmission);
Set<PartType> egIncompatibilities = new HashSet<PartType>();
egIncompatibilities.add(tr);
cm2.addIncompatibilities(eg, egIncompatibilities);
Set<PartType> efRequirement = new HashSet<PartType>();
efRequirement.add(eg);
cm2.addRequirements(tr, efRequirement);
assertFalse(cm2.getIncompatibilities(eg).contains(eg));
assertTrue(cm2.getRequirements(tr).contains(eg));
assertTrue(cm2.getIncompatibilities(tr).contains(tr)); //tr Require eg, eg Incompatible tr, -> eg Incompatible eg
}
@Test
public void test_isComplete_empty_config(){
ConfigurationImpl config1 = new ConfigurationImpl(cm);
assertFalse(config1.isComplete());
}
@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_isNotValide_empty_config(){
ConfigurationImpl config1 = new ConfigurationImpl(cm);
assertFalse(config1.isValid());
}
@Test
public void test_isNotValide_not_complete(){
ConfigurationImpl config1 = new ConfigurationImpl(cm);
config1.selectPart(EG210);
config1.selectPart(TM5);
config1.selectPart(XS);
assertFalse(config1.isValid());
}
@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);
assertFalse(config1.isValid());
}
@Test
public void test_contradiction_config(){
CompatibilityManager cm2 = new CompatibilityManagerImpl();
PartType eg= new PartTypeImpl("Eg", Engine);
PartType tr= new PartTypeImpl("Tr", Transmission);
PartType ex= new PartTypeImpl("Ex", Exterior);
PartType in= new PartTypeImpl("In", 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());
}
}