Skip to content

Commit

Permalink
@task XT-36766 - Junit tests for importing static analysis findings b…
Browse files Browse the repository at this point in the history
…y new parser
  • Loading branch information
kmarczyk committed May 7, 2019
1 parent b9b5692 commit f02d802
Show file tree
Hide file tree
Showing 5 changed files with 3,203 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class ParasoftParser

private final Properties _properties;

private final Path _workspace;
private final String _workspace;

private transient JenkinsResultsImporter _importer = null;

Expand All @@ -80,7 +80,12 @@ public ParasoftParser(Properties properties, String workspace)
{
_properties = properties == null ? new Properties() : properties;
Logger.getLogger().debug("Constructor call with settings: " + _properties); //$NON-NLS-1$
_workspace = workspace == null ? null : new File(workspace).toPath();
_workspace = workspace;
}

public Properties getProperties()
{
return _properties;
}

@Override
Expand All @@ -103,7 +108,8 @@ private Report importResults(File file)
return convert(importedData, importedData.getRulesImportHandler());
}

private Report convert(Iterator<IViolation> importResults, IRulesImportHandler rulesImportHandler)
// keep it public for JUnit tests
public Report convert(Iterator<IViolation> importResults, IRulesImportHandler rulesImportHandler)
{
JenkinsRulesUtil.refreshRuleDescriptions(_properties);

Expand Down Expand Up @@ -131,13 +137,15 @@ private Report convert(Iterator<IViolation> importResults, IRulesImportHandler r
private void populateViolationPathElements(IRuleViolation violation, Issue issue)
{
Serializable properties = issue.getAdditionalProperties();
Path workspacePath = _workspace == null ? null : new File(_workspace).toPath();
if (properties instanceof FlowIssueAdditionalProperties) {
FlowIssueAdditionalProperties additionalProperties = (FlowIssueAdditionalProperties) properties;
additionalProperties
.setChildren(new FlowAnalysisPathBuilder((IFlowAnalysisViolation) violation, issue.getId().toString(), _workspace).getPath());
.setChildren(new FlowAnalysisPathBuilder((IFlowAnalysisViolation) violation, issue.getId().toString(), workspacePath).getPath());
} else if (properties instanceof DupIssueAdditionalProperties) {
DupIssueAdditionalProperties additionalProperties = (DupIssueAdditionalProperties) properties;
additionalProperties.setChildren(new DupCodePathBuilder((IDupCodeViolation) violation, issue.getId().toString(), _workspace).getPath());
additionalProperties
.setChildren(new DupCodePathBuilder((IDupCodeViolation) violation, issue.getId().toString(), workspacePath).getPath());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@RunWith(Suite.class)
@Suite.SuiteClasses({
JenkinsVariablesResolverTest.class,
//ParasoftParserTest.class,
ParasoftParserTest.class,
VariablePatternVerifierTest.class,
XSLTransformTest.class,
SoatestReportsXslTransformationTest.class
Expand Down

0 comments on commit f02d802

Please sign in to comment.