Skip to content

Commit

Permalink
#814 added test for behaviour of adding descriptions and defaults to …
Browse files Browse the repository at this point in the history
…JSON schema
  • Loading branch information
Bramaten committed Feb 24, 2025
1 parent c2209dc commit e661991
Showing 1 changed file with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.buschmais.jqassistant.core.runtime.api.configuration;

import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

import com.buschmais.jqassistant.core.shared.aether.configuration.Plugin;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.networknt.schema.ValidationMessage;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -17,7 +19,7 @@ class JsonSchemaGeneratorTest {
private JsonNode schemaNode;

@BeforeEach
void generateSchema() throws IOException {
void generateSchema() {
schemaNode = JsonSchemaGenerator.generateSchema(Configuration.class);
}

Expand Down Expand Up @@ -45,4 +47,48 @@ void testInvalidYaml() throws Exception {
}
}

@Test
void testDescriptionsAndDefaults() {
ObjectNode pluginNode = JsonSchemaGenerator.generateSchema(Plugin.class);

// inner descriptions should not be available at the moment on outer level
assertThat(schemaNode.findValue("plugins")
.has("description")).isFalse();
assertThat(schemaNode.findValue("default-plugins")
.has("description")).isFalse();

// direct descriptions should be available
assertThat(schemaNode.findValue("skip")
.get("description")
.textValue()).isEqualTo("Skip execution of jQAssistant tasks/goals.");
assertThat(pluginNode.findValue("group-id")
.get("description")
.textValue()).isEqualTo("The groupId of the plugin.");
assertThat(pluginNode.findValue("classifier")
.get("description")
.textValue()).isEqualTo("The classifier of the plugin (optional).");
assertThat(pluginNode.findValue("artifact-id")
.get("description")
.textValue()).isEqualTo("The artifactId of the plugin.");
assertThat(pluginNode.findValues("type")
.get(11)
.get("description")
.textValue()).isEqualTo("The type (extension) of the plugin.");
assertThat(pluginNode.findValue("version")
.get("description")
.textValue()).isEqualTo("The version of the plugin.");
assertThat(pluginNode.findValue("exclusions")
.get("description")
.textValue()).isEqualTo("The exclusions of the plugin.");

// defaults should be available
assertThat(schemaNode.findValue("skip")
.get("default")
.textValue()).isEqualTo("false");
assertThat(pluginNode.findValues("type")
.get(11)
.get("default")
.textValue()).isEqualTo("jar");

}
}

0 comments on commit e661991

Please sign in to comment.