From 8770ec3165d0e800a3e79baaae487dc280f3c19c Mon Sep 17 00:00:00 2001 From: trochas Date: Thu, 24 Oct 2024 10:03:08 +0200 Subject: [PATCH] ajout de commentaires dans les interfaces et correction des test --- src/fr/api/Category.java | 5 ++++ src/fr/api/CompatibilityChecker.java | 12 ++++++++ src/fr/api/CompatibilityManager.java | 26 ++++++++++++++++ src/fr/api/Configuration.java | 7 +++++ src/fr/test/test.java | 45 +++++++++++++++++++++++----- 5 files changed, 88 insertions(+), 7 deletions(-) diff --git a/src/fr/api/Category.java b/src/fr/api/Category.java index 2eebb34..a0823bd 100644 --- a/src/fr/api/Category.java +++ b/src/fr/api/Category.java @@ -5,5 +5,10 @@ package src.fr.api; * A public type to organize part types in categories */ public interface Category { + + /* + * return the name of the cathegory + * @return String, name of the cathegory, non null + */ String getName(); } \ No newline at end of file diff --git a/src/fr/api/CompatibilityChecker.java b/src/fr/api/CompatibilityChecker.java index 99a6ca7..03869db 100644 --- a/src/fr/api/CompatibilityChecker.java +++ b/src/fr/api/CompatibilityChecker.java @@ -1,6 +1,18 @@ package src.fr.api; import java.util.Set; public interface CompatibilityChecker { + + /* + * return the list of the incompatibles PartType of a PartType + * @param reference : the PartType that we want to see the incompatibilities,non null + * @return the Set list of the incompatibles PartType + */ Set getIncompatibilities(PartType reference); + + /* + * return the list of the requirements PartType of a PartType + * @param reference : the PartType that we want to see the requirements,non null + * @return the Set list of the requirements PartType + */ Set getRequirements(PartType reference); } \ No newline at end of file diff --git a/src/fr/api/CompatibilityManager.java b/src/fr/api/CompatibilityManager.java index b620cc3..1be12fc 100644 --- a/src/fr/api/CompatibilityManager.java +++ b/src/fr/api/CompatibilityManager.java @@ -1,8 +1,34 @@ package src.fr.api; import java.util.Set; public interface CompatibilityManager extends CompatibilityChecker { + + /* + * add a incompatibles PartType to a PartType + * @param reference : the PartType that we wish to add incompatibilities + * @param target : Set list of incompatibilities PartType to add + */ void addIncompatibilities(PartType reference,Set target); + + /* + * remove a PartType of the incompatibilities of a PartType, warning, + * warning : we must also remove the incompatibility from all the other PartTypes which the @param reference in their incompatibility + * @param reference : the PartType that we wish to remove a incompatible PartType + * @param target : PartType to remove of incompatibility + */ void removeIncompatibility(PartType reference, PartType target); + + + /* + * add requirements PartType to a PartType + * @param reference : the PartType that we wish to add requirements + * @param target : Set list of requirement PartType to add + */ void addRequirements(PartType reference, Set target); + + /* + * remove a PartType of the incompatibilities of a PartType + * @param reference : the PartType that we wish to remove a requirement PartType + * @param target : PartType to remove of requirement + */ void removeRequirement(PartType reference, PartType target); } \ No newline at end of file diff --git a/src/fr/api/Configuration.java b/src/fr/api/Configuration.java index a746beb..7a7e221 100644 --- a/src/fr/api/Configuration.java +++ b/src/fr/api/Configuration.java @@ -1,7 +1,14 @@ package src.fr.api; import java.util.Set; public interface Configuration { + + + /* + * @return true if there is no compatibility issue between PartType else false + */ boolean isValid(); + + boolean isComplete(); Set getSelectedParts(); void selectPart(PartType chosenPart); diff --git a/src/fr/test/test.java b/src/fr/test/test.java index 0f87174..840ba2a 100644 --- a/src/fr/test/test.java +++ b/src/fr/test/test.java @@ -125,18 +125,49 @@ public class test { } @Test - public void test_Remove(){ + public void test_Remove_and_restore_Incompatibilities_6(){ assertTrue(cm.getIncompatibilities(XM).contains(EG100)); cm.removeIncompatibility(XM, EG100); assertFalse(cm.getIncompatibilities(XM).contains(EG100)); Set setEG100 = new HashSet(); setEG100.add(EG100); - cm.addIncompatibilities(EG100, setEG100); - System.out.println(cm.getIncompatibilities(XM) + "//////////"); - //assertTrue(cm.getIncompatibilities(XM).contains(EG100)); - + cm.addIncompatibilities(XM, setEG100); + assertTrue(cm.getIncompatibilities(XM).contains(EG100)); } - - + @Test + public void test_Remove_Empty_7(){ + assertTrue(cm.getIncompatibilities(EG100).isEmpty()); + cm.removeIncompatibility(EG100, EG100); + assertFalse(cm.getIncompatibilities(EG100).contains(EG100)); + } + + @Test + public void test_Remove_and_restore_Requirements_8(){ + assertTrue(cm.getRequirements(EH120).contains(TC120)); + cm.removeRequirement(EH120, TC120); + assertFalse(cm.getRequirements(EH120).contains(TC120)); + Set setTC120 = new HashSet(); + setTC120.add(TC120); + cm.addRequirements(EH120, setTC120); + assertTrue(cm.getRequirements(EH120).contains(TC120)); + } + + @Test + public void test_Add_and_restore_Incompatibilities_9(){ + assertTrue(cm.getIncompatibilities(TSF7).contains(EG100)); + assertTrue(cm.getIncompatibilities(TSF7).contains(EG133)); + assertTrue(cm.getIncompatibilities(TSF7).contains(ED110)); + cm.removeIncompatibility(TSF7, EG100); + assertFalse(cm.getIncompatibilities(TSF7).contains(EG100)); + assertTrue(cm.getIncompatibilities(TSF7).contains(EG133)); + assertTrue(cm.getIncompatibilities(TSF7).contains(ED110)); + Set setEG100 = new HashSet(); + setEG100.add(EG100); + cm.addIncompatibilities(TSF7, setEG100); + assertTrue(cm.getIncompatibilities(TSF7).contains(EG100)); + assertTrue(cm.getIncompatibilities(TSF7).contains(EG133)); + assertTrue(cm.getIncompatibilities(TSF7).contains(ED110)); + } + }