Skip to content

Commit

Permalink
Merge pull request #26 from kc-bclaudel/master
Browse files Browse the repository at this point in the history
Fix required-nomenclature endpoint
  • Loading branch information
nicolasTurban authored May 18, 2021
2 parents 2f26152 + f971133 commit e3b48b5
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>fr.insee.queen</groupId>
<artifactId>queen</artifactId>
<version>3.0.4</version>
<version>3.0.5</version>
<packaging>war</packaging>
<name>Queen-Back-Office</name>
<description>Back-office services for Queen</description>
Expand Down Expand Up @@ -391,7 +391,7 @@
<changeLogFile>src/main/resources/db/master.xml</changeLogFile>
<diffChangeLogFile>src/main/resources/db/changelog/new_changelog.xml</diffChangeLogFile>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://localhost:5433/queen_api</url>
<url>jdbc:postgresql://localhost:5432/queen_api</url>
<defaultSchemaName>public</defaultSchemaName>
<contexts>test,dev,prod</contexts>
<username>user_capi3g</username>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.insee.queen.api.controller;

import java.util.List;
import java.util.Optional;
import java.util.Set;

Expand Down Expand Up @@ -85,7 +86,7 @@ public ResponseEntity<Object> getNomenclatureById(@PathVariable(value = "id") St
*/
@ApiOperation(value = "Get list of required nomenclature by campaign Id ")
@GetMapping(path = "/campaign/{id}/required-nomenclatures")
public ResponseEntity<Object> getListRequiredNomenclature(@PathVariable(value = "id") String id){
public ResponseEntity<List<String>> getListRequiredNomenclature(@PathVariable(value = "id") String id){
Optional<Campaign> campaignOptional = campaignService.findById(id);
if (!campaignOptional.isPresent()) {
LOGGER.info("GET required-nomenclatures for campaign with id {} resulting in 404", id);
Expand All @@ -104,7 +105,7 @@ public ResponseEntity<Object> getListRequiredNomenclature(@PathVariable(value =
*/
@ApiOperation(value = "Get list of required nomenclature by campaign Id ")
@GetMapping(path = "/questionnaire/{id}/required-nomenclatures")
public ResponseEntity<Object> getListRequiredNomenclatureByQuestionnaireId(@PathVariable(value = "id") String id){
public ResponseEntity<List<String>> getListRequiredNomenclatureByQuestionnaireId(@PathVariable(value = "id") String id){
Optional<QuestionnaireModel> questionnaireOptional = questionnaireModelService.findById(id);
if (!questionnaireOptional.isPresent()) {
LOGGER.info("GET required-nomenclatures for questionnaire with id {} resulting in 404", id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Optional<Nomenclature> findById(String id) {
public List<String> findRequiredNomenclatureByQuestionnaire(Set<QuestionnaireModel> setQuestionnaireModel) {
return setQuestionnaireModel.parallelStream().map(QuestionnaireModel::getNomenclatures).collect(Collectors.toList())
.parallelStream().flatMap(Set::parallelStream).collect(Collectors.toList())
.parallelStream().distinct().map(Nomenclature::getLabel).collect(Collectors.toList());
.parallelStream().distinct().map(Nomenclature::getId).collect(Collectors.toList());
}

public List<String> findRequiredNomenclatureByCampaign(String campaignId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ public void initialize(ConfigurableApplicationContext configurableApplicationCon
.of("spring.data.mongodb.uri=" + mongoDBContainer.getReplicaSetUrl(),
"keycloak.auth-server-url=" + keycloak.getAuthServerUrl())
.applyTo(configurableApplicationContext.getEnvironment());
mongoDBContainer.start();
}
}

@AfterAll
public static void cleanUp() {
if(mongoDBContainer!=null) {
if(mongoDBContainer!=null && mongoDBContainer.isRunning()) {
mongoDBContainer.close();
}
if(keycloak!=null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ public void initialize(ConfigurableApplicationContext configurableApplicationCon
TestPropertyValues
.of("spring.data.mongodb.uri=" + mongoDBContainer.getReplicaSetUrl())
.applyTo(configurableApplicationContext.getEnvironment());
mongoDBContainer.start();
}
}

@AfterAll
public static void cleanUp() {
if(mongoDBContainer!=null) {
if(mongoDBContainer!=null && mongoDBContainer.isRunning()) {
mongoDBContainer.close();
}
if(mockServerClient!=null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ public void initialize(ConfigurableApplicationContext configurableApplicationCon
TestPropertyValues
.of("spring.data.mongodb.uri=" + mongoDBContainer.getReplicaSetUrl())
.applyTo(configurableApplicationContext.getEnvironment());
mongoDBContainer.start();
}
}

@AfterAll
public static void cleanUp() {
if(mongoDBContainer!=null) {
mongoDBContainer.stop();
if(mongoDBContainer!=null && mongoDBContainer.isRunning()) {
mongoDBContainer.close();
}
}
}

0 comments on commit e3b48b5

Please sign in to comment.