From 1bc704452728f64817645f5394884a2487357489 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Sun, 21 Apr 2019 11:53:30 +0200 Subject: [PATCH] fixing pitest failure by excluding purely generated code etc. also removed unused methods and added a unit test to improve coverage and setting thresholds now to 90% each --- build.gradle | 25 ++++++++++++++++--- .../hsadminng/domain/Customer.java | 19 -------------- .../hsadminng/domain/Membership.java | 20 --------------- .../service/dto/MembershipDTOTest.java | 15 +++++++++++ 4 files changed, 36 insertions(+), 43 deletions(-) create mode 100644 src/test/java/org/hostsharing/hsadminng/service/dto/MembershipDTOTest.java diff --git a/build.gradle b/build.gradle index 7efa4725..dcdd80df 100644 --- a/build.gradle +++ b/build.gradle @@ -208,12 +208,29 @@ task cucumberTestReport(type: TestReport) { pitest { targetClasses = ['org.hostsharing.hsadminng.*'] + + excludedClasses = [ + // Unit Testing Spring configurations makes little sense in most cases. + 'org.hostsharing.hsadminng.config.*', + 'org.hostsharing.hsadminng.ApplicationWebXml', + 'org.hostsharing.hsadminng.HsadminNgApp', + + // Unit testing this would need PowerMock and + // blackbox testing of random values has little value. + 'org.hostsharing.hsadminng.service.util.RandomUtil', + + // The following are mostly generated classes, + // as soon as we amend these, consider removing the exclude. + 'org.hostsharing.hsadminng.**Criteria', + 'org.hostsharing.hsadminng.aop.logging.*', + 'org.hostsharing.hsadminng.web.api.*' // API helpers, not the API itself + ] threads = 2 - // Do not set these limit even lower, they are already pretty bad values! - // 83%*78% means that only ~66% of the code is properly covered by automated tests. - mutationThreshold = 78 - coverageThreshold = 83 + // Do not set these limit lower! 90% each might sound good, but keep in mind: + // 90%*90% means that ~81% of the code are properly covered by automated tests. + mutationThreshold = 90 + coverageThreshold = 90 outputFormats = ['XML', 'HTML'] timestampedReports = false diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Customer.java b/src/main/java/org/hostsharing/hsadminng/domain/Customer.java index c7cb1495..08548949 100644 --- a/src/main/java/org/hostsharing/hsadminng/domain/Customer.java +++ b/src/main/java/org/hostsharing/hsadminng/domain/Customer.java @@ -195,16 +195,6 @@ public class Customer implements Serializable { return this; } - public Customer removeMembership(Membership membership) { - this.memberships.remove(membership); - membership.setCustomer(null); - return this; - } - - public void setMemberships(Set memberships) { - this.memberships = memberships; - } - public Set getSepamandates() { return sepamandates; } @@ -220,15 +210,6 @@ public class Customer implements Serializable { return this; } - public Customer removeSepamandate(SepaMandate sepaMandate) { - this.sepamandates.remove(sepaMandate); - sepaMandate.setCustomer(null); - return this; - } - - public void setSepamandates(Set sepaMandates) { - this.sepamandates = sepaMandates; - } // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove @Override diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Membership.java b/src/main/java/org/hostsharing/hsadminng/domain/Membership.java index d6e4e5bd..78ce7bff 100644 --- a/src/main/java/org/hostsharing/hsadminng/domain/Membership.java +++ b/src/main/java/org/hostsharing/hsadminng/domain/Membership.java @@ -129,16 +129,6 @@ public class Membership implements Serializable { return this; } - public Membership removeShare(Share share) { - this.shares.remove(share); - share.setMembership(null); - return this; - } - - public void setShares(Set shares) { - this.shares = shares; - } - public Set getAssets() { return assets; } @@ -154,16 +144,6 @@ public class Membership implements Serializable { return this; } - public Membership removeAsset(Asset asset) { - this.assets.remove(asset); - asset.setMembership(null); - return this; - } - - public void setAssets(Set assets) { - this.assets = assets; - } - public Customer getCustomer() { return customer; } diff --git a/src/test/java/org/hostsharing/hsadminng/service/dto/MembershipDTOTest.java b/src/test/java/org/hostsharing/hsadminng/service/dto/MembershipDTOTest.java new file mode 100644 index 00000000..ffcec115 --- /dev/null +++ b/src/test/java/org/hostsharing/hsadminng/service/dto/MembershipDTOTest.java @@ -0,0 +1,15 @@ +package org.hostsharing.hsadminng.service.dto; + +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class MembershipDTOTest { + + @Test + public void withShouldApplyCallback() { + final MembershipDTO actual = new MembershipDTO().with(m -> m.setRemark("Some Remark")); + + assertThat(actual.getRemark()).isEqualTo("Some Remark"); + } +}