Skip to content

Commit

Permalink
Add getter to access warnings found during a portability analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
lenhard committed Aug 3, 2015
1 parent 126aa61 commit b1ee6fe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/prope/metrics/portability/PortabilityAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import prope.executables.FileAnalyzer;
import prope.reporting.ReportEntry;
import bpp.domain.Warning;

public final class PortabilityAnalyzer implements FileAnalyzer {

private final String fileEnding = ".bpel";

private List<Warning> warnings;

@Override
public List<ReportEntry> analyzeFile(Path filePath) {
Expand All @@ -29,11 +33,20 @@ public List<ReportEntry> analyzeFile(Path filePath) {
}
return report;
}

public List<Warning> getWarningsFromLastAnalysis() {
if(warnings == null) {
return new ArrayList<>(0);
} else {
return Collections.unmodifiableList(warnings);
}
}

private ReportEntry populateEntry(Path filePath) {
bpp.executables.FileAnalyzer bppAnalyzer = new bpp.executables.FileAnalyzer(
filePath.toString(), false);
bpp.domain.AnalysisResult analysisResult = bppAnalyzer.analyze();
warnings = analysisResult.getViolations();
ReportEntry entry = new ReportEntry(analysisResult.getBpelFile()
.toString());
entry.addVariable("class", analysisResult.getClassification()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ public void testBasicFile() {
assertActivityPortability(result, 0.888);
assertServicePortability(result, 0.814);
}

@Test
public void checkWarnings() {
sut.analyzeFile(
Paths.get("src/test/resources/portability/Invoke-Empty.bpel"))
.get(0);
assertEquals(1, sut.getWarningsFromLastAnalysis().size());
}

private void assertNumberOfElements(ReportEntry entry, int numberOfElements) {
assertEquals(Integer.parseInt(entry.getVariableValue("N")),
Expand Down

0 comments on commit b1ee6fe

Please sign in to comment.