fixes instable debitor temp test data deletion and code coverage exclusions

This commit is contained in:
Michael Hoennig 2022-10-21 17:05:28 +02:00
parent 8864a17b2b
commit 5ada0dae35
2 changed files with 12 additions and 22 deletions

View File

@ -230,8 +230,8 @@ jacocoTestCoverageVerification {
excludes = [ excludes = [
'net.hostsharing.hsadminng.**.generated.**', 'net.hostsharing.hsadminng.**.generated.**',
'net.hostsharing.hsadminng.HsadminNgApplication', 'net.hostsharing.hsadminng.HsadminNgApplication',
'net.hostsharing.hsadminng.PingController', 'net.hostsharing.hsadminng.ping.PingController',
'net.hostsharing.hsadminng.Mapper' 'net.hostsharing.hsadminng.mapper.Mapper'
] ]
limit { limit {
@ -245,7 +245,7 @@ jacocoTestCoverageVerification {
excludes = [ excludes = [
'net.hostsharing.hsadminng.**.generated.**', 'net.hostsharing.hsadminng.**.generated.**',
'net.hostsharing.hsadminng.HsadminNgApplication.main', 'net.hostsharing.hsadminng.HsadminNgApplication.main',
'net.hostsharing.hsadminng.PingController.*' 'net.hostsharing.hsadminng.ping.PingController.*'
] ]
limit { limit {

View File

@ -78,12 +78,12 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
// when // when
final var result = attempt(em, () -> { final var result = attempt(em, () -> {
final var newDebitor = toCleanup(HsOfficeDebitorEntity.builder() final var newDebitor = HsOfficeDebitorEntity.builder()
.uuid(UUID.randomUUID()) .uuid(UUID.randomUUID())
.debitorNumber(20001) .debitorNumber(20001)
.partner(givenPartner) .partner(givenPartner)
.billingContact(givenContact) .billingContact(givenContact)
.build()); .build();
return debitorRepo.save(newDebitor); return debitorRepo.save(newDebitor);
}); });
@ -111,12 +111,12 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
attempt(em, () -> { attempt(em, () -> {
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Fourth").get(0); final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Fourth").get(0);
final var givenContact = contactRepo.findContactByOptionalLabelLike("forth contact").get(0); final var givenContact = contactRepo.findContactByOptionalLabelLike("forth contact").get(0);
final var newDebitor = toCleanup(HsOfficeDebitorEntity.builder() final var newDebitor = HsOfficeDebitorEntity.builder()
.uuid(UUID.randomUUID()) .uuid(UUID.randomUUID())
.debitorNumber(20002) .debitorNumber(20002)
.partner(givenPartner) .partner(givenPartner)
.billingContact(givenContact) .billingContact(givenContact)
.build()); .build();
return debitorRepo.save(newDebitor); return debitorRepo.save(newDebitor);
}).assertSuccessful(); }).assertSuccessful();
@ -278,7 +278,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
givenDebitor.setVatId(givenNewVatId); givenDebitor.setVatId(givenNewVatId);
givenDebitor.setVatCountryCode(givenNewVatCountryCode); givenDebitor.setVatCountryCode(givenNewVatCountryCode);
givenDebitor.setVatBusiness(givenNewVatBusiness); givenDebitor.setVatBusiness(givenNewVatBusiness);
return toCleanup(debitorRepo.save(givenDebitor)); return debitorRepo.save(givenDebitor);
}); });
// then // then
@ -327,7 +327,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
final var result = jpaAttempt.transacted(() -> { final var result = jpaAttempt.transacted(() -> {
context("superuser-alex@hostsharing.net"); context("superuser-alex@hostsharing.net");
givenDebitor.setRefundBankAccount(givenNewBankAccount); givenDebitor.setRefundBankAccount(givenNewBankAccount);
return toCleanup(debitorRepo.save(givenDebitor)); return debitorRepo.save(givenDebitor);
}); });
// then // then
@ -356,7 +356,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
final var result = jpaAttempt.transacted(() -> { final var result = jpaAttempt.transacted(() -> {
context("superuser-alex@hostsharing.net"); context("superuser-alex@hostsharing.net");
givenDebitor.setRefundBankAccount(null); givenDebitor.setRefundBankAccount(null);
return toCleanup(debitorRepo.save(givenDebitor)); return debitorRepo.save(givenDebitor);
}); });
// then // then
@ -551,25 +551,15 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
.refundBankAccount(givenBankAccount) .refundBankAccount(givenBankAccount)
.build(); .build();
toCleanup(newDebitor);
return debitorRepo.save(newDebitor); return debitorRepo.save(newDebitor);
}).assertSuccessful().returnedValue(); }).assertSuccessful().returnedValue();
} }
private HsOfficeDebitorEntity toCleanup(final HsOfficeDebitorEntity tempDebitor) {
tempDebitors.add(tempDebitor);
return tempDebitor;
}
@BeforeEach @BeforeEach
@AfterEach @AfterEach
void cleanup() { void cleanup() {
context("superuser-alex@hostsharing.net", null); context("superuser-alex@hostsharing.net");
tempDebitors.forEach(tempDebitor -> { em.createQuery("DELETE FROM HsOfficeDebitorEntity d where d.debitorNumber >= 20000").executeUpdate();
System.out.println("DELETING temporary debitor: " + tempDebitor.toString());
debitorRepo.deleteByUuid(tempDebitor.getUuid());
});
} }
void exactlyTheseDebitorsAreReturned(final List<HsOfficeDebitorEntity> actualResult, final String... debitorNames) { void exactlyTheseDebitorsAreReturned(final List<HsOfficeDebitorEntity> actualResult, final String... debitorNames) {