Skip to content

Commit

Permalink
Introduce jacoco and global identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
flawmop committed Aug 19, 2024
1 parent 383b975 commit 51588b1
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 29 deletions.
47 changes: 27 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
plugins {
id 'jacoco'
id 'java'
id 'jvm-test-suite'
id 'org.springframework.boot' version '3.3.2'
Expand All @@ -24,9 +25,6 @@ ext {
}

configurations {
//testE2EImplementation.extendsFrom(testImplementation)
//testE2ERuntimeOnly.extendsFrom(testRuntimeOnly)

runtimeOnly {
// Standard Commons Logging discovery in action with spring-jcl: please remove commons-logging.jar from classpath in order to avoid potential conflicts
exclude group: 'commons-logging', module: 'commons-logging'
Expand All @@ -48,6 +46,10 @@ dependencyManagement {
}
}

jacoco {
toolVersion = "0.8.12"
}

testing {
suites {
configureEach {
Expand Down Expand Up @@ -79,28 +81,33 @@ testing {
}
}

// https://github.com/gradle/gradle/issues/19217#
// https://github.com/rkrisztian/search/blob/ec93a56c6d01f5398fcb626a0fbefc8c18bbc267/build.gradle
tasks.named('jacocoTestReport').configure {
enabled = false
}

tasks.register('codeCoverageReport', JacocoReport) {
sourceSets sourceSets.main

tasks.matching({ t -> t.extensions.findByType(JacocoTaskExtension) }).forEach { testTask ->
executionData testTask
dependsOn testTask
}

reports {
xml.required = true
html.required = true
}
}

tasks.named('check') {
dependsOn(test)
dependsOn(testing.suites.i)
dependsOn(testing.suites.e2e)
dependsOn('codeCoverageReport')
}

//sourceSets {
// testE2E {
// java {
// compileClasspath += main.output + test.output
// runtimeClasspath += main.output + test.output
// }
// }
//}

//task testE2E(type: Test) {
// description = "Run end-2-end tests"
// group = "verification"
// testClassesDirs = sourceSets.testE2E.output.classesDirs
// classpath = sourceSets.testE2E.runtimeClasspath
//}

// On deploy error of ....
// The current machine does not support all of the following CPU features that are required by the image: [CX8, CMOV, FXSR, MMX, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, POPCNT, LZCNT, AVX, AVX2, BMI1, BMI2, FMA].
// Please rebuild the executable with an appropriate setting of the -march option.
Expand All @@ -116,4 +123,4 @@ tasks.named('test') {

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
}
11 changes: 11 additions & 0 deletions src/main/java/com/insilicosoft/portal/svc/rip/RipIdentifiers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.insilicosoft.portal.svc.rip;

public final class RipIdentifiers {

public static final String PARAM_NAME_SIMULATION_FILE = "mpfile";
public static final String REQUEST_MAPPING_RUN = "/run";
public static final String REQUEST_MAPPING_UPLOAD_ASYNC = "/uploadAsync";

private RipIdentifiers() {}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.springframework.web.bind.annotation.RequestPart ;
import org.springframework.web.multipart.MultipartFile;

import com.insilicosoft.portal.svc.rip.RipIdentifiers;
import com.insilicosoft.portal.svc.rip.exception.FileProcessingException;
import com.insilicosoft.portal.svc.rip.service.InputProcessorService;

Expand All @@ -22,11 +23,9 @@
* @author geoff
*/
@Controller
@RequestMapping("/run")
@RequestMapping(RipIdentifiers.REQUEST_MAPPING_RUN)
public class FileAsyncUploadController {

public static final String UPLOAD_FILE_PARAM_NAME = "mpfile";

private static final Logger log = LoggerFactory.getLogger(FileAsyncUploadController.class);

private final InputProcessorService inputProcessorService;
Expand All @@ -53,14 +52,14 @@ public ResponseEntity<String> get() {
* @return Response entity.
* @throws FileProcessingException If problems processing file.
*/
@PostMapping("/uploadAsync")
@PostMapping(RipIdentifiers.REQUEST_MAPPING_UPLOAD_ASYNC)
public CompletableFuture<ResponseEntity<String>> handleFileUpload(final @RequestPart(required=false,
value=UPLOAD_FILE_PARAM_NAME)
value=RipIdentifiers.PARAM_NAME_SIMULATION_FILE)
MultipartFile file)
throws FileProcessingException {

if (file == null) {
final String message = "The POST request must supply the parameter '" + UPLOAD_FILE_PARAM_NAME + "'";
final String message = "The POST request must supply the parameter '" + RipIdentifiers.PARAM_NAME_SIMULATION_FILE + "'";
log.warn("~handleFileUpload() : ".concat(message));
throw new FileProcessingException(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;

import com.insilicosoft.portal.svc.rip.RipIdentifiers;
import com.insilicosoft.portal.svc.rip.service.InputProcessorService;

@WebMvcTest
public class FileSyncUploadControllerIT {
@WebMvcTest(FileAsyncUploadController.class)
public class FileAsyncUploadControllerIT {

final static MediaType textWithCharset = new MediaType(MediaType.TEXT_PLAIN, StandardCharsets.UTF_8);

Expand All @@ -34,7 +35,7 @@ void testGet() throws Exception {

given(mockInputProcessorService.get()).willReturn(getMessage);

mockMvc.perform(get("/run"))
mockMvc.perform(get(RipIdentifiers.REQUEST_MAPPING_RUN))
.andExpect(status().isOk())
.andExpect(content().contentType(textWithCharset));

Expand Down

0 comments on commit 51588b1

Please sign in to comment.