• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.networknt.schema;
2 
3 import com.fasterxml.jackson.databind.JsonNode;
4 import org.junit.jupiter.api.Assertions;
5 import org.junit.jupiter.api.Test;
6 
7 import java.util.List;
8 import java.util.Locale;
9 
10 import static java.util.stream.Collectors.toList;
11 
12 class Issue898Test extends BaseJsonSchemaValidatorTest {
13 
14     @Test
testMessagesWithSingleQuotes()15     void testMessagesWithSingleQuotes() throws Exception {
16         SchemaValidatorsConfig config = new SchemaValidatorsConfig();
17         config.setLocale(Locale.FRENCH);
18 
19         JsonSchema schema = getJsonSchemaFromClasspath("schema/issue898.json", SpecVersion.VersionFlag.V202012, config);
20         JsonNode node = getJsonNodeFromClasspath("data/issue898.json");
21 
22         List<String> messages = schema.validate(node).stream()
23                 .map(ValidationMessage::getMessage)
24                 .collect(toList());
25 
26         Assertions.assertEquals(2, messages.size());
27         Assertions.assertEquals("$.foo: n'a pas de valeur dans l'énumération [foo1, foo2]", messages.get(0));
28         Assertions.assertEquals("$.bar: ne correspond pas au modèle d'expression régulière (bar)+", messages.get(1));
29     }
30 
31 }
32