Repository: InseeFr/Bauhaus-Back-Office
Pull request #889: 888 augmenter la couverture des tests de bauhaus back office
Author: login: SMaSndil
Created: 2025-03-18T07:30:33Z | Merged: 2025-03-19T19:02:21Z

#888 


Diff:
diff --git a/src/test/java/fr/insee/rmes/bauhaus_services/code_list/CodeListPublicationTest.java b/src/test/java/fr/insee/rmes/bauhaus_services/code_list/CodeListPublicationTest.java
index 2ecbadbb3..767d40424 100644
--- a/src/test/java/fr/insee/rmes/bauhaus_services/code_list/CodeListPublicationTest.java
+++ b/src/test/java/fr/insee/rmes/bauhaus_services/code_list/CodeListPublicationTest.java
@@ -2,6 +2,7 @@
 
 import fr.insee.rmes.bauhaus_services.Constants;
 import fr.insee.rmes.bauhaus_services.rdf_utils.PublicationUtils;
+import fr.insee.rmes.bauhaus_services.rdf_utils.RdfUtils;
 import fr.insee.rmes.bauhaus_services.rdf_utils.RepositoryGestion;
 import fr.insee.rmes.bauhaus_services.rdf_utils.RepositoryPublication;
 import fr.insee.rmes.exceptions.RmesException;
@@ -9,6 +10,8 @@
 import org.eclipse.rdf4j.model.IRI;
 import org.eclipse.rdf4j.model.Model;
 import org.eclipse.rdf4j.model.Statement;
+import org.eclipse.rdf4j.model.base.InternedIRI;
+import org.eclipse.rdf4j.model.impl.GenericStatement;
 import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
 import org.eclipse.rdf4j.model.vocabulary.SKOS;
 import org.eclipse.rdf4j.repository.RepositoryResult;
@@ -24,6 +27,7 @@
 import java.util.Collections;
 import java.util.List;
 
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.verify;
@@ -44,6 +48,18 @@ class CodeListPublicationTest {
     @Mock
     PublicationUtils publicationUtils;
 
+    @Mock
+    GenericStatement statement;
+
+
+    @Test
+    void shouldExcludeTriplet() {
+        InternedIRI myIRI = new InternedIRI("myIRI", "creator");
+        when(statement.getPredicate()).thenReturn(myIRI);
+        String pred = RdfUtils.toString(statement.getPredicate());
+        assertTrue(pred.endsWith("validationState") || pred.endsWith(Constants.CREATOR) || pred.endsWith(Constants.CONTRIBUTOR) || pred.endsWith("lastCodeUriSegment"));
+    }
+
     @Test
     void shouldThrowExceptionIfNoStatements() throws RmesException {
         List<Statement> fakeStatements = Collections.emptyList();
diff --git a/src/test/java/fr/insee/rmes/bauhaus_services/code_list/CodeListServiceImplTest.java b/src/test/java/fr/insee/rmes/bauhaus_services/code_list/CodeListServiceImplTest.java
index ba2be5d3b..c509a75ac 100644
--- a/src/test/java/fr/insee/rmes/bauhaus_services/code_list/CodeListServiceImplTest.java
+++ b/src/test/java/fr/insee/rmes/bauhaus_services/code_list/CodeListServiceImplTest.java
@@ -28,12 +28,16 @@ class CodeListServiceImplTest {
     @Mock
     RepositoryGestion repositoryGestion;
 
+    @Mock
+    JSONObject counter;
+
     @Spy
     @InjectMocks
     CodeListServiceImpl codeListService;
 
     private final ObjectMapper objectMapper = new ObjectMapper();
 
+
     @Test
     void getAllCodesLists() throws RmesException, JsonProcessingException {
         try (MockedStatic<CodeListQueries> mockedFactory = Mockito.mockStatic(CodeListQueries.class)) {
diff --git a/src/test/java/fr/insee/rmes/bauhaus_services/concepts/ConceptsCollectionServiceImplTest.java b/src/test/java/fr/insee/rmes/bauhaus_services/concepts/ConceptsCollectionServiceImplTest.java
index 82c68e6d6..736b55489 100644
--- a/src/test/java/fr/insee/rmes/bauhaus_services/concepts/ConceptsCollectionServiceImplTest.java
+++ b/src/test/java/fr/insee/rmes/bauhaus_services/concepts/ConceptsCollectionServiceImplTest.java
@@ -4,7 +4,9 @@
 import fr.insee.rmes.bauhaus_services.rdf_utils.RepositoryGestion;
 import fr.insee.rmes.config.ConfigStub;
 import fr.insee.rmes.exceptions.RmesException;
+import fr.insee.rmes.model.concepts.CollectionForExport;
 import fr.insee.rmes.persistance.sparql_queries.GenericQueries;
+import fr.insee.rmes.utils.XMLUtils;
 import org.json.JSONArray;
 import org.json.JSONObject;
 import org.junit.jupiter.api.BeforeAll;
@@ -13,6 +15,9 @@
 import org.mockito.Mock;
 import org.mockito.junit.jupiter.MockitoExtension;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.when;
@@ -22,11 +27,30 @@ class ConceptsCollectionServiceImplTest {
     @Mock
     RepositoryGestion repoGestion;
 
+
     @BeforeAll
     static void initGenericQueries(){
         GenericQueries.setConfig(new ConfigStub());
     }
 
+    @Test
+    void shouldConvertCollectionInXml() {
+
+        JSONArray members = new JSONArray();
+        members.put(new JSONObject().put("id", "ID2").put("creator", "CREATOR").put("prefLabelLg1", "PREFLABELLG1").put("prefLabelLg2", "PREFLABELLG2").put("defCourteLg1", "DEFCOURTELG1").put("defCourteLg2", "DEFCOURTELG2").put("defLongueLg1", "DEFLONGUELG1").put("defLongueLg2", "DEFLONGUELG2").put("isValidated", "ISVALIDATED").put("editorialNoteLg1", "EDITORIALNOTELG1").put("editorialNoteLg2", "EDITORIALNOTELG2").put("createdA", "CREATEA").put("modifiedA", "MODIFIEDA"));
+        CollectionForExport collectionForExport = new CollectionForExport();
+        collectionForExport.addMembers(members);
+
+        String collectionXml = XMLUtils.produceXMLResponse(collectionForExport);
+        Map<String,String> xmlContent = new HashMap<>();
+        xmlContent.put("collectionFile",  collectionXml.replace("CollectionForExport", "Collection"));
+
+        String collectionFile="{collectionFile=<Collection><id/><prefLabelLg1/><prefLabelLg2/><creator/><contributor/><created/><modified/><isValidated/><membersLg><membersLg><id>ID2</id><creator>CREATOR</creator><prefLabelLg1>PREFLABELLG1</prefLabelLg1><prefLabelLg2>PREFLABELLG2</prefLabelLg2><defCourteLg1>DEFCOURTELG1</defCourteLg1><defCourteLg2>DEFCOURTELG2</defCourteLg2><defLongueLg1>DEFLONGUELG1</defLongueLg1><defLongueLg2>DEFLONGUELG2</defLongueLg2><isValidated>Provisoire</isValidated><editorialNoteLg1>EDITORIALNOTELG1</editorialNoteLg1><editorialNoteLg2>EDITORIALNOTELG2</editorialNoteLg2><created/><modified/></membersLg></membersLg><descriptionLg1/><descriptionLg2/></Collection>}";
+
+        assertEquals(collectionFile,xmlContent.toString());
+    }
+
+
     @Test
     void shouldGetCollectionsList() throws RmesException {
         ConceptsCollectionServiceImpl collectionsImpl = new ConceptsCollectionServiceImpl(null, null, 50);
diff --git a/src/test/java/fr/insee/rmes/bauhaus_services/concepts/ConceptsImplTest.java b/src/test/java/fr/insee/rmes/bauhaus_services/concepts/ConceptsImplTest.java
index 7d77663b7..02c752b5c 100644
--- a/src/test/java/fr/insee/rmes/bauhaus_services/concepts/ConceptsImplTest.java
+++ b/src/test/java/fr/insee/rmes/bauhaus_services/concepts/ConceptsImplTest.java
@@ -11,6 +11,7 @@
 import fr.insee.rmes.model.concepts.CollectionForExportOld;
 import fr.insee.rmes.persistance.sparql_queries.GenericQueries;
 import fr.insee.rmes.utils.ExportUtils;
+import fr.insee.rmes.utils.FilesUtils;
 import fr.insee.rmes.webservice.concepts.ConceptsCollectionsResources;
 import org.json.JSONArray;
 import org.json.JSONObject;
@@ -46,7 +47,6 @@
 @ExtendWith(MockitoExtension.class)
 class ConceptsImplTest {
 
-
     @Mock
     ConceptsUtils conceptsUtils;
 
@@ -56,11 +56,24 @@ class ConceptsImplTest {
     @Mock
     CollectionExportBuilder collectionExport;
 
+    @Mock
+    CollectionForExport collectionForExport;
+
     @BeforeAll
     static void initGenericQueries(){
         GenericQueries.setConfig(new ConfigStub());
     }
 
+
+    @Test
+    void shouldReturnFileNameForExport()  {
+        when(collectionForExport.getId()).thenReturn("421");
+        when(collectionForExport.getPrefLabelLg1()).thenReturn("FR");
+        String response = FilesUtils.generateFinalFileNameWithoutExtension(collectionForExport.getId() + "-" + collectionForExport.getPrefLabelLg1(), 32);
+        assertEquals("421Fr",response);
+    }
+
+
     @Test
     void shouldGetConceptsList() throws RmesException {
         ConceptsImpl conceptsImpl = new ConceptsImpl(null, null, null, collectionExport, 10);
diff --git a/src/test/java/fr/insee/rmes/bauhaus_services/concepts/concepts/ConceptsUtilsTest.java b/src/test/java/fr/insee/rmes/bauhaus_services/concepts/concepts/ConceptsUtilsTest.java
deleted file mode 100644
index d5ca5f0ba..000000000
--- a/src/test/java/fr/insee/rmes/bauhaus_services/concepts/concepts/ConceptsUtilsTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package fr.insee.rmes.bauhaus_services.concepts.concepts;
-
-import fr.insee.rmes.model.concepts.ConceptForExport;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-class ConceptsUtilsTest {
-
-    @Test
-    void testGetConceptExportFileName() {
-        String conceptId = "12345";
-        String prefLabelLg1 = "Lg1ConceptLabel";
-        String prefLabelLg2 = "Lg2ConceptLabel";
-        int maxLength = 10;
-
-        ConceptForExport concept = new ConceptForExport();
-        concept.setId(conceptId);
-        concept.setPrefLabelLg1(prefLabelLg1);
-        concept.setPrefLabelLg2(prefLabelLg2);
-
-        ConceptsUtils service = new ConceptsUtils(null, null, maxLength);
-
-        String result = service.getConceptExportFileName(concept);
-
-        assertEquals("12345Lg1co", result);
-
-    }
-}
\ No newline at end of file
diff --git a/src/test/java/fr/insee/rmes/bauhaus_services/rdf_utils/PublicationUtilsTest.java b/src/test/java/fr/insee/rmes/bauhaus_services/rdf_utils/PublicationUtilsTest.java
index 55e795a1d..826230efa 100644
--- a/src/test/java/fr/insee/rmes/bauhaus_services/rdf_utils/PublicationUtilsTest.java
+++ b/src/test/java/fr/insee/rmes/bauhaus_services/rdf_utils/PublicationUtilsTest.java
@@ -2,12 +2,48 @@
 
 import fr.insee.rmes.bauhaus_services.Constants;
 import fr.insee.rmes.model.ValidationStatus;
+import org.eclipse.rdf4j.model.Resource;
+import org.eclipse.rdf4j.model.base.InternedIRI;
 import org.junit.jupiter.api.Test;
+import org.mockito.Mock;
 
+import static fr.insee.rmes.bauhaus_services.rdf_utils.PublicationUtils.stringEndsWithItemFromList;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 class PublicationUtilsTest {
+
+    @Mock
+    RepositoryGestion repositoryGestion;
+
+    @Mock
+    RepositoryPublication repositoryPublication;
+
+
+    @Test
+    void shouldTranformBaseURIToPublishWithoutConvertToUriFormat() {
+
+        Resource myResource1 = new InternedIRI("myNamespace", "mylocalName");
+        Resource myResource2 = new InternedIRI("gestion.baseURI", ".mylocalName");
+        PublicationUtils myPublicationUtils = new PublicationUtils("gestion.baseURI.", "publication.baseURI.",repositoryGestion,repositoryPublication);
+
+        boolean myResponse1=!myResource1.toString().contains(myPublicationUtils.baseUriGestion());
+        String myResponse2 = myResource2.toString().replace(myPublicationUtils.baseUriGestion(), myPublicationUtils.baseUriPublication());
+
+        assertTrue(myResponse1 && ("publication.baseURI.mylocalName").equals(myResponse2));
+    }
+
+    @Test
+    void shouldTVerifyStringEndsWithItemFromList() {
+        String inputStr = "Bauhaus-Back-Office";
+        String[] items1 = { "Office", "pdf", "fr" };
+        String[] items2 = { "en", "pdf", "fr" };
+        boolean response1= stringEndsWithItemFromList(inputStr, items1);
+        boolean response2= !stringEndsWithItemFromList(inputStr, items2);
+        assertTrue(response1 && response2);
+
+    }
+
     @Test
     void testIsUnpublished() {
         String unpublishedStatus = ValidationStatus.UNPUBLISHED.getValue();
diff --git a/src/test/java/fr/insee/rmes/config/keycloak/KeycloakServerTest.java b/src/test/java/fr/insee/rmes/config/keycloak/KeycloakServerTest.java
new file mode 100644
index 000000000..505fe4181
--- /dev/null
+++ b/src/test/java/fr/insee/rmes/config/keycloak/KeycloakServerTest.java
@@ -0,0 +1,28 @@
+package fr.insee.rmes.config.keycloak;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class KeycloakServerTest {
+
+
+    @Test
+    void secret() {
+        KeycloakServer keycloakServer = new KeycloakServer("secret", "clientID", "server");
+        assertEquals("secret",keycloakServer.secret());
+    }
+
+    @Test
+    void clientId() {
+        KeycloakServer keycloakServer = new KeycloakServer("secret", "clientID", "server");
+        assertEquals("clientID",keycloakServer.clientId());
+    }
+
+    @Test
+    void server() {
+        KeycloakServer keycloakServer = new KeycloakServer("secret", "clientID", "server");
+        assertEquals("server",keycloakServer.server());
+    }
+
+}
\ No newline at end of file
diff --git a/src/test/java/fr/insee/rmes/config/swagger/OpenApiConfigurationTest.java b/src/test/java/fr/insee/rmes/config/swagger/OpenApiConfigurationTest.java
new file mode 100644
index 000000000..04e967eb6
--- /dev/null
+++ b/src/test/java/fr/insee/rmes/config/swagger/OpenApiConfigurationTest.java
@@ -0,0 +1,19 @@
+package fr.insee.rmes.config.swagger;
+
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class OpenApiConfigurationTest {
+
+    @Test
+    void shouldDisplayCorrectOpenAPI() {
+
+        OpenApiConfiguration myOpenAPI = new OpenApiConfiguration();
+        String actual = myOpenAPI.openAPI("v421").toString().replaceAll("\\s+", "");
+
+        String expected = "class OpenAPI {" + "openapi: 3.0.1" + "info: class Info {" + "title: Bauhaus" + "description: Back office de Bauhaus (rmesgncs)" + "summary: null" + "termsOfService: null" + "contact: null" + "license: null" + "version: v421" + "}" + "externalDocs: null" + "servers: null" + "security: null" + "tags: null" + "paths: null" + "components: null" + "}";
+
+        assertEquals(expected.replaceAll("\\s+", ""),actual);
+    }
+
+}
\ No newline at end of file
diff --git a/src/test/java/fr/insee/rmes/utils/PropertiesUtilsTest.java b/src/test/java/fr/insee/rmes/utils/PropertiesUtilsTest.java
new file mode 100644
index 000000000..01b379fec
--- /dev/null
+++ b/src/test/java/fr/insee/rmes/utils/PropertiesUtilsTest.java
@@ -0,0 +1,22 @@
+package fr.insee.rmes.utils;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.mock.env.MockEnvironment;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class PropertiesUtilsTest {
+
+    @Test
+    void shouldFindByName() {
+
+        MockEnvironment mockEnvironment = new MockEnvironment();
+        mockEnvironment.setProperty("myKey", "myProperties");
+
+        PropertiesUtils propertiesUtils = new PropertiesUtils(mockEnvironment);
+
+        String response =propertiesUtils.findByName("myKey").toString();
+        assertEquals("Optional[myProperties]",response);
+    }
+    
+}
\ No newline at end of file
diff --git a/src/test/java/fr/insee/rmes/utils/StringComparatorTest.java b/src/test/java/fr/insee/rmes/utils/StringComparatorTest.java
new file mode 100644
index 000000000..da0fa7f92
--- /dev/null
+++ b/src/test/java/fr/insee/rmes/utils/StringComparatorTest.java
@@ -0,0 +1,23 @@
+package fr.insee.rmes.utils;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class StringComparatorTest {
+
+    @Test
+    void shouldCompareTwoStrings() {
+
+        StringComparator stringComparator = new StringComparator();
+        int exampleOne = stringComparator.compare("Bauhaus","Bauhaus");
+        int exampleTwo = stringComparator.compare("Bauhaus", "Bauhaus-back-office");
+        int exampleThree = stringComparator.compare("Bauhaus-back-office","Bauhaus");
+
+        List<Integer> response = List.of(exampleOne,exampleTwo,exampleThree);
+
+        assertEquals(response, List.of(0,-1,1));
+    }
+}
\ No newline at end of file
diff --git a/src/test/java/fr/insee/rmes/utils/StringUtilsTest.java b/src/test/java/fr/insee/rmes/utils/StringUtilsTest.java
new file mode 100644
index 000000000..42e8bb641
--- /dev/null
+++ b/src/test/java/fr/insee/rmes/utils/StringUtilsTest.java
@@ -0,0 +1,41 @@
+package fr.insee.rmes.utils;
+
+import org.eclipse.rdf4j.model.IRI;
+import org.eclipse.rdf4j.model.base.InternedIRI;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class StringUtilsTest {
+
+    @Test
+    void stringToList() {
+        List<String> response = StringUtils.stringToList("Bauhaus-Back");
+        List<String> model = List.of("Bauhaus-Back");
+        assertEquals(model,response);
+    }
+
+    @Test
+    void urisAsString() {
+        InternedIRI uri1 = new InternedIRI("namespace1", "localName1");
+        InternedIRI uri2 = new InternedIRI("namespace2", "localName2");
+        InternedIRI uri3 = new InternedIRI("namespace3", "localName3");
+        List<IRI> uris = List.of(uri1,uri2,uri3);
+        String expected="<namespace1localName1><namespace2localName2><namespace3localName3>";
+        String actual=StringUtils.urisAsString(uris);
+        assertEquals(expected,actual);
+    }
+
+    @Test
+    void convertHtmlStringToRaw() {
+        String html= "<html><head> <title> Bauhaus HTML Page </title> <meta charset=\"utf-8\" /> </head> <body> <h1> A title of <p> Bauhaus </p> Application </h1> <p> An example. </p> <h2>Level of title  2</h2> <p> A new link to a website  <a href=\"https://github.com/inseefr\">bauhaus-back-office.fr</a>.</p></body> </html>";
+        String result = StringUtils.convertHtmlStringToRaw(html);
+        String expected =   "Bauhaus HTML Page      A title of Bauhaus  Application An example.  Level of title  2 A new link to a website bauhaus-back-office.fr.";
+        String resultWhithoutSpaces = result.replaceAll("\\s", "");
+        String expectedWhithoutSpaces = expected.replaceAll("\\s", "");
+        assertEquals(expectedWhithoutSpaces,resultWhithoutSpaces);
+    }
+
+}
\ No newline at end of file
diff --git a/src/test/java/fr/insee/rmes/utils/UriUtilsTest.java b/src/test/java/fr/insee/rmes/utils/UriUtilsTest.java
new file mode 100644
index 000000000..ca5c41bf2
--- /dev/null
+++ b/src/test/java/fr/insee/rmes/utils/UriUtilsTest.java
@@ -0,0 +1,18 @@
+package fr.insee.rmes.utils;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class UriUtilsTest {
+
+    @Test
+    void getLastPartFromUri() {
+        String exampleOne = UriUtils.getLastPartFromUri("BauhausBack");
+        String exampleTwo = UriUtils.getLastPartFromUri("Bauhaus\\Back\\");
+        String exampleTree = UriUtils.getLastPartFromUri("Bauhaus\\Back");
+        assertEquals("[, , Back]", List.of(exampleOne,exampleTwo,exampleTree).toString());
+    }
+}
\ No newline at end of file
diff --git a/src/test/java/fr/insee/rmes/utils/XhtmlTagsTest.java b/src/test/java/fr/insee/rmes/utils/XhtmlTagsTest.java
new file mode 100644
index 000000000..ccb7d2c8c
--- /dev/null
+++ b/src/test/java/fr/insee/rmes/utils/XhtmlTagsTest.java
@@ -0,0 +1,18 @@
+package fr.insee.rmes.utils;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class XhtmlTagsTest {
+
+    @Test
+    void verifyInListItemAndInUpperCaseFunctionalities() {
+
+        String s = "Bauhaus-back-Office";
+        boolean responseOne = ("<li>Bauhaus-back-Office</li>").equals(XhtmlTags.inListItem(s));
+        boolean responseTwo =("<U>Bauhaus-back-Office</U>").equals(XhtmlTags.inUpperCase(s));
+        assertTrue(responseOne && responseTwo);
+
+    }
+}
\ No newline at end of file


Reviews:
user: login: EmmanuelDemey
state: CHANGES_REQUESTED
author_association: COLLABORATOR
submitted_at: 2025-03-18T12:16:12Z
user: login: EmmanuelDemey
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-03-19T19:02:13Z

Review comments:
diff_hunk: @@ -28,12 +28,42 @@ class CodeListServiceImplTest {
     @Mock
     RepositoryGestion repositoryGestion;
 
+    @Mock
+    JSONObject counter;
+
     @Spy
     @InjectMocks
     CodeListServiceImpl codeListService;
 
     private final ObjectMapper objectMapper = new ObjectMapper();
 
+    @Test
+    void shouldDisplayCorrectGetCodesAsJSONObject() {
path: src/test/java/fr/insee/rmes/bauhaus_services/code_list/CodeListServiceImplTest.java
user: login: EmmanuelDemey
body: Pour moi ce test n'est pas utile, car tu ne testes pas de code métier. 
created_at: 2025-03-18T12:11:29Z
author_association: COLLABORATOR
diff_hunk: @@ -44,6 +53,40 @@ class CodeListPublicationTest {
     @Mock
     PublicationUtils publicationUtils;
 
+    @Mock
+    RepositoryResult<Statement> statements;
+
+    @Mock
+    Resource codeList;
+
+    @Mock
+    GenericStatement statement;
+
+    @Test
+    void shouldCheckIResourceDoesNotExists() {
path: src/test/java/fr/insee/rmes/bauhaus_services/code_list/CodeListPublicationTest.java
user: login: EmmanuelDemey
body: Pour moi ce test n'est pas utile, car tu ne testes pas de code métier. 
created_at: 2025-03-18T12:12:42Z
author_association: COLLABORATOR
diff_hunk: @@ -44,6 +53,40 @@ class CodeListPublicationTest {
     @Mock
     PublicationUtils publicationUtils;
 
+    @Mock
+    RepositoryResult<Statement> statements;
+
+    @Mock
+    Resource codeList;
+
+    @Mock
+    GenericStatement statement;
+
+    @Test
+    void shouldCheckIResourceDoesNotExists() {
+        when(codeList.stringValue()).thenReturn("test");
+        assertThatThrownBy(() -> {
+            if(!statements.hasNext()){
+                throw new RmesNotFoundException(CodesListErrorCodes.CODE_LIST_UNKNOWN_ID, "CodeList not found", codeList.stringValue());
+            }
+        }).isInstanceOf(RmesNotFoundException.class);
+    }
+
+    @Test
+    void shouldVerifyWhenMessageWhenResourceDoesNotExists()  {
path: src/test/java/fr/insee/rmes/bauhaus_services/code_list/CodeListPublicationTest.java
user: login: EmmanuelDemey
body: Pour moi ce test n'est pas utile, car tu ne testes pas de code métier. 
created_at: 2025-03-18T12:12:45Z
author_association: COLLABORATOR
diff_hunk: @@ -56,11 +55,41 @@ class ConceptsImplTest {
     @Mock
     CollectionExportBuilder collectionExport;
 
+    @Mock
+    CollectionForExport collectionForExport;
+
     @BeforeAll
     static void initGenericQueries(){
         GenericQueries.setConfig(new ConfigStub());
     }
 
+    @Test
+    void shouldNotDeleteConcepts() throws RmesException {
+        JSONArray array = new JSONArray();
+        array.put(new JSONObject().put("id", "1").put("label", "label 1").put("altLabel", "latLabel1"));
+        array.put(new JSONObject().put("id", "2").put("label", "label 2").put("altLabel", "latLabel2"));
+        when(conceptsUtils.getGraphsWithConcept(anyString())).thenReturn(array);
+        assertTrue(conceptsUtils.getGraphsWithConcept(anyString()).length()>1);
path: src/test/java/fr/insee/rmes/bauhaus_services/concepts/ConceptsImplTest.java
user: login: EmmanuelDemey
body: Pour moi ce test n'est pas utile, car tu test ton mock en fait je trouve. 
created_at: 2025-03-18T12:14:04Z
author_association: COLLABORATOR
diff_hunk: @@ -56,11 +55,41 @@ class ConceptsImplTest {
     @Mock
     CollectionExportBuilder collectionExport;
 
+    @Mock
+    CollectionForExport collectionForExport;
+
     @BeforeAll
     static void initGenericQueries(){
         GenericQueries.setConfig(new ConfigStub());
     }
 
+    @Test
+    void shouldNotDeleteConcepts() throws RmesException {
+        JSONArray array = new JSONArray();
+        array.put(new JSONObject().put("id", "1").put("label", "label 1").put("altLabel", "latLabel1"));
+        array.put(new JSONObject().put("id", "2").put("label", "label 2").put("altLabel", "latLabel2"));
+        when(conceptsUtils.getGraphsWithConcept(anyString())).thenReturn(array);
+        assertTrue(conceptsUtils.getGraphsWithConcept(anyString()).length()>1);
+    }
+
+    @Test
+    void shouldReturnConcept() throws RmesException {
+        JSONObject test = new JSONObject();
+        test.put("label","LABEL");
+        test.put("id","ID");
+        when(conceptsUtils.getConceptById((anyString()))).thenReturn(test);
+        assertEquals("{\"label\":\"LABEL\",\"id\":\"ID\"}",conceptsUtils.getConceptById("id").toString());
path: src/test/java/fr/insee/rmes/bauhaus_services/concepts/ConceptsImplTest.java
user: login: EmmanuelDemey
body: idem
created_at: 2025-03-18T12:14:21Z
author_association: COLLABORATOR
diff_hunk: @@ -1,12 +1,29 @@
 package fr.insee.rmes.bauhaus_services.concepts.concepts;
 
+import fr.insee.rmes.bauhaus_services.Constants;
 import fr.insee.rmes.model.concepts.ConceptForExport;
+import org.json.JSONObject;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 class ConceptsUtilsTest {
 
+    @Test
+    void shouldCreateID() {
path: src/test/java/fr/insee/rmes/bauhaus_services/concepts/concepts/ConceptsUtilsTest.java
user: login: EmmanuelDemey
body: Pour moi ce test n'est pas utile, car tu ne testes pas de code métier. 
created_at: 2025-03-18T12:14:54Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,32 @@
+package fr.insee.rmes.bauhaus_services.structures.utils;
+
+import com.sun.jna.Structure;
+import fr.insee.rmes.bauhaus_services.Constants;
+import fr.insee.rmes.bauhaus_services.rdf_utils.RdfUtils;
+import fr.insee.rmes.persistance.ontologies.INSEE;
+import org.json.JSONObject;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mock;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class StructureComponentUtilsTest {
+
+    @Mock
+    Structure structures;
+
+    @Test
+    void shouldReturnFormatComponent() {
path: src/test/java/fr/insee/rmes/bauhaus_services/structures/utils/StructureComponentUtilsTest.java
user: login: EmmanuelDemey
body: Pour moi ce test n'est pas utile, car tu ne testes pas de code métier. 
created_at: 2025-03-18T12:15:59Z
author_association: COLLABORATOR

PR comments:
user: login: sonarqubecloud[bot]
created_at: 2025-03-18T14:45:21Z
body: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=InseeFr_Bauhaus-Back-Office&pullRequest=889) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=InseeFr_Bauhaus-Back-Office&pullRequest=889&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=InseeFr_Bauhaus-Back-Office&pullRequest=889&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=InseeFr_Bauhaus-Back-Office&pullRequest=889&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=InseeFr_Bauhaus-Back-Office&pullRequest=889&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=InseeFr_Bauhaus-Back-Office&pullRequest=889&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=InseeFr_Bauhaus-Back-Office&pullRequest=889)


author_association: NONE