-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1135 from jenkinsci/analysisModelId
Rename the `id` parameter of `analysisModel` tool to `analysisModelId`
- Loading branch information
Showing
7 changed files
with
93 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
plugin/src/test/java/io/jenkins/plugins/analysis/warnings/RegisteredParserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package io.jenkins.plugins.analysis.warnings; | ||
|
||
import java.util.NoSuchElementException; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import edu.hm.hafner.analysis.parser.checkstyle.CheckStyleParser; | ||
|
||
import io.jenkins.plugins.util.JenkinsFacade; | ||
|
||
import static io.jenkins.plugins.analysis.core.assertions.Assertions.*; | ||
import static org.mockito.Mockito.*; | ||
|
||
/** | ||
* Tests the class {@link RegisteredParser}. | ||
* | ||
* @author Ullrich Hafner | ||
*/ | ||
class RegisteredParserTest { | ||
private static final String CHECKSTYLE_ID = "checkstyle"; | ||
private static final String CHECK_STYLE_NAME = "CheckStyle"; | ||
private static final String CHECKSTYLE_PATTERN = "**/checkstyle-result.xml"; | ||
|
||
@Test | ||
void shouldThrowExceptionIfThereIsNoParserAvailable() { | ||
assertThatExceptionOfType(NoSuchElementException.class).isThrownBy(() -> new RegisteredParser("-unknown-")); | ||
} | ||
|
||
@Test | ||
void shouldAllowChangingId() { | ||
RegisteredParser parser = new RegisteredParser(CHECKSTYLE_ID); | ||
|
||
JenkinsFacade jenkins = mock(JenkinsFacade.class); | ||
when(jenkins.getDescriptorOrDie(RegisteredParser.class)).thenReturn(new RegisteredParser.Descriptor()); | ||
parser.setJenkinsFacade(jenkins); | ||
|
||
assertThat(parser.createParser()).isInstanceOf(CheckStyleParser.class); | ||
assertThat(parser) | ||
.hasAnalysisModelId(CHECKSTYLE_ID) | ||
.hasId(CHECKSTYLE_ID) | ||
.hasActualId(CHECKSTYLE_ID) | ||
.hasActualName(CHECK_STYLE_NAME) | ||
.hasActualPattern(CHECKSTYLE_PATTERN); | ||
|
||
assertThat(parser.getLabelProvider()).hasId(CHECKSTYLE_ID); | ||
assertThat(parser.getLabelProvider()).hasName(CHECK_STYLE_NAME); | ||
|
||
String customId = "customId"; | ||
parser.setId(customId); | ||
String customName = "Custom Name"; | ||
parser.setName(customName); | ||
String customPattern = "Custom Pattern"; | ||
parser.setPattern(customPattern); | ||
|
||
assertThat(parser) | ||
.hasAnalysisModelId(CHECKSTYLE_ID) | ||
.hasId(customId) | ||
.hasActualId(customId) | ||
.hasActualName(customName) | ||
.hasActualPattern(customPattern); | ||
|
||
assertThat(parser.getLabelProvider()).hasId(CHECKSTYLE_ID); // get decorations for checkstyle | ||
assertThat(parser.getLabelProvider()).hasName(customName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters