diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/Rule.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/Rule.java index a314a7f..fccd941 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/Rule.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/Rule.java @@ -26,7 +26,6 @@ package net.kemitix.checkstyle.ruleset.builder; import lombok.Getter; import lombok.Setter; -import lombok.ToString; import java.net.URI; import java.util.HashMap; @@ -37,7 +36,6 @@ import java.util.Map; * * @author Paul Campbell (pcampbell@kemitix.net) */ -@ToString @Setter @Getter public class Rule { @@ -85,5 +83,5 @@ public class Rule { /** * Configuration properties. */ - private Map properties = new HashMap<>(); + private final Map properties = new HashMap<>(); } diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/RuleTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/RuleTest.java new file mode 100644 index 0000000..8dd535c --- /dev/null +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/RuleTest.java @@ -0,0 +1,79 @@ +package net.kemitix.checkstyle.ruleset.builder; + +import lombok.val; +import org.assertj.core.api.SoftAssertions; +import org.junit.Before; +import org.junit.Test; + +import java.net.URI; + +/** + * Tests for {@link Rule}. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +public class RuleTest { + + private Rule rule; + + @Before + public void setUp() throws Exception { + rule = new Rule(); + } + + @Test + public void setAndGet() throws Exception { + //given + val name = "name"; + val parent = RuleParent.TREEWALKER; + val level = RuleLevel.LAYOUT; + val source = RuleSource.CHECKSTYLE; + val enabled = true; + val insuppressible = true; + val uri = URI.create("rule://name.md"); + val reason = "reason"; + val key = "key"; + val value = "value"; + //when + rule.setName(name); + rule.setParent(parent); + rule.setLevel(level); + rule.setSource(source); + rule.setEnabled(enabled); + rule.setInsuppressible(insuppressible); + rule.setUri(uri); + rule.setReason(reason); + rule.getProperties() + .put(key, value); + //then + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(rule.getName()) + .as("set/getName()") + .isEqualTo(name); + softly.assertThat(rule.getParent()) + .as("set/getParent()") + .isEqualTo(parent); + softly.assertThat(rule.getLevel()) + .as("set/getLevel()") + .isEqualTo(level); + softly.assertThat(rule.getSource()) + .as("set/getSource()") + .isEqualTo(source); + softly.assertThat(rule.isEnabled()) + .as("set/isEnabled()") + .isEqualTo(enabled); + softly.assertThat(rule.isInsuppressible()) + .as("set/isInsuppressible()") + .isEqualTo(insuppressible); + softly.assertThat(rule.getUri()) + .as("set/getUri()") + .isEqualTo(uri); + softly.assertThat(rule.getReason()) + .as("set/getReason()") + .isEqualTo(reason); + softly.assertThat(rule.getProperties()) + .as("getProperties()") + .containsEntry(key, value); + }); + } +}