Skip to content

Commit 2407148

Browse files
committed
WS-2609: Code smells. More JaCoCo wrestling for Sonar.
1 parent a24479d commit 2407148

File tree

10 files changed

+44
-25
lines changed

10 files changed

+44
-25
lines changed

CI.Jenkinsfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ node ("docker-light") {
2121
/opt/maven-basis/bin/mvn --batch-mode sonar:sonar \
2222
-Dsonar.login=${env.SONAR_AUTH_TOKEN} \
2323
-Dsonar.host.url=${env.SONAR_HOST_URL} \
24-
-Dsonar.coverage.jacoco.xmlReportPaths=./api/target/site/jacoco/jacoco.xml,./json/target/site/jacoco/jacoco.xml \
2524
-Dsonar.pullrequest.key=${env.CHANGE_ID} \
2625
-Dsonar.pullrequest.base=${env.CHANGE_TARGET} \
2726
-Dsonar.pullrequest.branch=${env.CHANGE_BRANCH}\""

api/src/test/java/com/basistech/rosette/api/BasicTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
import static org.junit.jupiter.api.Assertions.assertTrue;
6161

6262
@ExtendWith(MockServerExtension.class)
63-
public class BasicTest {
63+
class BasicTest {
6464
private MockServerClient mockServer;
6565
private HttpRosetteAPI api;
6666

@@ -75,7 +75,7 @@ public void setup(MockServerClient mockServer) {
7575
// then set concurrent connections = 5,
7676
// run several requests again, showing they're executed in parallel
7777
@Test
78-
public void testMultipleConnections() throws InterruptedException {
78+
void testMultipleConnections() throws InterruptedException {
7979
int delayTime = 3;
8080
int numConnections = 5;
8181

@@ -130,7 +130,7 @@ public void testMultipleConnections() throws InterruptedException {
130130
assertTrue(d2.getTime() - d1.getTime() > delayTime * 1000); // but at least as long as one
131131
}
132132
@Test
133-
public void testHeaders() throws Exception {
133+
void testHeaders() throws Exception {
134134
mockServer.when(HttpRequest.request()
135135
.withMethod("GET")
136136
.withPath("/rest/v1/ping")
@@ -152,7 +152,7 @@ public void testHeaders() throws Exception {
152152
}
153153

154154
@Test
155-
public void testAdm() throws Exception {
155+
void testAdm() throws Exception {
156156
try (InputStream reqIns = getClass().getResourceAsStream("/adm-req.json");
157157
InputStream respIns = getClass().getResourceAsStream("/adm-resp.json")) {
158158
assertNotNull(respIns);
@@ -176,7 +176,7 @@ public void testAdm() throws Exception {
176176
}
177177

178178
@Test
179-
public void testExtendedInfo() throws Exception {
179+
void testExtendedInfo() throws Exception {
180180
mockServer.when(HttpRequest.request()
181181
.withMethod("GET")
182182
.withPath("/rest/v1/ping"))
@@ -216,7 +216,7 @@ public void run() {
216216
}
217217

218218
@Test
219-
public void testLanguageSupport() throws Exception {
219+
void testLanguageSupport() throws Exception {
220220
try (InputStream respIns = getClass().getResourceAsStream("/supported-languages.json")) {
221221
assertNotNull(respIns);
222222
mockServer.when(HttpRequest.request()
@@ -246,7 +246,7 @@ public void testLanguageSupport() throws Exception {
246246
}
247247

248248
@Test
249-
public void testNameSimilarityLanguageSupport() throws Exception {
249+
void testNameSimilarityLanguageSupport() throws Exception {
250250
try (InputStream respIns = getClass().getResourceAsStream("/name-similarity-supported-languages.json")) {
251251
assertNotNull(respIns);
252252
mockServer.when(HttpRequest.request()
@@ -277,7 +277,7 @@ public void testNameSimilarityLanguageSupport() throws Exception {
277277
}
278278

279279
@Test
280-
public void testNameTranslationLanguageSupport() throws Exception {
280+
void testNameTranslationLanguageSupport() throws Exception {
281281
try (InputStream respIns = getClass().getResourceAsStream("/name-translation-supported-languages.json")) {
282282
assertNotNull(respIns);
283283
mockServer.when(HttpRequest.request()

api/src/test/java/com/basistech/rosette/api/DevRosetteAPITest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Test that is usually ignored, used to debug against a live service.
3838
*/
3939
@Disabled
40-
public class DevRosetteAPITest {
40+
class DevRosetteAPITest {
4141
// edit the right URL into place
4242
private static final String URL = "http://localhost:8181/rest/v1";
4343
private static final String KEY = null;
@@ -55,7 +55,7 @@ public void after() throws IOException {
5555
}
5656

5757
@Test
58-
public void multipart() {
58+
void multipart() {
5959
// this assumes that the server has the mock version of the components.
6060
Request morphologyRequest = DocumentRequest.builder().language(LanguageCode.ENGLISH)
6161
.options(MorphologyOptions.builder().partOfSpeechTagSet(PartOfSpeechTagSet.upt16).build())
@@ -67,7 +67,7 @@ public void multipart() {
6767
}
6868

6969
@Test
70-
public void simple() {
70+
void simple() {
7171
// this assumes that the server has the mock version of the components.
7272
Request morphologyRequest = DocumentRequest.builder().language(LanguageCode.ENGLISH)
7373
.options(MorphologyOptions.builder().partOfSpeechTagSet(PartOfSpeechTagSet.upt16).build())

api/src/test/java/com/basistech/rosette/api/InvalidErrorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import static org.junit.jupiter.api.Assertions.assertTrue;
3838

3939
@ExtendWith(MockServerExtension.class)
40-
public class InvalidErrorTest {
40+
class InvalidErrorTest {
4141
private MockServerClient mockServer;
4242

4343
@BeforeEach
@@ -46,7 +46,7 @@ public void setup(MockServerClient mockServer) {
4646
}
4747

4848
@Test
49-
public void notJsonError() throws Exception {
49+
void notJsonError() throws Exception {
5050
mockServer.when(HttpRequest.request().withPath(".*/{2,}.*"))
5151
.respond(HttpResponse.response()
5252
.withBody("Invalid path; '//'")

api/src/test/java/com/basistech/rosette/api/RosetteAPITest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
import static org.junit.jupiter.api.Assertions.fail;
7575

7676
@ExtendWith(MockServerExtension.class)
77-
public class RosetteAPITest {
77+
class RosetteAPITest {
7878
private static final String INFO_RESPONSE = "{ \"buildNumber\": \"6bafb29d\", \"buildTime\": "
7979
+ "\"2015.10.08_10:19:26\", \"name\": \"RosetteAPI\", \"version\": \"0.7.0\", \"versionChecked\": true }";
8080
private HttpRosetteAPI api;
@@ -183,7 +183,7 @@ private static Stream<Arguments> testMatchNameParameters() throws IOException {
183183

184184
@ParameterizedTest(name = "testFilename: {0}; statusCode: {2}")
185185
@MethodSource("testMatchNameParameters")
186-
public void testMatchName(String testFilename, String responseStr, int statusCode) throws IOException {
186+
void testMatchName(String testFilename, String responseStr, int statusCode) throws IOException {
187187
setStatusCodeResponse(responseStr, statusCode);
188188
NameSimilarityRequest request = readValueNameMatcher(testFilename);
189189
try {

json/src/test/java/com/basistech/rosette/apimodel/EnumTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import static org.junit.jupiter.api.Assertions.assertEquals;
2727
import static org.junit.jupiter.api.Assertions.assertTrue;
2828

29-
public class EnumTest {
29+
class EnumTest {
3030
private ObjectMapper mapper;
3131

3232
@BeforeEach
@@ -35,7 +35,7 @@ public void init() {
3535
}
3636

3737
@Test
38-
public void testCaseInsensitivity() throws Exception {
38+
void testCaseInsensitivity() throws Exception {
3939
String json = "{\"content\": \"foo\", \"options\": {\"modelType\": \"dEfAuLT\"}}";
4040
Request request = mapper.readValue(json, new TypeReference<DocumentRequest<MorphologyOptions>>() { });
4141
assertTrue(request instanceof DocumentRequest);

json/src/test/java/com/basistech/rosette/apimodel/ModelTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
import static org.junit.jupiter.api.Assertions.assertEquals;
4646
import static org.junit.jupiter.api.Assertions.fail;
4747

48-
public class ModelTest {
48+
class ModelTest {
4949
private ObjectMapper mapper;
5050

5151
private static Stream<Arguments> packageTestParameters() {
@@ -62,7 +62,7 @@ public void init() {
6262

6363
@ParameterizedTest(name = "inputStreamContent: {0}")
6464
@MethodSource("packageTestParameters")
65-
public void packageTest(boolean inputStreams) throws ClassNotFoundException, IOException {
65+
void packageTest(boolean inputStreams) throws ClassNotFoundException, IOException {
6666
Reflections reflections = new Reflections(this.getClass().getPackage().getName(), new SubTypesScanner(false));
6767

6868
Set<Class<?>> allClasses = reflections.getSubTypesOf(Object.class);

json/src/test/java/com/basistech/rosette/apimodel/NonNullTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
import static org.junit.jupiter.api.Assertions.assertFalse;
3737

38-
public class NonNullTest {
38+
class NonNullTest {
3939
private ObjectMapper mapper;
4040

4141
// All test resource filename has <ClassName>.json pattern. They contain null requestId and timers fields.
@@ -60,7 +60,7 @@ public void init() {
6060

6161
@ParameterizedTest(name = "{0}; {1}")
6262
@MethodSource("testNonNullParameters")
63-
public void testNonNull(String className, File testFile) throws IOException, ClassNotFoundException {
63+
void testNonNull(String className, File testFile) throws IOException, ClassNotFoundException {
6464
Class<?> c = Class.forName(className);
6565
String s = FileUtils.readFileToString(testFile, StandardCharsets.UTF_8);
6666
String s2 = mapper.writeValueAsString(mapper.readValue(s, c));

json/src/test/java/com/basistech/rosette/apimodel/PolymorphicRequestTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import static org.junit.jupiter.api.Assertions.assertNull;
2727
import static org.junit.jupiter.api.Assertions.assertTrue;
2828

29-
public class PolymorphicRequestTest {
29+
class PolymorphicRequestTest {
3030
private static final String DOC_REQUEST = DocumentRequest.class.getName();
3131
private ObjectMapper mapper;
3232

@@ -36,7 +36,7 @@ public void init() {
3636
}
3737

3838
@Test
39-
public void testRequestTypes() throws Exception {
39+
void testRequestTypes() throws Exception {
4040

4141
String json = "{\"content\": \"what is my type\", \"language\": \"eng\", \"options\": {\"calculateConfidence\": true}}";
4242
Request request = mapper.readValue(json, new TypeReference<DocumentRequest<EntitiesOptions>>() { });
@@ -89,7 +89,7 @@ public void testRequestTypes() throws Exception {
8989
}
9090

9191
@Test
92-
public void eventsRequests() throws Exception {
92+
void eventsRequests() throws Exception {
9393
String json = "{\"content\": \"what is my type\", \"language\": \"eng\", \"options\": {\"workspaceId\": \"ws1\"}}";
9494
Request request = mapper.readValue(json, new TypeReference<DocumentRequest<EventsOptions>>() { });
9595
assertEquals(DOC_REQUEST, request.getClass().getName());

pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,26 @@
216216
</execution>
217217
</executions>
218218
</plugin>
219+
<plugin>
220+
<groupId>org.jacoco</groupId>
221+
<artifactId>jacoco-maven-plugin</artifactId>
222+
<version>${jacoco-maven-plugin.version}</version>
223+
<executions>
224+
<execution>
225+
<id>prepare-agent</id>
226+
<goals>
227+
<goal>prepare-agent</goal>
228+
</goals>
229+
</execution>
230+
<execution>
231+
<id>prepare-report</id>
232+
<phase>post-integration-test</phase>
233+
<goals>
234+
<goal>report-aggregate</goal>
235+
</goals>
236+
</execution>
237+
</executions>
238+
</plugin>
219239
</plugins>
220240
</pluginManagement>
221241
</build>

0 commit comments

Comments
 (0)