From 4b64d3dc08123542bedecd402f74e8c9f12f7ed5 Mon Sep 17 00:00:00 2001 From: Betty Becuwe Date: Wed, 11 Sep 2024 16:21:06 +0200 Subject: [PATCH] feat: add endpoint to get ongoing campaigns by type (V1, V2 or V3) --- .../metadata/controller/CampaignController.java | 2 +- .../metadata/util/ParamValidator.java | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/fr/insee/survey/datacollectionmanagement/metadata/controller/CampaignController.java b/src/main/java/fr/insee/survey/datacollectionmanagement/metadata/controller/CampaignController.java index 637ce581..082cb6c7 100644 --- a/src/main/java/fr/insee/survey/datacollectionmanagement/metadata/controller/CampaignController.java +++ b/src/main/java/fr/insee/survey/datacollectionmanagement/metadata/controller/CampaignController.java @@ -234,7 +234,7 @@ private CampaignOngoingDto convertToCampaignOngoingDto(Campaign campaign) { } private boolean isCampaignInType(Campaign c, String campaignType) { - if (campaignType.isEmpty()) + if (StringUtils.isEmpty(campaignType)) return true; if (campaignType.equalsIgnoreCase(V3.name())) return parametersService.findSuitableParameterValue(c, Parameters.ParameterEnum.URL_TYPE).equalsIgnoreCase(campaignType) diff --git a/src/main/java/fr/insee/survey/datacollectionmanagement/metadata/util/ParamValidator.java b/src/main/java/fr/insee/survey/datacollectionmanagement/metadata/util/ParamValidator.java index 47644d67..7f962058 100644 --- a/src/main/java/fr/insee/survey/datacollectionmanagement/metadata/util/ParamValidator.java +++ b/src/main/java/fr/insee/survey/datacollectionmanagement/metadata/util/ParamValidator.java @@ -13,18 +13,21 @@ public class ParamValidator { + private ParamValidator() { + throw new IllegalStateException("Validation class"); + } public static void validateParams(ParamsDto paramsDto) { if (paramsDto.getParamId().equalsIgnoreCase(Parameters.ParameterEnum.URL_TYPE.name()) && Arrays.stream(UrlTypeEnum.values()).noneMatch(p -> p.name().equals(paramsDto.getParamValue()))) { - throw new NotMatchException(String.format("Only %s are valid values for URL_TYPE", Arrays.stream(UrlTypeEnum.values()).map(item -> item.name()) + throw new NotMatchException(String.format("Only %s are valid values for URL_TYPE", Arrays.stream(UrlTypeEnum.values()).map(Enum::name) .collect(joining(" ")))); } if (paramsDto.getParamId().equalsIgnoreCase(Parameters.ParameterEnum.URL_REDIRECTION.name()) && Arrays.stream(UrlRedirectionEnum.values()).noneMatch(p -> p.name().equals(paramsDto.getParamValue()))) { - throw new NotMatchException(String.format("Only %s are valid values for URL_REDIRECTION", Arrays.stream(UrlRedirectionEnum.values()).map(item -> item.name()) + throw new NotMatchException(String.format("Only %s are valid values for URL_REDIRECTION", Arrays.stream(UrlRedirectionEnum.values()).map(Enum::name) .collect(joining(" ")))); } if (paramsDto.getParamId().equalsIgnoreCase(Parameters.ParameterEnum.MAIL_ASSISTANCE.name())