Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit 4327697e authored by Jujube Orange's avatar Jujube Orange
Browse files

refactor(ws-rest): fix integration tests

parent 6ca6a26d
Pipeline #283778 failed with stages
in 8 minutes and 43 seconds
......@@ -2,10 +2,21 @@ package fr.gouv.clea.integrationtests.utils;
import lombok.experimental.UtilityClass;
import java.util.regex.Pattern;
@UtilityClass
public class CleaApiResponseParser {
private static final Pattern REPORT_MESSAGE_RESPONSE_PATTERN = Pattern.compile("(\\d+)/(\\d+) accepted visits");
public static int getRejectedVisits(final String message) {
return Integer.parseInt(message.replaceAll("[^0-9]+", " ").trim().split(" ")[1]);
final var matcher = REPORT_MESSAGE_RESPONSE_PATTERN.matcher(message);
if (!matcher.find()) {
throw new IllegalArgumentException(
String.format("message '%s' doesn't match pattern %s", message, REPORT_MESSAGE_RESPONSE_PATTERN));
}
final var accepted = Integer.parseInt(matcher.group(1));
final var total = Integer.parseInt(matcher.group(2));
return total - accepted;
}
}
package fr.gouv.clea.integrationtests.utils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.params.provider.Arguments.arguments;
class CleaApiResponseParserTest {
static Stream<Arguments> can_extract_rejected_visits_count() {
return Stream.of(
arguments("0/0 accepted visits", 0),
arguments("10/10 accepted visits", 0),
arguments("5/6 accepted visits", 1),
arguments("0/22 accepted visits", 22),
arguments("1/10 accepted visits", 9)
);
}
@ParameterizedTest
@MethodSource
void can_extract_rejected_visits_count(String message, int expectedRejectedCount) {
assertThat(CleaApiResponseParser.getRejectedVisits(message))
.isEqualTo(expectedRejectedCount);
}
@Test
void return_incoherent_result() {
assertThat(CleaApiResponseParser.getRejectedVisits("10/5 accepted visits"))
.isEqualTo(-5);
}
}
......@@ -4,7 +4,7 @@ services:
image: clea-ws-rest
build: clea-ws-rest
environment:
SPRING_PROFILES_ACTIVE: dev
SPRING_PROFILES_ACTIVE: dev,docker
SPRING_KAFKA_BOOTSTRAP_SERVERS: kafka:29092
CLEA_CONF_AUTHORIZATION_CHECK_ACTIVE: "false"
CLEA_WS_REST_LOG_FILE_PATH: /logs
......@@ -18,7 +18,7 @@ services:
image: clea-venue-consumer
build: clea-venue-consumer
environment:
SPRING_PROFILES_ACTIVE: dev
SPRING_PROFILES_ACTIVE: dev,docker
SPRING_KAFKA_BOOTSTRAP_SERVERS: kafka:29092
CLEA_VENUE_CONSUMER_LOG_FILE_PATH: /logs
CLEA_VENUE_CONSUMER_LOG_FILE_NAME: clea-venue-consumer
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment