builder:RuleTest: added
Rule: * remove redundant @ToString * prevent creation of setProperties()
This commit is contained in:
parent
9b3f0869ea
commit
53586a7ffd
2 changed files with 80 additions and 3 deletions
|
@ -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<String, String> properties = new HashMap<>();
|
||||
private final Map<String, String> properties = new HashMap<>();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue