jacoco code coverage (with deliberately too low limit for testing)
This commit is contained in:
parent
933e4f3d3d
commit
ec70357ea0
72
build.gradle
72
build.gradle
@ -31,6 +31,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
|
apply plugin: 'jacoco'
|
||||||
apply plugin: 'org.owasp.dependencycheck'
|
apply plugin: 'org.owasp.dependencycheck'
|
||||||
sourceCompatibility=1.8
|
sourceCompatibility=1.8
|
||||||
targetCompatibility=1.8
|
targetCompatibility=1.8
|
||||||
@ -111,6 +112,75 @@ test {
|
|||||||
reports.html.enabled = false
|
reports.html.enabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- JaCoCo Code Coverage ---
|
||||||
|
|
||||||
|
jacoco {
|
||||||
|
toolVersion = "0.8.3"
|
||||||
|
}
|
||||||
|
|
||||||
|
test.finalizedBy jacocoTestReport
|
||||||
|
check.dependsOn jacocoTestCoverageVerification
|
||||||
|
|
||||||
|
// Only for purely JHipster/MapStruct generated classes.
|
||||||
|
// Please do NOT add any self coded classes!
|
||||||
|
// Keep in mind, git will blame you ;-)
|
||||||
|
def jhipsterGeneratedClassesWithDecentCoverage = [
|
||||||
|
'org.hostsharing.hsadminng.repository.CustomAuditEventRepository',
|
||||||
|
'org.hostsharing.hsadminng.service.ContactQueryService',
|
||||||
|
'org.hostsharing.hsadminng.service.UserService',
|
||||||
|
'org.hostsharing.hsadminng.service.CustomerContactQueryService'
|
||||||
|
]
|
||||||
|
|
||||||
|
// Only for purely JHipster/MapStruct generated classes.
|
||||||
|
// Please do NOT add any self coded classes!
|
||||||
|
// Keep in mind, git will blame you ;-)
|
||||||
|
def jhipsterGeneratedClassesWithLowCoverage = [
|
||||||
|
'org.hostsharing.hsadminng.service.MailService',
|
||||||
|
'org.hostsharing.hsadminng.security.SecurityUtils',
|
||||||
|
'org.hostsharing.hsadminng.config.DefaultProfileUtil',
|
||||||
|
'org.hostsharing.hsadminng.config.WebConfigurer',
|
||||||
|
'org.hostsharing.hsadminng.web.rest.AccountResource',
|
||||||
|
'org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator',
|
||||||
|
'org.hostsharing.hsadminng.web.rest.errors.CustomParameterizedException',
|
||||||
|
'org.hostsharing.hsadminng.config.audit.AuditEventConverter',
|
||||||
|
'org.hostsharing.hsadminng.security.jwt.TokenProvider',
|
||||||
|
'org.hostsharing.hsadminng.aop.logging.LoggingAspect',
|
||||||
|
'org.hostsharing.hsadminng.HsadminNgApp',
|
||||||
|
'*.*QueryService',
|
||||||
|
'*.*Configuration',
|
||||||
|
'*MapperImpl',
|
||||||
|
'*Criteria',
|
||||||
|
'*_'
|
||||||
|
]
|
||||||
|
|
||||||
|
jacocoTestCoverageVerification {
|
||||||
|
violationRules {
|
||||||
|
rule {
|
||||||
|
element = 'CLASS'
|
||||||
|
limit {
|
||||||
|
counter = 'BRANCH'
|
||||||
|
value = 'COVEREDRATIO'
|
||||||
|
// Increasing the threshold is fine, decreasing is not.
|
||||||
|
// Keep in mind, git will blame you ;-)
|
||||||
|
minimum = 0.95
|
||||||
|
}
|
||||||
|
excludes = jhipsterGeneratedClassesWithDecentCoverage + jhipsterGeneratedClassesWithLowCoverage
|
||||||
|
}
|
||||||
|
|
||||||
|
rule {
|
||||||
|
element = 'CLASS'
|
||||||
|
limit {
|
||||||
|
counter = 'BRANCH'
|
||||||
|
value = 'COVEREDRATIO'
|
||||||
|
minimum = 0.85
|
||||||
|
}
|
||||||
|
includes = jhipsterGeneratedClassesWithDecentCoverage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Cucumber BDD Tests ---
|
||||||
|
|
||||||
task cucumberTest(type: Test) {
|
task cucumberTest(type: Test) {
|
||||||
description = "Execute cucumber BDD tests."
|
description = "Execute cucumber BDD tests."
|
||||||
group = "verification"
|
group = "verification"
|
||||||
@ -133,6 +203,8 @@ task cucumberTestReport(type: TestReport) {
|
|||||||
reportOn cucumberTest
|
reportOn cucumberTest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------
|
||||||
|
|
||||||
apply from: 'gradle/docker.gradle'
|
apply from: 'gradle/docker.gradle'
|
||||||
apply from: 'gradle/sonar.gradle'
|
apply from: 'gradle/sonar.gradle'
|
||||||
apply from: 'gradle/swagger.gradle'
|
apply from: 'gradle/swagger.gradle'
|
||||||
|
@ -1,25 +1,24 @@
|
|||||||
package org.hostsharing.hsadminng.web.rest;
|
package org.hostsharing.hsadminng.web.rest;
|
||||||
|
|
||||||
|
import io.github.jhipster.web.util.ResponseUtil;
|
||||||
|
import org.hostsharing.hsadminng.service.ShareQueryService;
|
||||||
import org.hostsharing.hsadminng.service.ShareService;
|
import org.hostsharing.hsadminng.service.ShareService;
|
||||||
|
import org.hostsharing.hsadminng.service.dto.ShareCriteria;
|
||||||
|
import org.hostsharing.hsadminng.service.dto.ShareDTO;
|
||||||
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
||||||
import org.hostsharing.hsadminng.web.rest.util.HeaderUtil;
|
import org.hostsharing.hsadminng.web.rest.util.HeaderUtil;
|
||||||
import org.hostsharing.hsadminng.web.rest.util.PaginationUtil;
|
import org.hostsharing.hsadminng.web.rest.util.PaginationUtil;
|
||||||
import org.hostsharing.hsadminng.service.dto.ShareDTO;
|
|
||||||
import org.hostsharing.hsadminng.service.dto.ShareCriteria;
|
|
||||||
import org.hostsharing.hsadminng.service.ShareQueryService;
|
|
||||||
import io.github.jhipster.web.util.ResponseUtil;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@ -74,13 +73,8 @@ public class ShareResource {
|
|||||||
@PutMapping("/shares")
|
@PutMapping("/shares")
|
||||||
public ResponseEntity<ShareDTO> updateShare(@Valid @RequestBody ShareDTO shareDTO) throws URISyntaxException {
|
public ResponseEntity<ShareDTO> updateShare(@Valid @RequestBody ShareDTO shareDTO) throws URISyntaxException {
|
||||||
log.debug("REST request to update Share : {}", shareDTO);
|
log.debug("REST request to update Share : {}", shareDTO);
|
||||||
if (shareDTO.getId() == null) {
|
// TODO mhoennig: Rather completely remove the endpoint?
|
||||||
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
|
throw new BadRequestAlertException("Shares are immutable", ENTITY_NAME, "shareTransactionImmutable");
|
||||||
}
|
|
||||||
ShareDTO result = shareService.save(shareDTO);
|
|
||||||
return ResponseEntity.ok()
|
|
||||||
.headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, shareDTO.getId().toString()))
|
|
||||||
.body(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -132,7 +126,7 @@ public class ShareResource {
|
|||||||
@DeleteMapping("/shares/{id}")
|
@DeleteMapping("/shares/{id}")
|
||||||
public ResponseEntity<Void> deleteShare(@PathVariable Long id) {
|
public ResponseEntity<Void> deleteShare(@PathVariable Long id) {
|
||||||
log.debug("REST request to delete Share : {}", id);
|
log.debug("REST request to delete Share : {}", id);
|
||||||
shareService.delete(id);
|
// TODO mhoennig: Rather completely remove the endpoint?
|
||||||
return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build();
|
throw new BadRequestAlertException("Shares are immutable", ENTITY_NAME, "shareTransactionImmutable");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user