Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
meiswjn committed Oct 9, 2023
1 parent a787b81 commit 2087d71
Showing 1 changed file with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void shouldHaveNoParsersWhenCreated() {
}

@Test
void shouldSaveConfigurationIfParsersAreAdded() {
void shouldSaveConfigurationIfParsersAreSet() {
GlobalConfigurationFacade facade = mock(GlobalConfigurationFacade.class);

ParserConfiguration configuration = new ParserConfiguration(facade);
Expand Down Expand Up @@ -68,4 +68,43 @@ void shouldWarnUserIfConsoleLogScanningPermittedIsSet() {
final FormValidation actualTrue = configuration.doCheckConsoleLogScanningPermitted(true);
assertThat(actualTrue.kind).isEqualTo(FormValidation.Kind.WARNING);
}
@Test

Check warning on line 71 in plugin/src/test/java/io/jenkins/plugins/analysis/warnings/groovy/ParserConfigurationTest.java

View check run for this annotation

ci.jenkins.io / CheckStyle

EmptyLineSeparatorCheck

NORMAL: 'METHOD_DEF' should be separated from previous line.
Raw output
<p>Since Checkstyle 5.8</p><p> Checks for empty line separators after header, package, all import declarations, fields, constructors, methods, nested classes, static initializers and instance initializers. </p><p> ATTENTION: empty line separator is required between AST siblings, not after line where token is found. </p>
void shouldSaveConfigurationIfParserIsAdded() {
GlobalConfigurationFacade facade = mock(GlobalConfigurationFacade.class);
GroovyParser test_parser = new GroovyParser("1", "", "", "", "");

Check warning on line 74 in plugin/src/test/java/io/jenkins/plugins/analysis/warnings/groovy/ParserConfigurationTest.java

View check run for this annotation

ci.jenkins.io / CheckStyle

LocalVariableNameCheck

NORMAL: Name 'test_parser' must match pattern '^[a-z][a-zA-Z0-9]*$'.
Raw output
<p> Checks that local, non-<code>final</code> variable names conform to a format specified by the format property. A catch parameter is considered to be a local variable. </p>

Check warning on line 74 in plugin/src/test/java/io/jenkins/plugins/analysis/warnings/groovy/ParserConfigurationTest.java

View check run for this annotation

ci.jenkins.io / PMD

LocalVariableNamingConventions

HIGH: The local variable name 'test_parser' doesn't match '[a-z][a-zA-Z0-9]*'.
Raw output
Configurable naming conventions for local variable declarations and other locally-scoped variables. This rule reports variable declarations which do not match the regex that applies to their specific kind (e.g. final variable, or catch-clause parameter). Each regex can be configured through properties. By default this rule uses the standard Java naming convention (Camel case). <pre> <code> class Foo { void bar() { int localVariable = 1; // This is in camel case, so it&#x27;s ok int local_variable = 1; // This will be reported unless you change the regex final int i_var = 1; // final local variables can be configured separately try { foo(); } catch (IllegalArgumentException e_illegal) { // exception block parameters can be configured separately } } } </code> </pre> <a href="https://pmd.github.io/pmd-6.55.0/pmd_rules_java_codestyle.html#localvariablenamingconventions"> See PMD documentation. </a>

ParserConfiguration configuration = new ParserConfiguration(facade);
configuration.addParser(test_parser);

verify(facade).save();

Check warning on line 79 in plugin/src/test/java/io/jenkins/plugins/analysis/warnings/groovy/ParserConfigurationTest.java

View check run for this annotation

ci.jenkins.io / CPD

CPD

LOW: Found duplicated code.
Raw output
<pre><code>void shouldSaveConfigurationIfParserIsAdded() { GlobalConfigurationFacade facade &#61; mock(GlobalConfigurationFacade.class); GroovyParser test_parser &#61; new GroovyParser(&#34;1&#34;, &#34;&#34;, &#34;&#34;, &#34;&#34;, &#34;&#34;); ParserConfiguration configuration &#61; new ParserConfiguration(facade); configuration.addParser(test_parser); verify(facade).save();</code></pre>
assertThat(configuration.getParsers().contains(test_parser));
}
@Test

Check warning on line 82 in plugin/src/test/java/io/jenkins/plugins/analysis/warnings/groovy/ParserConfigurationTest.java

View check run for this annotation

ci.jenkins.io / CheckStyle

EmptyLineSeparatorCheck

NORMAL: 'METHOD_DEF' should be separated from previous line.
Raw output
<p>Since Checkstyle 5.8</p><p> Checks for empty line separators after header, package, all import declarations, fields, constructors, methods, nested classes, static initializers and instance initializers. </p><p> ATTENTION: empty line separator is required between AST siblings, not after line where token is found. </p>
void shouldThrowIfParserExists() {
GlobalConfigurationFacade facade = mock(GlobalConfigurationFacade.class);
GroovyParser test_parser = new GroovyParser("1", "", "", "", "");

Check warning on line 85 in plugin/src/test/java/io/jenkins/plugins/analysis/warnings/groovy/ParserConfigurationTest.java

View check run for this annotation

ci.jenkins.io / CheckStyle

LocalVariableNameCheck

NORMAL: Name 'test_parser' must match pattern '^[a-z][a-zA-Z0-9]*$'.
Raw output
<p> Checks that local, non-<code>final</code> variable names conform to a format specified by the format property. A catch parameter is considered to be a local variable. </p>

Check warning on line 85 in plugin/src/test/java/io/jenkins/plugins/analysis/warnings/groovy/ParserConfigurationTest.java

View check run for this annotation

ci.jenkins.io / PMD

LocalVariableNamingConventions

HIGH: The local variable name 'test_parser' doesn't match '[a-z][a-zA-Z0-9]*'.
Raw output
Configurable naming conventions for local variable declarations and other locally-scoped variables. This rule reports variable declarations which do not match the regex that applies to their specific kind (e.g. final variable, or catch-clause parameter). Each regex can be configured through properties. By default this rule uses the standard Java naming convention (Camel case). <pre> <code> class Foo { void bar() { int localVariable = 1; // This is in camel case, so it&#x27;s ok int local_variable = 1; // This will be reported unless you change the regex final int i_var = 1; // final local variables can be configured separately try { foo(); } catch (IllegalArgumentException e_illegal) { // exception block parameters can be configured separately } } } </code> </pre> <a href="https://pmd.github.io/pmd-6.55.0/pmd_rules_java_codestyle.html#localvariablenamingconventions"> See PMD documentation. </a>

ParserConfiguration configuration = new ParserConfiguration(facade);
configuration.addParser(test_parser);
verify(facade).save();

Check warning on line 90 in plugin/src/test/java/io/jenkins/plugins/analysis/warnings/groovy/ParserConfigurationTest.java

View check run for this annotation

ci.jenkins.io / CPD

CPD

LOW: Found duplicated code.
Raw output
<pre><code>void shouldSaveConfigurationIfParserIsAdded() { GlobalConfigurationFacade facade &#61; mock(GlobalConfigurationFacade.class); GroovyParser test_parser &#61; new GroovyParser(&#34;1&#34;, &#34;&#34;, &#34;&#34;, &#34;&#34;, &#34;&#34;); ParserConfiguration configuration &#61; new ParserConfiguration(facade); configuration.addParser(test_parser); verify(facade).save();</code></pre>
assertThatIllegalArgumentException().isThrownBy(() -> configuration.addParser(test_parser));
}
@Test

Check warning on line 93 in plugin/src/test/java/io/jenkins/plugins/analysis/warnings/groovy/ParserConfigurationTest.java

View check run for this annotation

ci.jenkins.io / CheckStyle

EmptyLineSeparatorCheck

NORMAL: 'METHOD_DEF' should be separated from previous line.
Raw output
<p>Since Checkstyle 5.8</p><p> Checks for empty line separators after header, package, all import declarations, fields, constructors, methods, nested classes, static initializers and instance initializers. </p><p> ATTENTION: empty line separator is required between AST siblings, not after line where token is found. </p>
void deleteShouldRemoveOnlySpecifiedParser() {
GlobalConfigurationFacade facade = mock(GlobalConfigurationFacade.class);
GroovyParser first_test_parser = new GroovyParser("1", "", "", "", "");

Check warning on line 96 in plugin/src/test/java/io/jenkins/plugins/analysis/warnings/groovy/ParserConfigurationTest.java

View check run for this annotation

ci.jenkins.io / CheckStyle

LocalVariableNameCheck

NORMAL: Name 'first_test_parser' must match pattern '^[a-z][a-zA-Z0-9]*$'.
Raw output
<p> Checks that local, non-<code>final</code> variable names conform to a format specified by the format property. A catch parameter is considered to be a local variable. </p>

Check warning on line 96 in plugin/src/test/java/io/jenkins/plugins/analysis/warnings/groovy/ParserConfigurationTest.java

View check run for this annotation

ci.jenkins.io / PMD

LocalVariableNamingConventions

HIGH: The local variable name 'first_test_parser' doesn't match '[a-z][a-zA-Z0-9]*'.
Raw output
Configurable naming conventions for local variable declarations and other locally-scoped variables. This rule reports variable declarations which do not match the regex that applies to their specific kind (e.g. final variable, or catch-clause parameter). Each regex can be configured through properties. By default this rule uses the standard Java naming convention (Camel case). <pre> <code> class Foo { void bar() { int localVariable = 1; // This is in camel case, so it&#x27;s ok int local_variable = 1; // This will be reported unless you change the regex final int i_var = 1; // final local variables can be configured separately try { foo(); } catch (IllegalArgumentException e_illegal) { // exception block parameters can be configured separately } } } </code> </pre> <a href="https://pmd.github.io/pmd-6.55.0/pmd_rules_java_codestyle.html#localvariablenamingconventions"> See PMD documentation. </a>
GroovyParser second_test_parser = new GroovyParser("2", "", "", "", "");

Check warning on line 97 in plugin/src/test/java/io/jenkins/plugins/analysis/warnings/groovy/ParserConfigurationTest.java

View check run for this annotation

ci.jenkins.io / CheckStyle

LocalVariableNameCheck

NORMAL: Name 'second_test_parser' must match pattern '^[a-z][a-zA-Z0-9]*$'.
Raw output
<p> Checks that local, non-<code>final</code> variable names conform to a format specified by the format property. A catch parameter is considered to be a local variable. </p>

Check warning on line 97 in plugin/src/test/java/io/jenkins/plugins/analysis/warnings/groovy/ParserConfigurationTest.java

View check run for this annotation

ci.jenkins.io / PMD

LocalVariableNamingConventions

HIGH: The local variable name 'second_test_parser' doesn't match '[a-z][a-zA-Z0-9]*'.
Raw output
Configurable naming conventions for local variable declarations and other locally-scoped variables. This rule reports variable declarations which do not match the regex that applies to their specific kind (e.g. final variable, or catch-clause parameter). Each regex can be configured through properties. By default this rule uses the standard Java naming convention (Camel case). <pre> <code> class Foo { void bar() { int localVariable = 1; // This is in camel case, so it&#x27;s ok int local_variable = 1; // This will be reported unless you change the regex final int i_var = 1; // final local variables can be configured separately try { foo(); } catch (IllegalArgumentException e_illegal) { // exception block parameters can be configured separately } } } </code> </pre> <a href="https://pmd.github.io/pmd-6.55.0/pmd_rules_java_codestyle.html#localvariablenamingconventions"> See PMD documentation. </a>

ParserConfiguration configuration = new ParserConfiguration(facade);
configuration.addParser(first_test_parser);
configuration.addParser(second_test_parser);

assertThat(configuration.getParsers().contains(first_test_parser));
assertThat(configuration.getParsers().contains(second_test_parser));

configuration.deleteParser(first_test_parser.getId());
assertThat(!(configuration.getParsers().contains(first_test_parser)));
assertThat(configuration.getParsers().contains(first_test_parser));
}
}

0 comments on commit 2087d71

Please sign in to comment.