Skip to content

Commit

Permalink
Add test to assert fixed findings is never null
Browse files Browse the repository at this point in the history
  • Loading branch information
drdavella committed Dec 20, 2024
1 parent 9fed6d8 commit 04c56b1
Show file tree
Hide file tree
Showing 2 changed files with 787 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/test/java/io/codemodder/codetf/DeserializeReportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -69,6 +70,21 @@ void it_deserializes_basic_report() throws IOException {
assertThat(report.hasCodeChanges(), equalTo(true));
}

@Test
void it_deserializes_fixed_findings() throws IOException {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
File file = new File("src/test/resources/semgrep.codetf.json");
CodeTFReport report = mapper.readValue(file, CodeTFReport.class);
for (final CodeTFResult result : report.getResults()) {
for (CodeTFChangesetEntry entry : result.getChangeset()) {
assertThat(entry.getFixedFindings(), notNullValue());
for (CodeTFChange change : entry.getChanges()) {
assertThat(change.getFixedFindings(), notNullValue());
}
}
}
}

@Test
void it_answers_correctly_if_results_but_no_changes() throws IOException {
File file = new File("src/test/resources/no_changes_but_results.codetf.json");
Expand Down
Loading

0 comments on commit 04c56b1

Please sign in to comment.