Search in sources :

Example 1 with Option

use of com.github.victools.jsonschema.generator.Option in project jsonschema-generator by victools.

the class AttributeCollectorTest method testSetEnum_twoEnumValues.

@Test
@Parameters({ "default", "ENUM_KEYWORD_FOR_SINGLE_VALUES" })
public void testSetEnum_twoEnumValues(String optionMode) {
    Option[] options = optionMode.equals("default") ? new Option[0] : new Option[] { Option.ENUM_KEYWORD_FOR_SINGLE_VALUES };
    this.collector.setEnum(this.definitionNode, Arrays.asList("A", "B"), this.generateContext(SchemaVersion.DRAFT_2019_09, options));
    JsonNode enumNode = this.definitionNode.get(SchemaKeyword.TAG_ENUM.forVersion(SchemaVersion.DRAFT_2019_09));
    Assert.assertNotNull(enumNode);
    Assert.assertTrue(enumNode.isArray());
    Assert.assertEquals(2, enumNode.size());
    JsonNode firstValueItem = enumNode.get(0);
    Assert.assertNotNull(firstValueItem);
    Assert.assertTrue(firstValueItem.isTextual());
    Assert.assertEquals("A", firstValueItem.textValue());
    JsonNode secondValueItem = enumNode.get(1);
    Assert.assertNotNull(secondValueItem);
    Assert.assertTrue(secondValueItem.isTextual());
    Assert.assertEquals("B", secondValueItem.textValue());
}
Also used : Option(com.github.victools.jsonschema.generator.Option) JsonNode(com.fasterxml.jackson.databind.JsonNode) Parameters(junitparams.Parameters) Test(org.junit.Test)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Option (com.github.victools.jsonschema.generator.Option)1 Parameters (junitparams.Parameters)1 Test (org.junit.Test)1