Skip to content

Commit

Permalink
Merge pull request #6 from AnetteTaivere/jsonTests
Browse files Browse the repository at this point in the history
Mock server
  • Loading branch information
karoliineh authored Mar 22, 2024
2 parents fb116d3 + 9f039b9 commit 1cd6399
Show file tree
Hide file tree
Showing 9 changed files with 519 additions and 14 deletions.
24 changes: 12 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<version>0.0.4-SNAPSHOT</version>
<dependencies>

<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
Expand All @@ -22,23 +23,31 @@
<scope>test</scope>
</dependency>


<!-- mockito -->
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.8.0</version>
<scope>test</scope>
</dependency>

<!-- junit -->
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.10.0</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/uk.org.webcompere/system-stubs-jupiter -->
<dependency>
<groupId>uk.org.webcompere</groupId>
<artifactId>system-stubs-jupiter</artifactId>
Expand Down Expand Up @@ -128,15 +137,6 @@
<version>2.20.0</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.2</version>
<scope>test</scope>
</dependency>



</dependencies>
<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/analysis/GoblintAnalysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ public void analyze(Collection<? extends Module> files, AnalysisConsumer consume
log.info("---------------------- Analysis started ----------------------");

lastAnalysisTask = reanalyse().thenAccept(response -> {
for (AnalysisResult analysisResult : response) {
System.out.println(analysisResult.toString());
}
consumer.consume(new ArrayList<>(response), source());

log.info("--------------------- Analysis finished ----------------------");
Expand Down Expand Up @@ -152,7 +155,6 @@ public void analyze(Collection<? extends Module> files, AnalysisConsumer consume
public CompletableFuture<Collection<AnalysisResult>> reanalyse() {
//return goblintService.analyze(new AnalyzeParams(true))
return goblintService.analyze(new AnalyzeParams(!gobpieConfiguration.useIncrementalAnalysis()))

.thenCompose(this::getComposedAnalysisResults);
}

Expand Down
25 changes: 25 additions & 0 deletions src/main/java/analysis/GoblintCFGAnalysisResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.Objects;

/**
* The Class GoblintCFGAnalysisResult.
Expand Down Expand Up @@ -72,4 +73,28 @@ public Pair<Position, String> repair() {
public String code() {
return null;
}


@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
GoblintCFGAnalysisResult that = (GoblintCFGAnalysisResult) o;
return Objects.equals(pos, that.pos) && Objects.equals(title, that.title) && Objects.equals(funName, that.funName) && Objects.equals(related, that.related);
}

@Override
public int hashCode() {
return Objects.hash(pos, title, funName, related);
}

@Override
public String toString() {
return "GoblintCFGAnalysisResult{" +
"pos=" + pos +
", title='" + title + '\'' +
", funName='" + funName + '\'' +
", related=" + related +
'}';
}
}
24 changes: 24 additions & 0 deletions src/main/java/analysis/GoblintMessagesAnalysisResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.eclipse.lsp4j.DiagnosticSeverity;

import java.util.ArrayList;
import java.util.Objects;

/**
* The Class GoblintMessagesAnalysisResult.
Expand Down Expand Up @@ -108,4 +109,27 @@ public String code() {
return null;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
GoblintMessagesAnalysisResult that = (GoblintMessagesAnalysisResult) o;
return Objects.equals(group_text, that.group_text) && Objects.equals(text, that.text) && Objects.equals(pos, that.pos) && Objects.equals(severity, that.severity) && Objects.equals(related, that.related);
}

@Override
public int hashCode() {
return Objects.hash(group_text, text, pos, severity, related);
}

@Override
public String toString() {
return "GoblintMessagesAnalysisResult{" +
"group_text='" + group_text + '\'' +
", text='" + text + '\'' +
", pos=" + pos.toString() +
", severity='" + severity + '\'' +
", related=" + related +
'}';
}
}
2 changes: 1 addition & 1 deletion src/main/java/api/messages/GoblintMessagesResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static class Group implements MultiPiece {
* @return A collection of AnalysisResult objects.
*/
public List<AnalysisResult> convert(List<Tag> tags, String severity, boolean explode) {
return explode
return explode && this.group_loc != null
? convertGroupExplode(tags, severity)
: convertGroup(tags, severity);
}
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/api/messages/GoblintPosition.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.io.Reader;
import java.net.URL;
import java.util.Objects;

/**
* The Class GoblintPosition.
Expand Down Expand Up @@ -81,4 +82,28 @@ public Reader getReader() {
public URL getURL() {
return sourcefileURL;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
GoblintPosition that = (GoblintPosition) o;
return columnStart == that.columnStart && columnEnd == that.columnEnd && lineStart == that.lineStart && lineEnd == that.lineEnd && Objects.equals(sourcefileURL, that.sourcefileURL);
}

@Override
public int hashCode() {
return Objects.hash(columnStart, columnEnd, lineStart, lineEnd, sourcefileURL);
}

@Override
public String toString() {
return "GoblintPosition{" +
"columnStart=" + columnStart +
", columnEnd=" + columnEnd +
", lineStart=" + lineStart +
", lineEnd=" + lineEnd +
", sourcefileURL=" + sourcefileURL +
'}';
}
}
Loading

0 comments on commit 1cd6399

Please sign in to comment.