Upgrade to SpringBoot 3.4.1 and dependencies #147

Merged
hsh-michaelhoennig merged 35 commits from maintenance/use-latest-versions into master 2025-01-15 13:43:29 +01:00
Showing only changes of commit c698754a8d - Show all commits

View File

@ -6,19 +6,19 @@ import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.grant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.role.RawRbacObjectRepository;
import net.hostsharing.hsadminng.rbac.role.RawRbacRoleRepository;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.context.annotation.Import;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
@ -27,10 +27,10 @@ import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import static net.hostsharing.hsadminng.mapper.Array.from;
import static net.hostsharing.hsadminng.rbac.grant.RawRbacGrantEntity.distinctGrantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.role.RawRbacObjectEntity.objectDisplaysOf;
import static net.hostsharing.hsadminng.rbac.role.RawRbacRoleEntity.distinctRoleNamesOf;
import static net.hostsharing.hsadminng.mapper.Array.from;
import static net.hostsharing.hsadminng.rbac.role.RbacRoleType.ADMIN;
import static net.hostsharing.hsadminng.rbac.role.RbacRoleType.AGENT;
import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt;
@ -81,7 +81,8 @@ class HsOfficePartnerRbacRepositoryIntegrationTest extends ContextBasedTestWithC
final var partnerRel = givenSomeTemporaryHostsharingPartnerRel("Winkler", "first contact");
// when
final var result = attempt(em, () -> {
final var result = attempt(
em, () -> {
final var newPartner = HsOfficePartnerRbacEntity.builder()
.partnerNumber(20031)
.partnerRel(partnerRel)
@ -109,7 +110,8 @@ class HsOfficePartnerRbacRepositoryIntegrationTest extends ContextBasedTestWithC
.toList();
// when
attempt(em, () -> {
attempt(
em, () -> {
final var givenPartnerPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0);
final var givenContact = contactrealRepo.findContactByOptionalCaptionLike("fourth contact").get(0);
final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0);
@ -208,29 +210,32 @@ class HsOfficePartnerRbacRepositoryIntegrationTest extends ContextBasedTestWithC
}
@Test
public void partnerAgent_canViewOnlyRelatedPartnersWithoutDetails() {
public void partnerAgent_canViewOnlyRelatedPartnersWithDetails() {
// given:
context("person-FirstGmbH@example.com",
context(
"person-FirstGmbH@example.com",
"hs_office.relation#HostsharingeG-with-PARTNER-FirstGmbH:AGENT");
// when:
final var result = partnerRepo.findPartnerByOptionalNameLike(null);
// then:
exactlyThesePartnersAreReturned(result, "partner(P-10001: LP First GmbH, first contact)");
exactlyThesePartnersAreReturned(result,
"partner(P-10001: LP First GmbH, first contact)+(partnerDetails(Hamburg, RegNo123456789))");
}
@Test
public void partnerTenant_canViewRelatedPartnersButWithoutDetails() {
// given:
context("person-FirstGmbH@example.com",
context(
"person-FirstGmbH@example.com",
"hs_office.relation#HostsharingeG-with-PARTNER-FirstGmbH:TENANT");
// when:
final var result = partnerRepo.findPartnerByOptionalNameLike(null);
// then:
exactlyThesePartnersAreReturned(result, "partner(P-10001: LP First GmbH, first contact)");
exactlyThesePartnersAreReturned(result, "partner(P-10001: LP First GmbH, first contact)+null");
}
}
@ -238,7 +243,7 @@ class HsOfficePartnerRbacRepositoryIntegrationTest extends ContextBasedTestWithC
class FindByNameLike {
@Test
public void globalAdmin_withoutAssumedRole_canViewAllPartners() {
public void globalAdmin_withoutAssumedRole_canViewAllPartnersWithDetails() {
// given
context("superuser-alex@hostsharing.net");
@ -246,7 +251,8 @@ class HsOfficePartnerRbacRepositoryIntegrationTest extends ContextBasedTestWithC
final var result = partnerRepo.findPartnerByOptionalNameLike("third contact");
// then
exactlyThesePartnersAreReturned(result, "partner(P-10003: IF Third OHG, third contact)");
exactlyThesePartnersAreReturned(result,
"partner(P-10003: IF Third OHG, third contact)+(partnerDetails(Hamburg, RegNo123456789))");
}
}
@ -315,7 +321,8 @@ class HsOfficePartnerRbacRepositoryIntegrationTest extends ContextBasedTestWithC
// when
final var result = jpaAttempt.transacted(() -> {
context("superuser-alex@hostsharing.net",
context(
"superuser-alex@hostsharing.net",
givenPartner.getPartnerRel().roleId(AGENT));
givenPartner.getDetails().setBirthName("new birthname");
return partnerRepo.save(givenPartner);
@ -327,7 +334,11 @@ class HsOfficePartnerRbacRepositoryIntegrationTest extends ContextBasedTestWithC
private void assertThatPartnerActuallyInDatabase(final HsOfficePartnerRbacEntity saved) {
final var found = partnerRepo.findByUuid(saved.getUuid());
assertThat(found).isNotEmpty().get().isNotSameAs(saved).extracting(HsOfficePartnerRbacEntity::toString).isEqualTo(saved.toString());
assertThat(found).isNotEmpty()
.get()
.isNotSameAs(saved)
.extracting(HsOfficePartnerRbacEntity::toString)
.isEqualTo(saved.toString());
}
private void assertThatPartnerIsVisibleForUserWithRole(
@ -478,7 +489,9 @@ class HsOfficePartnerRbacRepositoryIntegrationTest extends ContextBasedTestWithC
void exactlyThesePartnersAreReturned(final List<HsOfficePartnerRbacEntity> actualResult, final String... partnerNames) {
assertThat(actualResult)
.extracting(HsOfficePartnerRbacEntity::toString)
.extracting(partner ->
partner.toString() + "+" +
(partner.getDetails() != null ? ("(" + partner.getDetails() + ")") : "null"))
.containsExactlyInAnyOrder(partnerNames);
}