Skip to content

Commit 1cd6399

Browse files
authored
Merge pull request #6 from AnetteTaivere/jsonTests
Mock server
2 parents fb116d3 + 9f039b9 commit 1cd6399

File tree

9 files changed

+519
-14
lines changed

9 files changed

+519
-14
lines changed

pom.xml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<version>0.0.4-SNAPSHOT</version>
88
<dependencies>
99

10+
<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
1011
<dependency>
1112
<groupId>ch.qos.logback</groupId>
1213
<artifactId>logback-classic</artifactId>
@@ -22,23 +23,31 @@
2223
<scope>test</scope>
2324
</dependency>
2425

25-
26-
<!-- mockito -->
26+
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
2727
<dependency>
2828
<groupId>org.mockito</groupId>
2929
<artifactId>mockito-core</artifactId>
3030
<version>5.8.0</version>
3131
<scope>test</scope>
3232
</dependency>
3333

34-
<!-- junit -->
34+
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
3535
<dependency>
3636
<groupId>org.junit.jupiter</groupId>
3737
<artifactId>junit-jupiter-api</artifactId>
3838
<version>5.10.2</version>
3939
<scope>test</scope>
4040
</dependency>
4141

42+
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
43+
<dependency>
44+
<groupId>org.junit.jupiter</groupId>
45+
<artifactId>junit-jupiter-engine</artifactId>
46+
<version>5.10.0</version>
47+
<scope>test</scope>
48+
</dependency>
49+
50+
<!-- https://mvnrepository.com/artifact/uk.org.webcompere/system-stubs-jupiter -->
4251
<dependency>
4352
<groupId>uk.org.webcompere</groupId>
4453
<artifactId>system-stubs-jupiter</artifactId>
@@ -128,15 +137,6 @@
128137
<version>2.20.0</version>
129138
</dependency>
130139

131-
<dependency>
132-
<groupId>org.junit.jupiter</groupId>
133-
<artifactId>junit-jupiter-engine</artifactId>
134-
<version>5.9.2</version>
135-
<scope>test</scope>
136-
</dependency>
137-
138-
139-
140140
</dependencies>
141141
<properties>
142142
<maven.compiler.source>17</maven.compiler.source>

src/main/java/analysis/GoblintAnalysis.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ public void analyze(Collection<? extends Module> files, AnalysisConsumer consume
121121
log.info("---------------------- Analysis started ----------------------");
122122

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

126129
log.info("--------------------- Analysis finished ----------------------");
@@ -152,7 +155,6 @@ public void analyze(Collection<? extends Module> files, AnalysisConsumer consume
152155
public CompletableFuture<Collection<AnalysisResult>> reanalyse() {
153156
//return goblintService.analyze(new AnalyzeParams(true))
154157
return goblintService.analyze(new AnalyzeParams(!gobpieConfiguration.useIncrementalAnalysis()))
155-
156158
.thenCompose(this::getComposedAnalysisResults);
157159
}
158160

src/main/java/analysis/GoblintCFGAnalysisResult.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import java.util.ArrayList;
1111
import java.util.Collections;
12+
import java.util.Objects;
1213

1314
/**
1415
* The Class GoblintCFGAnalysisResult.
@@ -72,4 +73,28 @@ public Pair<Position, String> repair() {
7273
public String code() {
7374
return null;
7475
}
76+
77+
78+
@Override
79+
public boolean equals(Object o) {
80+
if (this == o) return true;
81+
if (o == null || getClass() != o.getClass()) return false;
82+
GoblintCFGAnalysisResult that = (GoblintCFGAnalysisResult) o;
83+
return Objects.equals(pos, that.pos) && Objects.equals(title, that.title) && Objects.equals(funName, that.funName) && Objects.equals(related, that.related);
84+
}
85+
86+
@Override
87+
public int hashCode() {
88+
return Objects.hash(pos, title, funName, related);
89+
}
90+
91+
@Override
92+
public String toString() {
93+
return "GoblintCFGAnalysisResult{" +
94+
"pos=" + pos +
95+
", title='" + title + '\'' +
96+
", funName='" + funName + '\'' +
97+
", related=" + related +
98+
'}';
99+
}
75100
}

src/main/java/analysis/GoblintMessagesAnalysisResult.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.eclipse.lsp4j.DiagnosticSeverity;
99

1010
import java.util.ArrayList;
11+
import java.util.Objects;
1112

1213
/**
1314
* The Class GoblintMessagesAnalysisResult.
@@ -108,4 +109,27 @@ public String code() {
108109
return null;
109110
}
110111

112+
@Override
113+
public boolean equals(Object o) {
114+
if (this == o) return true;
115+
if (o == null || getClass() != o.getClass()) return false;
116+
GoblintMessagesAnalysisResult that = (GoblintMessagesAnalysisResult) o;
117+
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);
118+
}
119+
120+
@Override
121+
public int hashCode() {
122+
return Objects.hash(group_text, text, pos, severity, related);
123+
}
124+
125+
@Override
126+
public String toString() {
127+
return "GoblintMessagesAnalysisResult{" +
128+
"group_text='" + group_text + '\'' +
129+
", text='" + text + '\'' +
130+
", pos=" + pos.toString() +
131+
", severity='" + severity + '\'' +
132+
", related=" + related +
133+
'}';
134+
}
111135
}

src/main/java/api/messages/GoblintMessagesResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static class Group implements MultiPiece {
9292
* @return A collection of AnalysisResult objects.
9393
*/
9494
public List<AnalysisResult> convert(List<Tag> tags, String severity, boolean explode) {
95-
return explode
95+
return explode && this.group_loc != null
9696
? convertGroupExplode(tags, severity)
9797
: convertGroup(tags, severity);
9898
}

src/main/java/api/messages/GoblintPosition.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import java.io.Reader;
77
import java.net.URL;
8+
import java.util.Objects;
89

910
/**
1011
* The Class GoblintPosition.
@@ -81,4 +82,28 @@ public Reader getReader() {
8182
public URL getURL() {
8283
return sourcefileURL;
8384
}
85+
86+
@Override
87+
public boolean equals(Object o) {
88+
if (this == o) return true;
89+
if (o == null || getClass() != o.getClass()) return false;
90+
GoblintPosition that = (GoblintPosition) o;
91+
return columnStart == that.columnStart && columnEnd == that.columnEnd && lineStart == that.lineStart && lineEnd == that.lineEnd && Objects.equals(sourcefileURL, that.sourcefileURL);
92+
}
93+
94+
@Override
95+
public int hashCode() {
96+
return Objects.hash(columnStart, columnEnd, lineStart, lineEnd, sourcefileURL);
97+
}
98+
99+
@Override
100+
public String toString() {
101+
return "GoblintPosition{" +
102+
"columnStart=" + columnStart +
103+
", columnEnd=" + columnEnd +
104+
", lineStart=" + lineStart +
105+
", lineEnd=" + lineEnd +
106+
", sourcefileURL=" + sourcefileURL +
107+
'}';
108+
}
84109
}

0 commit comments

Comments
 (0)