From 9909a74903614359033907d5b8e57c93b950aacf Mon Sep 17 00:00:00 2001 From: xstefank Date: Thu, 26 Mar 2020 17:38:23 +0100 Subject: [PATCH] Add TyrConfiguration and enable MP config in WebHookEndpoint --- .../java/org/jboss/tyr/check/SkipCheck.java | 10 ++-- .../org/jboss/tyr/check/TemplateChecker.java | 4 +- .../org/jboss/tyr/model/TyrConfiguration.java | 17 ++++++ .../{FormatConfig.java => FormatYaml.java} | 2 +- .../FormatElementVerification.java | 6 +-- .../RepositoryFormatVerification.java | 6 +-- .../jboss/tyr/verification/Verification.java | 6 +-- .../tyr/verification/VerificationHandler.java | 6 +-- .../jboss/tyr/webhook/WebHookEndpoint.java | 52 +++++++++++-------- .../tyr/whitelist/WhitelistProcessing.java | 8 +-- .../src/main/resources/application.properties | 0 .../test/java/org/jboss/tyr/TestUtils.java | 8 +-- .../org/jboss/tyr/check/SkipCheckTest.java | 42 +++++++-------- .../jboss/tyr/check/TemplateCheckerTest.java | 4 +- .../tyr/verification/VerificationsTest.java | 8 +-- 15 files changed, 101 insertions(+), 78 deletions(-) create mode 100644 tyr-runner/src/main/java/org/jboss/tyr/model/TyrConfiguration.java rename tyr-runner/src/main/java/org/jboss/tyr/model/yaml/{FormatConfig.java => FormatYaml.java} (97%) create mode 100644 tyr-runner/src/main/resources/application.properties diff --git a/tyr-runner/src/main/java/org/jboss/tyr/check/SkipCheck.java b/tyr-runner/src/main/java/org/jboss/tyr/check/SkipCheck.java index da878c9d..95d99b15 100644 --- a/tyr-runner/src/main/java/org/jboss/tyr/check/SkipCheck.java +++ b/tyr-runner/src/main/java/org/jboss/tyr/check/SkipCheck.java @@ -17,7 +17,7 @@ import org.jboss.tyr.InvalidPayloadException; import org.jboss.tyr.model.Utils; -import org.jboss.tyr.model.yaml.FormatConfig; +import org.jboss.tyr.model.yaml.FormatYaml; import org.jboss.tyr.model.yaml.RegexDefinition; import javax.json.JsonObject; @@ -26,14 +26,14 @@ public class SkipCheck { - public static boolean shouldSkip(JsonObject payload, FormatConfig config) throws InvalidPayloadException { + public static boolean shouldSkip(JsonObject payload, FormatYaml config) throws InvalidPayloadException { if (payload == null || config == null) { throw new IllegalArgumentException("Input arguments cannot be null"); } return skipByTitle(payload, config) || skipByCommit(payload, config) || skipByDescriptionFirstRow(payload, config); } - private static boolean skipByTitle(JsonObject payload, FormatConfig config) { + private static boolean skipByTitle(JsonObject payload, FormatYaml config) { Pattern titlePattern = config.getFormat().getSkipPatterns().getTitle(); if (titlePattern != null) { Matcher titleMatcher = titlePattern.matcher(payload.getJsonObject(Utils.PULL_REQUEST).getString(Utils.TITLE)); @@ -43,7 +43,7 @@ private static boolean skipByTitle(JsonObject payload, FormatConfig config) { } - private static boolean skipByCommit(JsonObject payload, FormatConfig config) throws InvalidPayloadException { + private static boolean skipByCommit(JsonObject payload, FormatYaml config) throws InvalidPayloadException { Pattern commitPattern = config.getFormat().getSkipPatterns().getCommit(); if (commitPattern != null) { RegexDefinition commitRegexDefinition = new RegexDefinition(); @@ -54,7 +54,7 @@ private static boolean skipByCommit(JsonObject payload, FormatConfig config) thr return false; } - private static boolean skipByDescriptionFirstRow(JsonObject payload, FormatConfig config) { + private static boolean skipByDescriptionFirstRow(JsonObject payload, FormatYaml config) { Pattern descriptionPattern = config.getFormat().getSkipPatterns().getDescription(); if (descriptionPattern != null) { String description = payload.getJsonObject(Utils.PULL_REQUEST).getString(Utils.BODY); diff --git a/tyr-runner/src/main/java/org/jboss/tyr/check/TemplateChecker.java b/tyr-runner/src/main/java/org/jboss/tyr/check/TemplateChecker.java index 6562d1b0..76976d2f 100644 --- a/tyr-runner/src/main/java/org/jboss/tyr/check/TemplateChecker.java +++ b/tyr-runner/src/main/java/org/jboss/tyr/check/TemplateChecker.java @@ -21,7 +21,7 @@ import org.jboss.tyr.model.AdditionalResourcesLoader; import org.jboss.tyr.model.Utils; import org.jboss.tyr.model.yaml.Format; -import org.jboss.tyr.model.yaml.FormatConfig; +import org.jboss.tyr.model.yaml.FormatYaml; import javax.json.JsonObject; import java.util.ArrayList; @@ -33,7 +33,7 @@ public class TemplateChecker { private List checks; - public TemplateChecker(FormatConfig config) { + public TemplateChecker(FormatYaml config) { if (config == null || config.getFormat() == null) { throw new IllegalArgumentException("Input argument cannot be null"); } diff --git a/tyr-runner/src/main/java/org/jboss/tyr/model/TyrConfiguration.java b/tyr-runner/src/main/java/org/jboss/tyr/model/TyrConfiguration.java new file mode 100644 index 00000000..19899ad0 --- /dev/null +++ b/tyr-runner/src/main/java/org/jboss/tyr/model/TyrConfiguration.java @@ -0,0 +1,17 @@ +package org.jboss.tyr.model; + +import io.quarkus.arc.config.ConfigProperties; +import org.eclipse.microprofile.config.inject.ConfigProperty; + +import java.util.Optional; + +@ConfigProperties(prefix = "tyr") +public interface TyrConfiguration { + + @ConfigProperty(name = "template.format.url") + Optional formatFileUrl(); + + @ConfigProperty(name = "template.format.file") + Optional configFileName(); + +} diff --git a/tyr-runner/src/main/java/org/jboss/tyr/model/yaml/FormatConfig.java b/tyr-runner/src/main/java/org/jboss/tyr/model/yaml/FormatYaml.java similarity index 97% rename from tyr-runner/src/main/java/org/jboss/tyr/model/yaml/FormatConfig.java rename to tyr-runner/src/main/java/org/jboss/tyr/model/yaml/FormatYaml.java index 5ea66f58..ed06a4b7 100644 --- a/tyr-runner/src/main/java/org/jboss/tyr/model/yaml/FormatConfig.java +++ b/tyr-runner/src/main/java/org/jboss/tyr/model/yaml/FormatYaml.java @@ -15,7 +15,7 @@ */ package org.jboss.tyr.model.yaml; -public class FormatConfig { +public class FormatYaml { private String repository; private String statusUrl; diff --git a/tyr-runner/src/main/java/org/jboss/tyr/verification/FormatElementVerification.java b/tyr-runner/src/main/java/org/jboss/tyr/verification/FormatElementVerification.java index 2346069f..070b9841 100644 --- a/tyr-runner/src/main/java/org/jboss/tyr/verification/FormatElementVerification.java +++ b/tyr-runner/src/main/java/org/jboss/tyr/verification/FormatElementVerification.java @@ -15,13 +15,13 @@ */ package org.jboss.tyr.verification; -import org.jboss.tyr.model.yaml.FormatConfig; +import org.jboss.tyr.model.yaml.FormatYaml; public class FormatElementVerification implements Verification { @Override - public void verify(FormatConfig formatConfig) throws InvalidConfigurationException { - if (formatConfig.getFormat() == null) + public void verify(FormatYaml formatYaml) throws InvalidConfigurationException { + if (formatYaml.getFormat() == null) throw new InvalidConfigurationException("Element 'format' is not specified"); } } diff --git a/tyr-runner/src/main/java/org/jboss/tyr/verification/RepositoryFormatVerification.java b/tyr-runner/src/main/java/org/jboss/tyr/verification/RepositoryFormatVerification.java index d36b45e2..f2f6718a 100644 --- a/tyr-runner/src/main/java/org/jboss/tyr/verification/RepositoryFormatVerification.java +++ b/tyr-runner/src/main/java/org/jboss/tyr/verification/RepositoryFormatVerification.java @@ -15,13 +15,13 @@ */ package org.jboss.tyr.verification; -import org.jboss.tyr.model.yaml.FormatConfig; +import org.jboss.tyr.model.yaml.FormatYaml; public class RepositoryFormatVerification implements Verification { @Override - public void verify(FormatConfig formatConfig) throws InvalidConfigurationException { - if (!formatConfig.getRepository().matches("^[a-zA-Z0-9_]*/[a-zA-Z0-9_-]*$")) + public void verify(FormatYaml formatYaml) throws InvalidConfigurationException { + if (!formatYaml.getRepository().matches("^[a-zA-Z0-9_]*/[a-zA-Z0-9_-]*$")) throw new InvalidConfigurationException("Wrong repository format in configuration file"); } } diff --git a/tyr-runner/src/main/java/org/jboss/tyr/verification/Verification.java b/tyr-runner/src/main/java/org/jboss/tyr/verification/Verification.java index 772c8f0e..b958571f 100644 --- a/tyr-runner/src/main/java/org/jboss/tyr/verification/Verification.java +++ b/tyr-runner/src/main/java/org/jboss/tyr/verification/Verification.java @@ -15,7 +15,7 @@ */ package org.jboss.tyr.verification; -import org.jboss.tyr.model.yaml.FormatConfig; +import org.jboss.tyr.model.yaml.FormatYaml; /** * Verifies structure of the format.yaml configuration file @@ -25,8 +25,8 @@ public interface Verification { /** * Verify the provided format.yaml structure * - * @param formatConfig object representing format.yaml file + * @param formatYaml object representing format.yaml file * @throws InvalidConfigurationException if any validation error is encountered */ - void verify(FormatConfig formatConfig) throws InvalidConfigurationException; + void verify(FormatYaml formatYaml) throws InvalidConfigurationException; } diff --git a/tyr-runner/src/main/java/org/jboss/tyr/verification/VerificationHandler.java b/tyr-runner/src/main/java/org/jboss/tyr/verification/VerificationHandler.java index 2a5d4caf..cd6bc63e 100644 --- a/tyr-runner/src/main/java/org/jboss/tyr/verification/VerificationHandler.java +++ b/tyr-runner/src/main/java/org/jboss/tyr/verification/VerificationHandler.java @@ -15,7 +15,7 @@ */ package org.jboss.tyr.verification; -import org.jboss.tyr.model.yaml.FormatConfig; +import org.jboss.tyr.model.yaml.FormatYaml; import java.util.ArrayList; import java.util.List; @@ -24,9 +24,9 @@ public class VerificationHandler { private static final List verifications = registerVerifications(); - public static void verifyConfiguration(FormatConfig formatConfig) throws InvalidConfigurationException { + public static void verifyConfiguration(FormatYaml formatYaml) throws InvalidConfigurationException { for (Verification verification : verifications) { - verification.verify(formatConfig); + verification.verify(formatYaml); } } diff --git a/tyr-runner/src/main/java/org/jboss/tyr/webhook/WebHookEndpoint.java b/tyr-runner/src/main/java/org/jboss/tyr/webhook/WebHookEndpoint.java index a8c3c0a1..64366f00 100644 --- a/tyr-runner/src/main/java/org/jboss/tyr/webhook/WebHookEndpoint.java +++ b/tyr-runner/src/main/java/org/jboss/tyr/webhook/WebHookEndpoint.java @@ -22,12 +22,16 @@ import org.jboss.tyr.check.SkipCheck; import org.jboss.tyr.check.TemplateChecker; import org.jboss.tyr.model.CommitStatus; +import org.jboss.tyr.model.TyrConfiguration; import org.jboss.tyr.model.Utils; -import org.jboss.tyr.model.yaml.FormatConfig; +import org.jboss.tyr.model.yaml.FormatYaml; import org.jboss.tyr.verification.InvalidConfigurationException; import org.jboss.tyr.verification.VerificationHandler; import org.jboss.tyr.whitelist.WhitelistProcessing; +import javax.annotation.PostConstruct; +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; import javax.json.JsonObject; import javax.ws.rs.Consumes; import javax.ws.rs.POST; @@ -37,16 +41,23 @@ import java.io.IOException; import java.net.URL; -import static org.jboss.tyr.model.Utils.TEMPLATE_FORMAT_FILE; - @Path("/") +@ApplicationScoped public class WebHookEndpoint { - private static final FormatConfig config = readConfig(); - private static final WhitelistProcessing whitelistProcessing = - WhitelistProcessing.IS_WHITELISTING_ENABLED ? new WhitelistProcessing(config) : null; + @Inject + TyrConfiguration configuration; + + private FormatYaml format; + private WhitelistProcessing whitelistProcessing; + private TemplateChecker templateChecker; - private TemplateChecker templateChecker = new TemplateChecker(config); + @PostConstruct + public void init() { + format = readConfig(); + whitelistProcessing = WhitelistProcessing.IS_WHITELISTING_ENABLED ? new WhitelistProcessing(format) : null; + templateChecker = new TemplateChecker(format); + } @POST @Path("/pull-request") @@ -59,36 +70,31 @@ public void processRequest(JsonObject payload) throws InvalidPayloadException { } } - private static FormatConfig readConfig() { + private FormatYaml readConfig() { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); - FormatConfig formatConfig; + FormatYaml formatYaml; try { - URL formatFileUrl = Utils.getFormatUrl(); - if (formatFileUrl != null) - formatConfig = mapper.readValue(formatFileUrl.openStream(), FormatConfig.class); + if (configuration.formatFileUrl().isPresent()) + formatYaml = mapper.readValue(new URL(configuration.formatFileUrl().get()).openStream(), FormatYaml.class); else { - String configFileName = System.getProperty(TEMPLATE_FORMAT_FILE); - if (configFileName == null) { - configFileName = Utils.getConfigDirectory() + "/format.yaml"; - } - File configFile = new File(configFileName); - formatConfig = mapper.readValue(configFile, FormatConfig.class); + File configFile = new File(configuration.configFileName().orElse(Utils.getConfigDirectory() + "/format.yaml")); + formatYaml = mapper.readValue(configFile, FormatYaml.class); } - VerificationHandler.verifyConfiguration(formatConfig); - return formatConfig; + VerificationHandler.verifyConfiguration(formatYaml); + return formatYaml; } catch (IOException | InvalidConfigurationException e) { throw new IllegalArgumentException("Cannot load configuration file", e); } } private void processPullRequest(JsonObject prPayload) throws InvalidPayloadException { - if (!SkipCheck.shouldSkip(prPayload, config)) { + if (!SkipCheck.shouldSkip(prPayload, format)) { String errorMessage = templateChecker.checkPR(prPayload); if (errorMessage != null) { - GitHubAPI.updateCommitStatus(config.getRepository(), + GitHubAPI.updateCommitStatus(format.getRepository(), prPayload.getJsonObject(Utils.PULL_REQUEST).getJsonObject(Utils.HEAD).getString(Utils.SHA), errorMessage.isEmpty() ? CommitStatus.SUCCESS : CommitStatus.ERROR, - config.getStatusUrl(), + format.getStatusUrl(), errorMessage.isEmpty() ? "valid" : errorMessage, "PR format"); } } diff --git a/tyr-runner/src/main/java/org/jboss/tyr/whitelist/WhitelistProcessing.java b/tyr-runner/src/main/java/org/jboss/tyr/whitelist/WhitelistProcessing.java index 756ec82a..3c71742e 100644 --- a/tyr-runner/src/main/java/org/jboss/tyr/whitelist/WhitelistProcessing.java +++ b/tyr-runner/src/main/java/org/jboss/tyr/whitelist/WhitelistProcessing.java @@ -25,7 +25,7 @@ import org.jboss.tyr.model.PersistentList; import org.jboss.tyr.model.TyrProperties; import org.jboss.tyr.model.Utils; -import org.jboss.tyr.model.yaml.FormatConfig; +import org.jboss.tyr.model.yaml.FormatYaml; import javax.json.JsonObject; import java.util.ArrayList; @@ -45,7 +45,7 @@ public class WhitelistProcessing implements CIOperations { private final List commands; private final List continuousIntegrations; - public WhitelistProcessing(FormatConfig config) { + public WhitelistProcessing(FormatYaml config) { String dirName = Utils.getConfigDirectory(); userList = new PersistentList(dirName, Utils.USERLIST_FILE_NAME); adminList = new PersistentList(dirName, Utils.ADMINLIST_FILE_NAME); @@ -120,7 +120,7 @@ public boolean addUserToUserList(String username) { return userList.add(username); } - private List getCommands(FormatConfig config) { + private List getCommands(FormatYaml config) { List commands = new ArrayList<>(); Map regexMap = config.getFormat().getCommands(); @@ -141,7 +141,7 @@ private List getCommands(FormatConfig config) { return commands; } - private List loadCIs(FormatConfig config) { + private List loadCIs(FormatYaml config) { List continuousIntegrations = new ArrayList<>(); List CIConfigList = config.getFormat().getCI(); diff --git a/tyr-runner/src/main/resources/application.properties b/tyr-runner/src/main/resources/application.properties new file mode 100644 index 00000000..e69de29b diff --git a/tyr-runner/src/test/java/org/jboss/tyr/TestUtils.java b/tyr-runner/src/test/java/org/jboss/tyr/TestUtils.java index 620596c9..629ddd6e 100644 --- a/tyr-runner/src/test/java/org/jboss/tyr/TestUtils.java +++ b/tyr-runner/src/test/java/org/jboss/tyr/TestUtils.java @@ -17,7 +17,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import org.jboss.tyr.model.yaml.FormatConfig; +import org.jboss.tyr.model.yaml.FormatYaml; import javax.json.Json; import javax.json.JsonArray; @@ -50,13 +50,13 @@ public class TestUtils { public static final String READ_TOKEN = "readToken"; public static final String GET_JSON_WITH_COMMITS = "getCommitsJSON"; - public static final FormatConfig FORMAT_CONFIG = loadFormatFromYamlFile(YAML_DIR + "/testTemplate.yaml"); + public static final FormatYaml FORMAT_CONFIG = loadFormatFromYamlFile(YAML_DIR + "/testTemplate.yaml"); public static final Path TEST_CONFIG_PATH = getFilePath("testConfig.properties"); - public static FormatConfig loadFormatFromYamlFile(String fileName) { + public static FormatYaml loadFormatFromYamlFile(String fileName) { try { File file = getFile(fileName); - return new ObjectMapper(new YAMLFactory()).readValue(file, FormatConfig.class); + return new ObjectMapper(new YAMLFactory()).readValue(file, FormatYaml.class); } catch (IOException e) { throw new RuntimeException("Cannot load file " + fileName); } diff --git a/tyr-runner/src/test/java/org/jboss/tyr/check/SkipCheckTest.java b/tyr-runner/src/test/java/org/jboss/tyr/check/SkipCheckTest.java index 5b82649d..41d97201 100644 --- a/tyr-runner/src/test/java/org/jboss/tyr/check/SkipCheckTest.java +++ b/tyr-runner/src/test/java/org/jboss/tyr/check/SkipCheckTest.java @@ -19,7 +19,7 @@ import org.jboss.tyr.TestUtils; import org.jboss.tyr.api.GitHubAPI; import org.jboss.tyr.model.yaml.Format; -import org.jboss.tyr.model.yaml.FormatConfig; +import org.jboss.tyr.model.yaml.FormatYaml; import org.jboss.tyr.model.yaml.SkipPatterns; import org.junit.Assert; import org.junit.Before; @@ -38,7 +38,7 @@ @PrepareForTest(GitHubAPI.class) public class SkipCheckTest { - private static FormatConfig formatConfig; + private static FormatYaml formatYaml; private SkipPatterns skipPatterns; @Before @@ -55,69 +55,69 @@ public void testNullConfigParameter() throws InvalidPayloadException { @Test (expected=IllegalArgumentException.class) public void testNullPayloadParameter() throws InvalidPayloadException { - SkipCheck.shouldSkip(null, formatConfig); + SkipCheck.shouldSkip(null, formatYaml); } @Test public void testSkipByTitleRegexMatch() throws InvalidPayloadException { skipPatterns.setTitle(Pattern.compile("Test PR")); - formatConfig = setUpFormatConfig(skipPatterns); + formatYaml = setUpFormatConfig(skipPatterns); - Assert.assertTrue("Method cannot match valid title regex", SkipCheck.shouldSkip(TestUtils.TEST_PAYLOAD, formatConfig)); + Assert.assertTrue("Method cannot match valid title regex", SkipCheck.shouldSkip(TestUtils.TEST_PAYLOAD, formatYaml)); } @Test public void testSkipByTitleRegexNonMatch() throws InvalidPayloadException { skipPatterns.setTitle(Pattern.compile("can't.*match.*this")); - formatConfig = setUpFormatConfig(skipPatterns); + formatYaml = setUpFormatConfig(skipPatterns); - Assert.assertFalse("Method matched invalid title regex",SkipCheck.shouldSkip(TestUtils.TEST_PAYLOAD, formatConfig)); + Assert.assertFalse("Method matched invalid title regex",SkipCheck.shouldSkip(TestUtils.TEST_PAYLOAD, formatYaml)); } @Test public void testSkipByCommitRegexMatch() throws InvalidPayloadException { skipPatterns.setCommit(Pattern.compile("Test commit")); - formatConfig = setUpFormatConfig(skipPatterns); + formatYaml = setUpFormatConfig(skipPatterns); - Assert.assertTrue("Method cannot match valid commit regex",SkipCheck.shouldSkip(TestUtils.TEST_PAYLOAD, formatConfig)); + Assert.assertTrue("Method cannot match valid commit regex",SkipCheck.shouldSkip(TestUtils.TEST_PAYLOAD, formatYaml)); } @Test public void testSkipByCommitRegexNonMatch() throws InvalidPayloadException { skipPatterns.setCommit(Pattern.compile("can't.*match.*this")); - formatConfig = setUpFormatConfig(skipPatterns); + formatYaml = setUpFormatConfig(skipPatterns); - Assert.assertFalse("Method matched invalid commit regex",SkipCheck.shouldSkip(TestUtils.TEST_PAYLOAD, formatConfig)); + Assert.assertFalse("Method matched invalid commit regex",SkipCheck.shouldSkip(TestUtils.TEST_PAYLOAD, formatYaml)); } @Test public void testSkipByPullRequestDescriptionRegexMatch() throws InvalidPayloadException { skipPatterns.setDescription(Pattern.compile("Test description")); - formatConfig = setUpFormatConfig(skipPatterns); + formatYaml = setUpFormatConfig(skipPatterns); - Assert.assertTrue("Method cannot match valid description regex",SkipCheck.shouldSkip(TestUtils.TEST_PAYLOAD, formatConfig)); + Assert.assertTrue("Method cannot match valid description regex",SkipCheck.shouldSkip(TestUtils.TEST_PAYLOAD, formatYaml)); } @Test public void testSkipByPullRequestDescriptionRegexNonMatch() throws InvalidPayloadException { skipPatterns.setDescription(Pattern.compile("can't.*match.*this")); - formatConfig = setUpFormatConfig(skipPatterns); + formatYaml = setUpFormatConfig(skipPatterns); - Assert.assertFalse("Method matched invalid description regex",SkipCheck.shouldSkip(TestUtils.TEST_PAYLOAD, formatConfig)); + Assert.assertFalse("Method matched invalid description regex",SkipCheck.shouldSkip(TestUtils.TEST_PAYLOAD, formatYaml)); } @Test public void testShouldSkipEmptySkipPatterns() throws InvalidPayloadException { - formatConfig = setUpFormatConfig(skipPatterns); + formatYaml = setUpFormatConfig(skipPatterns); - Assert.assertFalse("Invalid result after empty skipping patterns",SkipCheck.shouldSkip(TestUtils.TEST_PAYLOAD, formatConfig)); + Assert.assertFalse("Invalid result after empty skipping patterns",SkipCheck.shouldSkip(TestUtils.TEST_PAYLOAD, formatYaml)); } - private static FormatConfig setUpFormatConfig(SkipPatterns testSkipPatterns) { + private static FormatYaml setUpFormatConfig(SkipPatterns testSkipPatterns) { Format testFormat = new Format(); testFormat.setSkipPatterns(testSkipPatterns); - FormatConfig testFormatConfig = new FormatConfig(); - testFormatConfig.setFormat(testFormat); - return testFormatConfig; + FormatYaml testFormatYaml = new FormatYaml(); + testFormatYaml.setFormat(testFormat); + return testFormatYaml; } } diff --git a/tyr-runner/src/test/java/org/jboss/tyr/check/TemplateCheckerTest.java b/tyr-runner/src/test/java/org/jboss/tyr/check/TemplateCheckerTest.java index b2a086f7..25e84e84 100644 --- a/tyr-runner/src/test/java/org/jboss/tyr/check/TemplateCheckerTest.java +++ b/tyr-runner/src/test/java/org/jboss/tyr/check/TemplateCheckerTest.java @@ -15,7 +15,7 @@ */ package org.jboss.tyr.check; -import org.jboss.tyr.model.yaml.FormatConfig; +import org.jboss.tyr.model.yaml.FormatYaml; import org.junit.Test; public class TemplateCheckerTest { @@ -27,7 +27,7 @@ public void testNullConfigParameter() { @Test(expected=IllegalArgumentException.class) public void testNullFormatParameter() { - FormatConfig testConfig = new FormatConfig(); + FormatYaml testConfig = new FormatYaml(); testConfig.setFormat(null); new TemplateChecker(testConfig); } diff --git a/tyr-runner/src/test/java/org/jboss/tyr/verification/VerificationsTest.java b/tyr-runner/src/test/java/org/jboss/tyr/verification/VerificationsTest.java index 03c1d3af..61cae64e 100644 --- a/tyr-runner/src/test/java/org/jboss/tyr/verification/VerificationsTest.java +++ b/tyr-runner/src/test/java/org/jboss/tyr/verification/VerificationsTest.java @@ -15,7 +15,7 @@ */ package org.jboss.tyr.verification; -import org.jboss.tyr.model.yaml.FormatConfig; +import org.jboss.tyr.model.yaml.FormatYaml; import org.junit.BeforeClass; import org.junit.Test; @@ -25,11 +25,11 @@ public class VerificationsTest { - private static FormatConfig badFormatConfig; + private static FormatYaml badFormatYaml; @BeforeClass public static void beforeClass() { - badFormatConfig = loadFormatFromYamlFile(YAML_DIR + "/wrongTemplate.yaml"); + badFormatYaml = loadFormatFromYamlFile(YAML_DIR + "/wrongTemplate.yaml"); } @Test @@ -39,7 +39,7 @@ public void testReadValidFormatConfiguration() throws InvalidConfigurationExcept @Test(expected = InvalidConfigurationException.class) public void testReadInvalidFormatConfiguration() throws InvalidConfigurationException { - VerificationHandler.verifyConfiguration(badFormatConfig); + VerificationHandler.verifyConfiguration(badFormatYaml); } @Test(expected = NullPointerException.class)