Upgrade to SpringBoot 3.4.1 and dependencies (#147)
Co-authored-by: Michael Hoennig <michael@hoennig.de> Reviewed-on: https://dev.hostsharing.net/hostsharing/hs.hsadmin.ng/pulls/147 Reviewed-by: Marc Sandlus <marc.sandlus@hostsharing.net>
This commit is contained in:
+2
-3
@@ -81,8 +81,7 @@ class RestResponseEntityExceptionHandlerUnitTest {
|
||||
void handleJpaObjectRetrievalFailureExceptionWithDisplayName() {
|
||||
// given
|
||||
final var givenException = new JpaObjectRetrievalFailureException(
|
||||
new EntityNotFoundException(
|
||||
"Unable to find net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity with id 12345-123454")
|
||||
new EntityNotFoundException("Unable to find Entity with id 12345-123454")
|
||||
);
|
||||
final var givenWebRequest = mock(WebRequest.class);
|
||||
|
||||
@@ -91,7 +90,7 @@ class RestResponseEntityExceptionHandlerUnitTest {
|
||||
|
||||
// then
|
||||
assertThat(errorResponse.getBody().getStatusCode()).isEqualTo(400);
|
||||
assertThat(errorResponse.getBody().getMessage()).isEqualTo("ERROR: [400] Unable to find Partner with uuid 12345-123454");
|
||||
assertThat(errorResponse.getBody().getMessage()).isEqualTo("ERROR: [400] Unable to find Entity with id 12345-123454");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
-1
@@ -643,7 +643,6 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
||||
final var givenProject = realProjectRepo.findByCaption(projectCaption).stream()
|
||||
.findAny().orElseThrow();
|
||||
final var newBookingItem = HsBookingItemRealEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.project(givenProject)
|
||||
.type(hsBookingItemType)
|
||||
.caption("some test-booking")
|
||||
|
||||
+6
-6
@@ -14,7 +14,7 @@ import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -48,23 +48,23 @@ class HsBookingItemControllerRestTest {
|
||||
@Autowired
|
||||
MockMvc mockMvc;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
Context contextMock;
|
||||
|
||||
@Autowired
|
||||
@SuppressWarnings("unused") // not used in test, but in controller class
|
||||
StrictMapper mapper;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
EntityManagerWrapper em;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
EntityManagerFactory emf;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HsBookingProjectRealRepository realProjectRepo;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HsBookingItemRbacRepository rbacBookingItemRepo;
|
||||
|
||||
@TestConfiguration
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ 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.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
|
||||
@@ -61,7 +61,7 @@ class HsBookingItemRepositoryIntegrationTest extends ContextBasedTestWithCleanup
|
||||
@PersistenceContext
|
||||
EntityManager em;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Test
|
||||
|
||||
-1
@@ -270,7 +270,6 @@ class HsBookingProjectControllerAcceptanceTest extends ContextBasedTestWithClean
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenDebitor = debitorRepo.findByDebitorNumber(debitorNumber).stream().findAny().orElseThrow();
|
||||
final var newBookingProject = HsBookingProjectRealEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.debitor(givenDebitor)
|
||||
.caption(caption)
|
||||
.build();
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
|
||||
@@ -56,7 +56,7 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
@PersistenceContext
|
||||
EntityManager em;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Test
|
||||
|
||||
-4
@@ -488,7 +488,6 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
||||
|
||||
final var givenAsset = givenSomeTemporaryHostingAsset(() ->
|
||||
HsHostingAssetRealEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.bookingItem(givenSomeNewBookingItem(
|
||||
"D-1000111 default project",
|
||||
HsBookingItemType.MANAGED_SERVER,
|
||||
@@ -571,7 +570,6 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
||||
|
||||
final var givenAsset = givenSomeTemporaryHostingAsset(() ->
|
||||
HsHostingAssetRealEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.type(UNIX_USER)
|
||||
.parentAsset(givenRealHostingAsset(MANAGED_WEBSPACE, "fir01"))
|
||||
.identifier("fir01-temp")
|
||||
@@ -648,7 +646,6 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenAsset = givenSomeTemporaryHostingAsset(() ->
|
||||
HsHostingAssetRealEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.bookingItem(givenSomeNewBookingItem(
|
||||
"D-1000111 default project",
|
||||
HsBookingItemType.MANAGED_SERVER,
|
||||
@@ -681,7 +678,6 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenAsset = givenSomeTemporaryHostingAsset(() ->
|
||||
HsHostingAssetRealEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.bookingItem(givenSomeNewBookingItem(
|
||||
"D-1000111 default project",
|
||||
HsBookingItemType.MANAGED_SERVER,
|
||||
|
||||
+10
-10
@@ -9,7 +9,7 @@ import net.hostsharing.hsadminng.config.JsonObjectMapperConfiguration;
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.hs.booking.item.HsBookingItemRealRepository;
|
||||
import net.hostsharing.hsadminng.mapper.Array;
|
||||
import net.hostsharing.hsadminng.mapper.StandardMapper;
|
||||
import net.hostsharing.hsadminng.mapper.StrictMapper;
|
||||
import net.hostsharing.hsadminng.persistence.EntityManagerWrapper;
|
||||
import net.hostsharing.hsadminng.config.DisableSecurityConfig;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -24,7 +24,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
@@ -54,7 +54,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@WebMvcTest(HsHostingAssetController.class)
|
||||
@Import({ StandardMapper.class, JsonObjectMapperConfiguration.class, DisableSecurityConfig.class })
|
||||
@Import({ StrictMapper.class, JsonObjectMapperConfiguration.class, DisableSecurityConfig.class })
|
||||
@RunWith(SpringRunner.class)
|
||||
@ActiveProfiles("test")
|
||||
public class HsHostingAssetControllerRestTest {
|
||||
@@ -62,27 +62,27 @@ public class HsHostingAssetControllerRestTest {
|
||||
@Autowired
|
||||
MockMvc mockMvc;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
Context contextMock;
|
||||
|
||||
@Autowired
|
||||
@SuppressWarnings("unused") // not used in test, but in controller class
|
||||
StandardMapper mapper;
|
||||
StrictMapper mapper;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
EntityManagerWrapper em;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
EntityManagerFactory emf;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
@SuppressWarnings("unused") // bean needs to be present for HsHostingAssetController
|
||||
private HsBookingItemRealRepository realBookingItemRepo;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
private HsHostingAssetRealRepository realAssetRepo;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
private HsHostingAssetRbacRepository rbacAssetRepo;
|
||||
|
||||
@TestConfiguration
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
|
||||
@@ -70,7 +70,7 @@ class HsHostingAssetRepositoryIntegrationTest extends ContextBasedTestWithCleanu
|
||||
@PersistenceContext
|
||||
EntityManager em;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Test
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import net.hostsharing.hsadminng.config.JsonObjectMapperConfiguration;
|
||||
import net.hostsharing.hsadminng.mapper.StandardMapper;
|
||||
import net.hostsharing.hsadminng.mapper.StrictMapper;
|
||||
import net.hostsharing.hsadminng.persistence.EntityManagerWrapper;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
@@ -59,7 +59,7 @@ class DomainSetupHostingAssetFactoryUnitTest {
|
||||
private ObjectMapper jsonMapper = new JsonObjectMapperConfiguration().customObjectMapper().build();
|
||||
|
||||
@Spy
|
||||
private StandardMapper standardMapper = new StandardMapper(emw);
|
||||
private StrictMapper StrictMapper = new StrictMapper(emw);
|
||||
|
||||
@InjectMocks
|
||||
private HsBookingItemCreatedListener listener;
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ import net.hostsharing.hsadminng.hs.booking.item.BookingItemCreatedEventEntity;
|
||||
import net.hostsharing.hsadminng.hs.booking.item.HsBookingItemRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.booking.item.HsBookingItemType;
|
||||
import net.hostsharing.hsadminng.lambda.Reducer;
|
||||
import net.hostsharing.hsadminng.mapper.StandardMapper;
|
||||
import net.hostsharing.hsadminng.mapper.StrictMapper;
|
||||
import net.hostsharing.hsadminng.persistence.EntityManagerWrapper;
|
||||
import net.hostsharing.hsadminng.persistence.EntityManagerWrapperFake;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -42,7 +42,7 @@ class HsBookingItemCreatedListenerUnitTest {
|
||||
private ObjectMapper jsonMapper = new JsonObjectMapperConfiguration().customObjectMapper().build();
|
||||
|
||||
@Spy
|
||||
private StandardMapper standardMapper = new StandardMapper(emw);
|
||||
private StrictMapper StrictMapper = new StrictMapper(emw);
|
||||
|
||||
@InjectMocks
|
||||
private HsBookingItemCreatedListener listener;
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ import net.hostsharing.hsadminng.hs.hosting.asset.validators.Dns;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContact;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity;
|
||||
import net.hostsharing.hsadminng.lambda.Reducer;
|
||||
import net.hostsharing.hsadminng.mapper.StandardMapper;
|
||||
import net.hostsharing.hsadminng.mapper.StrictMapper;
|
||||
import net.hostsharing.hsadminng.persistence.EntityManagerWrapper;
|
||||
import net.hostsharing.hsadminng.persistence.EntityManagerWrapperFake;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -55,7 +55,7 @@ class ManagedWebspaceHostingAssetFactoryUnitTest {
|
||||
private ObjectMapper jsonMapper = new JsonObjectMapperConfiguration().customObjectMapper().build();
|
||||
|
||||
@Spy
|
||||
private StandardMapper standardMapper = new StandardMapper(emw);
|
||||
private StrictMapper StrictMapper = new StrictMapper(emw);
|
||||
|
||||
@InjectMocks
|
||||
private HsBookingItemCreatedListener listener;
|
||||
|
||||
@@ -10,7 +10,7 @@ import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipStatus;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerDetailsEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation;
|
||||
@@ -84,7 +84,7 @@ public abstract class BaseOfficeDataImport extends CsvDataImport {
|
||||
|
||||
static Map<Integer, HsOfficeContactRealEntity> contacts = new WriteOnceMap<>();
|
||||
static Map<Integer, HsOfficePersonRealEntity> persons = new WriteOnceMap<>();
|
||||
static Map<Integer, HsOfficePartnerEntity> partners = new WriteOnceMap<>();
|
||||
static Map<Integer, HsOfficePartnerRealEntity> partners = new WriteOnceMap<>();
|
||||
static Map<Integer, HsOfficeDebitorEntity> debitors = new WriteOnceMap<>();
|
||||
static Map<Integer, HsOfficeMembershipEntity> memberships = new WriteOnceMap<>();
|
||||
|
||||
@@ -743,7 +743,7 @@ public abstract class BaseOfficeDataImport extends CsvDataImport {
|
||||
null // is set during contacts import depending on assigned roles
|
||||
);
|
||||
|
||||
final var partner = HsOfficePartnerEntity.builder()
|
||||
final var partner = HsOfficePartnerRealEntity.builder()
|
||||
.partnerNumber(rec.getInteger("member_id"))
|
||||
.details(HsOfficePartnerDetailsEntity.builder().build())
|
||||
.partnerRel(partnerRel)
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.junit.jupiter.api.extension.TestWatcher;
|
||||
import org.opentest4j.AssertionFailedError;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
@@ -76,7 +76,7 @@ public class CsvDataImport extends ContextBasedTest {
|
||||
@Autowired
|
||||
JpaAttempt jpaAttempt;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
|
||||
static final LinkedHashSet<String> errors = new LinkedHashSet<>();
|
||||
|
||||
+6
-6
@@ -1,13 +1,13 @@
|
||||
package net.hostsharing.hsadminng.hs.office.bankaccount;
|
||||
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.mapper.StandardMapper;
|
||||
import net.hostsharing.hsadminng.mapper.StrictMapper;
|
||||
import net.hostsharing.hsadminng.config.DisableSecurityConfig;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
@@ -26,14 +26,14 @@ class HsOfficeBankAccountControllerRestTest {
|
||||
@Autowired
|
||||
MockMvc mockMvc;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
Context contextMock;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
@SuppressWarnings("unused") // not used in test, but in controller class
|
||||
StandardMapper mapper;
|
||||
StrictMapper mapper;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HsOfficeBankAccountRepository bankAccountRepo;
|
||||
|
||||
enum InvalidIbanTestCase {
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ 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.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
@@ -46,7 +46,7 @@ class HsOfficeBankAccountRepositoryIntegrationTest extends ContextBasedTestWithC
|
||||
@Autowired
|
||||
JpaAttempt jpaAttempt;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Nested
|
||||
|
||||
-1
@@ -374,7 +374,6 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
return jpaAttempt.transacted(() -> {
|
||||
context.define(creatingUser);
|
||||
final var newContact = HsOfficeContactRbacEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.caption("Temp from " + Context.getCallerMethodNameFromStackFrame(1) )
|
||||
.postalAddress(Map.ofEntries(
|
||||
entry("name", RandomStringUtils.randomAlphabetic(6) + " " + RandomStringUtils.randomAlphabetic(10)),
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ 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.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
@@ -46,7 +46,7 @@ class HsOfficeContactRbacRepositoryIntegrationTest extends ContextBasedTestWithC
|
||||
@Autowired
|
||||
JpaAttempt jpaAttempt;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Nested
|
||||
|
||||
+8
-8
@@ -4,7 +4,7 @@ import net.hostsharing.hsadminng.config.JsonObjectMapperConfiguration;
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRealEntity;
|
||||
import net.hostsharing.hsadminng.mapper.StrictMapper;
|
||||
import net.hostsharing.hsadminng.persistence.EntityManagerWrapper;
|
||||
import net.hostsharing.hsadminng.rbac.test.JsonBuilder;
|
||||
@@ -17,10 +17,10 @@ import org.junit.jupiter.params.provider.EnumSource;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
@@ -67,7 +67,7 @@ class HsOfficeCoopAssetsTransactionControllerRestTest {
|
||||
private static final String ORIGIN_MEMBER_NUMBER = "M-1111100";
|
||||
public final HsOfficeMembershipEntity ORIGIN_TARGET_MEMBER_ENTITY = HsOfficeMembershipEntity.builder()
|
||||
.uuid(ORIGIN_MEMBERSHIP_UUID)
|
||||
.partner(HsOfficePartnerEntity.builder()
|
||||
.partner(HsOfficePartnerRealEntity.builder()
|
||||
.partnerNumber(partnerNumberOf(ORIGIN_MEMBER_NUMBER))
|
||||
.build())
|
||||
.memberNumberSuffix(suffixOf(ORIGIN_MEMBER_NUMBER))
|
||||
@@ -77,7 +77,7 @@ class HsOfficeCoopAssetsTransactionControllerRestTest {
|
||||
private static final String AVAILABLE_TARGET_MEMBER_NUMBER = "M-1234500";
|
||||
public final HsOfficeMembershipEntity AVAILABLE_MEMBER_ENTITY = HsOfficeMembershipEntity.builder()
|
||||
.uuid(AVAILABLE_TARGET_MEMBERSHIP_UUID)
|
||||
.partner(HsOfficePartnerEntity.builder()
|
||||
.partner(HsOfficePartnerRealEntity.builder()
|
||||
.partnerNumber(partnerNumberOf(AVAILABLE_TARGET_MEMBER_NUMBER))
|
||||
.build())
|
||||
.memberNumberSuffix(suffixOf(AVAILABLE_TARGET_MEMBER_NUMBER))
|
||||
@@ -499,20 +499,20 @@ class HsOfficeCoopAssetsTransactionControllerRestTest {
|
||||
@Autowired
|
||||
MockMvc mockMvc;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
Context contextMock;
|
||||
|
||||
@Autowired
|
||||
@SuppressWarnings("unused") // not used in test, but in controller class
|
||||
StrictMapper mapper;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
EntityManagerWrapper emw; // even if not used in test anymore, it's needed by base-class of StrictMapper
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HsOfficeCoopAssetsTransactionRepository coopAssetsTransactionRepo;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HsOfficeMembershipRepository membershipRepo;
|
||||
|
||||
static final String INSERT_REQUEST_BODY_TEMPLATE = """
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ 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.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
@@ -51,7 +51,7 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase
|
||||
@Autowired
|
||||
JpaAttempt jpaAttempt;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Nested
|
||||
|
||||
+84
-56
@@ -170,7 +170,9 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
|
||||
final var givenMembership = membershipRepo.findMembershipByMemberNumber(1000101).orElseThrow();
|
||||
|
||||
final var location = RestAssured // @formatter:off
|
||||
.given().header("current-subject", "superuser-alex@hostsharing.net").contentType(ContentType.JSON).body("""
|
||||
.given()
|
||||
.header("current-subject", "superuser-alex@hostsharing.net")
|
||||
.contentType(ContentType.JSON).body("""
|
||||
{
|
||||
"membership.uuid": "%s",
|
||||
"transactionType": "SUBSCRIPTION",
|
||||
@@ -179,15 +181,29 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
|
||||
"reference": "temp ref A",
|
||||
"comment": "just some test coop shares transaction"
|
||||
}
|
||||
""".formatted(givenMembership.getUuid())).port(port).when().post("http://localhost/api/hs/office/coopsharestransactions").then().log().all().assertThat().statusCode(201).contentType(ContentType.JSON).body("uuid", isUuidValid()).body("", lenientlyEquals("""
|
||||
""".formatted(givenMembership.getUuid()))
|
||||
.port(port)
|
||||
.when()
|
||||
.post("http://localhost/api/hs/office/coopsharestransactions")
|
||||
.then()
|
||||
.log().all()
|
||||
.assertThat()
|
||||
.statusCode(201)
|
||||
.contentType(ContentType.JSON)
|
||||
.body("uuid", isUuidValid())
|
||||
.body("", lenientlyEquals("""
|
||||
{
|
||||
"membership.uuid": "%s",
|
||||
"transactionType": "SUBSCRIPTION",
|
||||
"shareCount": 8,
|
||||
"valueDate": "2022-10-13",
|
||||
"reference": "temp ref A",
|
||||
"comment": "just some test coop shares transaction"
|
||||
}
|
||||
""")).header("Location", startsWith("http://localhost")).extract().header("Location"); // @formatter:on
|
||||
""".formatted(givenMembership.getUuid())))
|
||||
.header("Location", startsWith("http://localhost"))
|
||||
.extract()
|
||||
.header("Location"); // @formatter:on
|
||||
|
||||
// finally, the new coopSharesTransaction can be accessed under the generated UUID
|
||||
final var newShareTxUuid = UUID.fromString(location.substring(location.lastIndexOf('/') + 1));
|
||||
@@ -197,7 +213,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
|
||||
@Test
|
||||
void globalAdmin_canAddCoopSharesReversalTransaction() {
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
context.define("superuser-alex@hostsharing.net", "rbac.global#global:ADMIN");
|
||||
final var givenMembership = membershipRepo.findMembershipByMemberNumber(1000101).orElseThrow();
|
||||
final var givenTransaction = jpaAttempt.transacted(() -> {
|
||||
// TODO.impl: introduce something like transactedAsSuperuser / transactedAs("...", ...)
|
||||
@@ -214,46 +230,46 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
|
||||
|
||||
final var location = RestAssured // @formatter:off
|
||||
.given()
|
||||
.header("current-subject", "superuser-alex@hostsharing.net")
|
||||
.contentType(ContentType.JSON)
|
||||
.body("""
|
||||
{
|
||||
"membership.uuid": "%s",
|
||||
"transactionType": "REVERSAL",
|
||||
"shareCount": %s,
|
||||
"valueDate": "2022-10-30",
|
||||
"reference": "test reversal ref",
|
||||
"comment": "some coop shares reversal transaction",
|
||||
"revertedShareTx.uuid": "%s"
|
||||
}
|
||||
""".formatted(
|
||||
givenMembership.getUuid(),
|
||||
-givenTransaction.getShareCount(),
|
||||
givenTransaction.getUuid()))
|
||||
.port(port)
|
||||
.header("current-subject", "superuser-alex@hostsharing.net")
|
||||
.contentType(ContentType.JSON)
|
||||
.body("""
|
||||
{
|
||||
"membership.uuid": "%s",
|
||||
"transactionType": "REVERSAL",
|
||||
"shareCount": %s,
|
||||
"valueDate": "2022-10-30",
|
||||
"reference": "test reversal ref",
|
||||
"comment": "some coop shares reversal transaction",
|
||||
"revertedShareTx.uuid": "%s"
|
||||
}
|
||||
""".formatted(
|
||||
givenMembership.getUuid(),
|
||||
-givenTransaction.getShareCount(),
|
||||
givenTransaction.getUuid()))
|
||||
.port(port)
|
||||
.when()
|
||||
.post("http://localhost/api/hs/office/coopsharestransactions")
|
||||
.post("http://localhost/api/hs/office/coopsharestransactions")
|
||||
.then().log().all().assertThat()
|
||||
.statusCode(201)
|
||||
.contentType(ContentType.JSON)
|
||||
.body("uuid", isUuidValid())
|
||||
.body("", lenientlyEquals("""
|
||||
{
|
||||
"transactionType": "REVERSAL",
|
||||
"shareCount": -13,
|
||||
"valueDate": "2022-10-30",
|
||||
"reference": "test reversal ref",
|
||||
"comment": "some coop shares reversal transaction",
|
||||
"revertedShareTx": {
|
||||
"transactionType": "SUBSCRIPTION",
|
||||
"shareCount": 13,
|
||||
"valueDate": "2022-10-20",
|
||||
"reference": "test ref"
|
||||
}
|
||||
.statusCode(201)
|
||||
.contentType(ContentType.JSON)
|
||||
.body("uuid", isUuidValid())
|
||||
.body("", lenientlyEquals("""
|
||||
{
|
||||
"transactionType": "REVERSAL",
|
||||
"shareCount": -13,
|
||||
"valueDate": "2022-10-30",
|
||||
"reference": "test reversal ref",
|
||||
"comment": "some coop shares reversal transaction",
|
||||
"revertedShareTx": {
|
||||
"transactionType": "SUBSCRIPTION",
|
||||
"shareCount": 13,
|
||||
"valueDate": "2022-10-20",
|
||||
"reference": "test ref"
|
||||
}
|
||||
"""))
|
||||
.header("Location", startsWith("http://localhost"))
|
||||
.extract().header("Location"); // @formatter:on
|
||||
}
|
||||
"""))
|
||||
.header("Location", startsWith("http://localhost"))
|
||||
.extract().header("Location"); // @formatter:on
|
||||
|
||||
// finally, the new coopAssetsTransaction can be accessed under the generated UUID
|
||||
final var newShareTxUuid = UUID.fromString(
|
||||
@@ -269,22 +285,34 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
|
||||
final var givenMembership = membershipRepo.findMembershipByMemberNumber(1000101).orElseThrow();
|
||||
|
||||
RestAssured // @formatter:off
|
||||
.given().header("current-subject", "superuser-alex@hostsharing.net").contentType(ContentType.JSON).body("""
|
||||
{
|
||||
"membership.uuid": "%s",
|
||||
"transactionType": "CANCELLATION",
|
||||
"shareCount": -80,
|
||||
"valueDate": "2022-10-13",
|
||||
"reference": "temp ref X",
|
||||
"comment": "just some test coop shares transaction"
|
||||
}
|
||||
""".formatted(givenMembership.getUuid())).port(port).when().post("http://localhost/api/hs/office/coopsharestransactions").then().log().all().assertThat().statusCode(400).contentType(ContentType.JSON).body("", lenientlyEquals("""
|
||||
.given()
|
||||
.header("current-subject", "superuser-alex@hostsharing.net")
|
||||
.contentType(ContentType.JSON)
|
||||
.body("""
|
||||
{
|
||||
"statusCode": 400,
|
||||
"statusPhrase": "Bad Request",
|
||||
"message": "ERROR: [400] coop shares transaction would result in a negative number of shares"
|
||||
}
|
||||
""")); // @formatter:on
|
||||
"membership.uuid": "%s",
|
||||
"transactionType": "CANCELLATION",
|
||||
"shareCount": -80,
|
||||
"valueDate": "2022-10-13",
|
||||
"reference": "temp ref X",
|
||||
"comment": "just some test coop shares transaction"
|
||||
}
|
||||
""".formatted(givenMembership.getUuid()))
|
||||
.port(port)
|
||||
.when()
|
||||
.post("http://localhost/api/hs/office/coopsharestransactions")
|
||||
.then()
|
||||
.log().all()
|
||||
.assertThat()
|
||||
.statusCode(400)
|
||||
.contentType(ContentType.JSON)
|
||||
.body("", lenientlyEquals("""
|
||||
{
|
||||
"statusCode": 400,
|
||||
"statusPhrase": "Bad Request",
|
||||
"message": "ERROR: [400] coop shares transaction would result in a negative number of shares"
|
||||
}
|
||||
""")); // @formatter:on
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-6
@@ -1,14 +1,15 @@
|
||||
package net.hostsharing.hsadminng.hs.office.coopshares;
|
||||
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.mapper.StandardMapper;
|
||||
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipRepository;
|
||||
import net.hostsharing.hsadminng.mapper.StrictMapper;
|
||||
import net.hostsharing.hsadminng.rbac.test.JsonBuilder;
|
||||
import net.hostsharing.hsadminng.config.DisableSecurityConfig;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
@@ -31,16 +32,19 @@ class HsOfficeCoopSharesTransactionControllerRestTest {
|
||||
@Autowired
|
||||
MockMvc mockMvc;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
Context contextMock;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
@SuppressWarnings("unused") // not used in test, but in controller class
|
||||
StandardMapper mapper;
|
||||
StrictMapper mapper;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HsOfficeCoopSharesTransactionRepository coopSharesTransactionRepo;
|
||||
|
||||
@MockitoBean
|
||||
HsOfficeMembershipRepository membershipRepo;
|
||||
|
||||
static final String VALID_INSERT_REQUEST_BODY = """
|
||||
{
|
||||
"membership.uuid": "%s",
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ 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.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
@@ -50,7 +50,7 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase
|
||||
@Autowired
|
||||
JpaAttempt jpaAttempt;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Nested
|
||||
|
||||
+11
-10
@@ -6,7 +6,7 @@ import net.hostsharing.hsadminng.HsadminNgApplication;
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRbacRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository;
|
||||
@@ -28,6 +28,7 @@ import jakarta.persistence.PersistenceContext;
|
||||
import java.util.UUID;
|
||||
|
||||
import static net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType.DEBITOR;
|
||||
import static net.hostsharing.hsadminng.rbac.role.RbacRoleType.ADMIN;
|
||||
import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid;
|
||||
import static net.hostsharing.hsadminng.test.JsonMatcher.lenientlyEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -57,7 +58,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
HsOfficeDebitorRepository debitorRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficePartnerRepository partnerRepo;
|
||||
HsOfficePartnerRbacRepository partnerRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficeContactRealRepository contactRealRepo;
|
||||
@@ -467,7 +468,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
.post("http://localhost/api/hs/office/debitors")
|
||||
.then().log().all().assertThat()
|
||||
.statusCode(400)
|
||||
.body("message", is("ERROR: [400] Unable to find RealContact by debitorRel.contactUuid: 00000000-0000-0000-0000-000000000000"));
|
||||
.body("message", is("ERROR: [400] Unable to find debitorRel.contact.uuid: 00000000-0000-0000-0000-000000000000"));
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@@ -495,7 +496,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
.post("http://localhost/api/hs/office/debitors")
|
||||
.then().log().all().assertThat()
|
||||
.statusCode(400)
|
||||
.body("message", is("ERROR: [400] Unable to find RealRelation by debitorRelUuid: 00000000-0000-0000-0000-000000000000"));
|
||||
.body("message", is("ERROR: [400] Unable to find debitorRel.uuid: 00000000-0000-0000-0000-000000000000"));
|
||||
// @formatter:on
|
||||
}
|
||||
}
|
||||
@@ -695,16 +696,16 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
}
|
||||
|
||||
@Test
|
||||
void theContactOwner_canNotPatchARelatedDebitor() {
|
||||
void theContactAdmin_canNotPatchARelatedDebitor() {
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenDebitor = givenSomeTemporaryDebitor();
|
||||
|
||||
// @formatter:on
|
||||
RestAssured // @formatter:off
|
||||
.given()
|
||||
.given()
|
||||
.header("current-subject", "superuser-alex@hostsharing.net")
|
||||
.header("assumed-roles", "hs_office.contact#tenthcontact:ADMIN")
|
||||
.header("assumed-roles", givenDebitor.getDebitorRel().getContact().roleId(ADMIN) )
|
||||
.contentType(ContentType.JSON)
|
||||
.body("""
|
||||
{
|
||||
@@ -712,9 +713,9 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
}
|
||||
""")
|
||||
.port(port)
|
||||
.when()
|
||||
.when()
|
||||
.patch("http://localhost/api/hs/office/debitors/" + givenDebitor.getUuid())
|
||||
.then().log().all().assertThat()
|
||||
.then().log().all().assertThat()
|
||||
.statusCode(403)
|
||||
.body("message", containsString("ERROR: [403] Subject"))
|
||||
.body("message", containsString("is not allowed to update hs_office.debitor uuid "));
|
||||
@@ -802,7 +803,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
.vatReverseCharge(false)
|
||||
.build();
|
||||
|
||||
return debitorRepo.save(newDebitor).load();
|
||||
return debitorRepo.save(newDebitor).reload(em);
|
||||
}).assertSuccessful().returnedValue();
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -1,7 +1,7 @@
|
||||
package net.hostsharing.hsadminng.hs.office.debitor;
|
||||
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
|
||||
@@ -30,7 +30,7 @@ class HsOfficeDebitorEntityUnitTest {
|
||||
.debitorNumberSuffix("67")
|
||||
.debitorRel(givenDebitorRel)
|
||||
.defaultPrefix("som")
|
||||
.partner(HsOfficePartnerEntity.builder()
|
||||
.partner(HsOfficePartnerRealEntity.builder()
|
||||
.partnerNumber(12345)
|
||||
.build())
|
||||
.build();
|
||||
@@ -45,7 +45,7 @@ class HsOfficeDebitorEntityUnitTest {
|
||||
final var given = HsOfficeDebitorEntity.builder()
|
||||
.debitorRel(givenDebitorRel)
|
||||
.debitorNumberSuffix("67")
|
||||
.partner(HsOfficePartnerEntity.builder()
|
||||
.partner(HsOfficePartnerRealEntity.builder()
|
||||
.partnerNumber(12345)
|
||||
.build())
|
||||
.build();
|
||||
@@ -60,7 +60,7 @@ class HsOfficeDebitorEntityUnitTest {
|
||||
final var given = HsOfficeDebitorEntity.builder()
|
||||
.debitorRel(givenDebitorRel)
|
||||
.debitorNumberSuffix("67")
|
||||
.partner(HsOfficePartnerEntity.builder()
|
||||
.partner(HsOfficePartnerRealEntity.builder()
|
||||
.partnerNumber(12345)
|
||||
.build())
|
||||
.build();
|
||||
@@ -88,7 +88,7 @@ class HsOfficeDebitorEntityUnitTest {
|
||||
final var given = HsOfficeDebitorEntity.builder()
|
||||
.debitorRel(givenDebitorRel)
|
||||
.debitorNumberSuffix("67")
|
||||
.partner(HsOfficePartnerEntity.builder().build())
|
||||
.partner(HsOfficePartnerRealEntity.builder().build())
|
||||
.build();
|
||||
|
||||
final var result = given.getTaggedDebitorNumber();
|
||||
@@ -101,7 +101,7 @@ class HsOfficeDebitorEntityUnitTest {
|
||||
final var given = HsOfficeDebitorEntity.builder()
|
||||
.debitorRel(givenDebitorRel)
|
||||
.debitorNumberSuffix(null)
|
||||
.partner(HsOfficePartnerEntity.builder()
|
||||
.partner(HsOfficePartnerRealEntity.builder()
|
||||
.partnerNumber(12345)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
+4
-4
@@ -3,7 +3,7 @@ package net.hostsharing.hsadminng.hs.office.debitor;
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRealRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
|
||||
@@ -22,7 +22,7 @@ import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -48,7 +48,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
HsOfficeDebitorRepository debitorRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficePartnerRepository partnerRepo;
|
||||
HsOfficePartnerRealRepository partnerRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficeContactRealRepository contactRealRepo;
|
||||
@@ -74,7 +74,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
@Autowired
|
||||
RbacGrantsDiagramService mermaidService;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
@Nested
|
||||
class CreateDebitor {
|
||||
|
||||
@@ -5,7 +5,7 @@ import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
|
||||
|
||||
import static net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealTestEntity.TEST_REAL_CONTACT;
|
||||
import static net.hostsharing.hsadminng.hs.office.partner.TestHsOfficePartner.TEST_PARTNER;
|
||||
import static net.hostsharing.hsadminng.hs.office.partner.HsOfficeTestRealPartner.TEST_PARTNER;
|
||||
|
||||
@UtilityClass
|
||||
public class TestHsOfficeDebitor {
|
||||
|
||||
+2
-3
@@ -5,7 +5,7 @@ import io.restassured.RestAssured;
|
||||
import io.restassured.http.ContentType;
|
||||
import net.hostsharing.hsadminng.HsadminNgApplication;
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRealRepository;
|
||||
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
|
||||
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
|
||||
import net.hostsharing.hsadminng.config.DisableSecurityConfig;
|
||||
@@ -54,7 +54,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
|
||||
HsOfficeMembershipRepository membershipRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficePartnerRepository partnerRepo;
|
||||
HsOfficePartnerRealRepository partnerRepo;
|
||||
|
||||
@Autowired
|
||||
JpaAttempt jpaAttempt;
|
||||
@@ -430,7 +430,6 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike(partnerName).get(0);
|
||||
final var newMembership = HsOfficeMembershipEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.partner(givenPartner)
|
||||
.memberNumberSuffix(TEMP_MEMBER_NUMBER_SUFFIX)
|
||||
.validity(Range.closedInfinite(LocalDate.parse("2022-11-01")))
|
||||
|
||||
+16
-11
@@ -2,8 +2,10 @@ package net.hostsharing.hsadminng.hs.office.membership;
|
||||
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.hs.office.coopassets.HsOfficeCoopAssetsTransactionRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
|
||||
import net.hostsharing.hsadminng.mapper.StandardMapper;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRbacEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRealRepository;
|
||||
import net.hostsharing.hsadminng.mapper.StrictMapper;
|
||||
import net.hostsharing.hsadminng.persistence.EntityManagerWrapper;
|
||||
import net.hostsharing.hsadminng.config.DisableSecurityConfig;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
@@ -12,7 +14,7 @@ import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
@@ -34,11 +36,11 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@WebMvcTest(HsOfficeMembershipController.class)
|
||||
@Import({StandardMapper.class, DisableSecurityConfig.class})
|
||||
@Import({StrictMapper.class, DisableSecurityConfig.class})
|
||||
@ActiveProfiles("test")
|
||||
public class HsOfficeMembershipControllerRestTest {
|
||||
|
||||
private static final HsOfficePartnerEntity PARTNER_12345 = HsOfficePartnerEntity.builder()
|
||||
private static final HsOfficePartnerRealEntity PARTNER_12345 = HsOfficePartnerRealEntity.builder()
|
||||
.partnerNumber(12345)
|
||||
.build();
|
||||
public static final HsOfficeMembershipEntity MEMBERSHIP_1234501 = HsOfficeMembershipEntity.builder()
|
||||
@@ -69,16 +71,19 @@ public class HsOfficeMembershipControllerRestTest {
|
||||
@Autowired
|
||||
MockMvc mockMvc;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
Context contextMock;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HsOfficeCoopAssetsTransactionRepository coopAssetsTransactionRepo;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HsOfficePartnerRealRepository partnerRepo;
|
||||
|
||||
@MockitoBean
|
||||
HsOfficeMembershipRepository membershipRepo;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
EntityManagerWrapper em;
|
||||
|
||||
@Nested
|
||||
@@ -252,7 +257,7 @@ public class HsOfficeMembershipControllerRestTest {
|
||||
|
||||
// given
|
||||
final var givenPartnerUuid = UUID.randomUUID();
|
||||
when(em.find(HsOfficePartnerEntity.class, givenPartnerUuid)).thenReturn(null);
|
||||
when(em.find(HsOfficePartnerRbacEntity.class, givenPartnerUuid)).thenReturn(null);
|
||||
|
||||
// when
|
||||
mockMvc.perform(MockMvcRequestBuilders
|
||||
@@ -275,7 +280,7 @@ public class HsOfficeMembershipControllerRestTest {
|
||||
.andExpect(jsonPath("statusPhrase", is("Bad Request")))
|
||||
.andExpect(jsonPath(
|
||||
"message",
|
||||
is("ERROR: [400] Unable to find Partner by partner.uuid: " + givenPartnerUuid)));
|
||||
is("ERROR: [400] partnerUuid " + givenPartnerUuid + " not found")));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
|
||||
+3
-3
@@ -4,7 +4,7 @@ import io.hypersistence.utils.hibernate.type.range.Range;
|
||||
import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeMembershipPatchResource;
|
||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeMembershipStatusResource;
|
||||
import net.hostsharing.hsadminng.mapper.StandardMapper;
|
||||
import net.hostsharing.hsadminng.mapper.StrictMapper;
|
||||
import net.hostsharing.hsadminng.persistence.EntityManagerWrapper;
|
||||
import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -17,7 +17,7 @@ import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static net.hostsharing.hsadminng.hs.office.partner.TestHsOfficePartner.TEST_PARTNER;
|
||||
import static net.hostsharing.hsadminng.hs.office.partner.HsOfficeTestRealPartner.TEST_PARTNER;
|
||||
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
@@ -40,7 +40,7 @@ class HsOfficeMembershipEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
@Mock
|
||||
private EntityManagerWrapper em;
|
||||
|
||||
private StandardMapper mapper = new StandardMapper(em);
|
||||
private StrictMapper mapper = new StrictMapper(em);
|
||||
|
||||
@BeforeEach
|
||||
void initMocks() {
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package net.hostsharing.hsadminng.hs.office.membership;
|
||||
|
||||
import io.hypersistence.utils.hibernate.type.range.Range;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRealEntity;
|
||||
import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static net.hostsharing.hsadminng.hs.office.partner.TestHsOfficePartner.TEST_PARTNER;
|
||||
import static net.hostsharing.hsadminng.hs.office.partner.HsOfficeTestRealPartner.TEST_PARTNER;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class HsOfficeMembershipEntityUnitTest {
|
||||
@@ -57,7 +57,7 @@ class HsOfficeMembershipEntityUnitTest {
|
||||
|
||||
@Test
|
||||
void getMemberNumberWithoutPartnerNumberButWithSuffix() {
|
||||
givenMembership.setPartner(HsOfficePartnerEntity.builder().build());
|
||||
givenMembership.setPartner(HsOfficePartnerRealEntity.builder().build());
|
||||
final var result = givenMembership.getMemberNumber();
|
||||
assertThat(result).isEqualTo(null);
|
||||
}
|
||||
|
||||
+4
-4
@@ -3,7 +3,7 @@ package net.hostsharing.hsadminng.hs.office.membership;
|
||||
import io.hypersistence.utils.hibernate.type.range.Range;
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRealRepository;
|
||||
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
|
||||
import net.hostsharing.hsadminng.rbac.grant.RawRbacGrantRepository;
|
||||
import net.hostsharing.hsadminng.rbac.role.RawRbacRoleRepository;
|
||||
@@ -13,7 +13,7 @@ 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.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
|
||||
@@ -37,7 +37,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTestWithCl
|
||||
HsOfficeMembershipRepository membershipRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficePartnerRepository partnerRepo;
|
||||
HsOfficePartnerRealRepository partnerRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficeDebitorRepository debitorRepo;
|
||||
@@ -54,7 +54,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTestWithCl
|
||||
@Autowired
|
||||
JpaAttempt jpaAttempt;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Nested
|
||||
|
||||
@@ -4,7 +4,7 @@ import io.hypersistence.utils.hibernate.type.range.Range;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import static net.hostsharing.hsadminng.hs.office.partner.TestHsOfficePartner.TEST_PARTNER;
|
||||
import static net.hostsharing.hsadminng.hs.office.partner.HsOfficeTestRealPartner.TEST_PARTNER;
|
||||
|
||||
public class TestHsMembership {
|
||||
|
||||
|
||||
+4
-4
@@ -42,7 +42,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
private Integer port;
|
||||
|
||||
@Autowired
|
||||
HsOfficePartnerRepository partnerRepo;
|
||||
HsOfficePartnerRbacRepository partnerRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficeRelationRealRepository relationRepo;
|
||||
@@ -541,12 +541,12 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
return partnerRel;
|
||||
}).assertSuccessful().returnedValue();
|
||||
}
|
||||
private HsOfficePartnerEntity givenSomeTemporaryPartnerBessler(final Integer partnerNumber) {
|
||||
private HsOfficePartnerRbacEntity givenSomeTemporaryPartnerBessler(final Integer partnerNumber) {
|
||||
return jpaAttempt.transacted(() -> {
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var partnerRel = em.merge(givenSomeTemporaryPartnerRel("Erben Bessler", "fourth contact"));
|
||||
|
||||
final var newPartner = HsOfficePartnerEntity.builder()
|
||||
final var newPartner = HsOfficePartnerRbacEntity.builder()
|
||||
.partnerRel(partnerRel)
|
||||
.partnerNumber(partnerNumber)
|
||||
.details(HsOfficePartnerDetailsEntity.builder()
|
||||
@@ -561,7 +561,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
|
||||
@AfterEach
|
||||
void cleanup() {
|
||||
cleanupAllNew(HsOfficePartnerEntity.class);
|
||||
cleanupAllNew(HsOfficePartnerRbacEntity.class);
|
||||
|
||||
// TODO: should not be necessary anymore, once it's deleted via after delete trigger
|
||||
cleanupAllNew(HsOfficeRelationRealEntity.class);
|
||||
|
||||
+11
-11
@@ -5,7 +5,7 @@ import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRbacEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository;
|
||||
import net.hostsharing.hsadminng.mapper.StandardMapper;
|
||||
import net.hostsharing.hsadminng.mapper.StrictMapper;
|
||||
import net.hostsharing.hsadminng.persistence.EntityManagerWrapper;
|
||||
import net.hostsharing.hsadminng.config.DisableSecurityConfig;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
@@ -38,7 +38,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@WebMvcTest(HsOfficePartnerController.class)
|
||||
@Import({StandardMapper.class, DisableSecurityConfig.class})
|
||||
@Import({StrictMapper.class, DisableSecurityConfig.class})
|
||||
@ActiveProfiles("test")
|
||||
class HsOfficePartnerControllerRestTest {
|
||||
|
||||
@@ -50,19 +50,19 @@ class HsOfficePartnerControllerRestTest {
|
||||
@Autowired
|
||||
MockMvc mockMvc;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
Context contextMock;
|
||||
|
||||
@MockBean
|
||||
HsOfficePartnerRepository partnerRepo;
|
||||
@MockitoBean
|
||||
HsOfficePartnerRbacRepository partnerRepo;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HsOfficeRelationRealRepository relationRepo;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
EntityManagerWrapper em;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
EntityManagerFactory emf;
|
||||
|
||||
@Mock
|
||||
@@ -75,7 +75,7 @@ class HsOfficePartnerControllerRestTest {
|
||||
HsOfficeContactRbacEntity contactMock;
|
||||
|
||||
@Mock
|
||||
HsOfficePartnerEntity partnerMock;
|
||||
HsOfficePartnerRbacEntity partnerMock;
|
||||
|
||||
@BeforeEach
|
||||
void init() {
|
||||
@@ -174,7 +174,7 @@ class HsOfficePartnerControllerRestTest {
|
||||
@Test
|
||||
void respondWithPartner_ifPartnerNumberIsAvailable() throws Exception {
|
||||
// given
|
||||
when(partnerRepo.findPartnerByPartnerNumber(12345)).thenReturn(Optional.of(HsOfficePartnerEntity.builder()
|
||||
when(partnerRepo.findPartnerByPartnerNumber(12345)).thenReturn(Optional.of(HsOfficePartnerRbacEntity.builder()
|
||||
.partnerNumber(12345)
|
||||
.build()));
|
||||
|
||||
|
||||
+5
-5
@@ -24,7 +24,7 @@ import static org.mockito.Mockito.lenient;
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class HsOfficePartnerEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
HsOfficePartnerPatchResource,
|
||||
HsOfficePartnerEntity
|
||||
HsOfficePartnerRbacEntity
|
||||
> {
|
||||
|
||||
private static final UUID INITIAL_PARTNER_UUID = UUID.randomUUID();
|
||||
@@ -53,8 +53,8 @@ class HsOfficePartnerEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HsOfficePartnerEntity newInitialEntity() {
|
||||
final var entity = HsOfficePartnerEntity.builder()
|
||||
protected HsOfficePartnerRbacEntity newInitialEntity() {
|
||||
final var entity = HsOfficePartnerRbacEntity.builder()
|
||||
.uuid(INITIAL_PARTNER_UUID)
|
||||
.partnerNumber(12345)
|
||||
.partnerRel(HsOfficeRelationRealEntity.builder()
|
||||
@@ -72,7 +72,7 @@ class HsOfficePartnerEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HsOfficePartnerEntityPatcher createPatcher(final HsOfficePartnerEntity partner) {
|
||||
protected HsOfficePartnerEntityPatcher createPatcher(final HsOfficePartnerRbacEntity partner) {
|
||||
return new HsOfficePartnerEntityPatcher(em, partner);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ class HsOfficePartnerEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
"partnerRel",
|
||||
HsOfficePartnerPatchResource::setPartnerRelUuid,
|
||||
PATCHED_PARTNER_ROLE_UUID,
|
||||
HsOfficePartnerEntity::setPartnerRel,
|
||||
HsOfficePartnerRbacEntity::setPartnerRel,
|
||||
newPartnerRel(PATCHED_PARTNER_ROLE_UUID))
|
||||
.notNullable()
|
||||
);
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class HsOfficePartnerEntityUnitTest {
|
||||
|
||||
private final HsOfficePartnerEntity givenPartner = HsOfficePartnerEntity.builder()
|
||||
private final HsOfficePartnerRbacEntity givenPartner = HsOfficePartnerRbacEntity.builder()
|
||||
.partnerNumber(12345)
|
||||
.partnerRel(HsOfficeRelationRealEntity.builder()
|
||||
.anchor(HsOfficePersonRealEntity.builder()
|
||||
@@ -42,7 +42,7 @@ class HsOfficePartnerEntityUnitTest {
|
||||
|
||||
@Test
|
||||
void definesRbac() {
|
||||
final var rbacFlowchart = new RbacViewMermaidFlowchartGenerator(HsOfficePartnerEntity.rbac()).toString();
|
||||
final var rbacFlowchart = new RbacViewMermaidFlowchartGenerator(HsOfficePartnerRbacEntity.rbac()).toString();
|
||||
assertThat(rbacFlowchart).isEqualTo("""
|
||||
%%{init:{'flowchart':{'htmlLabels':false}}}%%
|
||||
flowchart TB
|
||||
|
||||
+88
-81
@@ -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.boot.test.mock.mockito.MockBean;
|
||||
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,20 +27,21 @@ 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;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DataJpaTest
|
||||
@Import( { Context.class, JpaAttempt.class })
|
||||
class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithCleanup {
|
||||
@Import({ Context.class, JpaAttempt.class })
|
||||
class HsOfficePartnerRbacRepositoryIntegrationTest extends ContextBasedTestWithCleanup {
|
||||
|
||||
@Autowired
|
||||
HsOfficePartnerRepository partnerRepo;
|
||||
HsOfficePartnerRbacRepository partnerRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficeRelationRealRepository relationRepo;
|
||||
@@ -66,7 +67,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
@Autowired
|
||||
JpaAttempt jpaAttempt;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Nested
|
||||
@@ -80,18 +81,19 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
final var partnerRel = givenSomeTemporaryHostsharingPartnerRel("Winkler", "first contact");
|
||||
|
||||
// when
|
||||
final var result = attempt(em, () -> {
|
||||
final var newPartner = HsOfficePartnerEntity.builder()
|
||||
.partnerNumber(20031)
|
||||
.partnerRel(partnerRel)
|
||||
.details(HsOfficePartnerDetailsEntity.builder().build())
|
||||
.build();
|
||||
return partnerRepo.save(newPartner);
|
||||
});
|
||||
final var result = attempt(
|
||||
em, () -> {
|
||||
final var newPartner = HsOfficePartnerRbacEntity.builder()
|
||||
.partnerNumber(20031)
|
||||
.partnerRel(partnerRel)
|
||||
.details(HsOfficePartnerDetailsEntity.builder().build())
|
||||
.build();
|
||||
return partnerRepo.save(newPartner);
|
||||
});
|
||||
|
||||
// then
|
||||
result.assertSuccessful();
|
||||
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePartnerEntity::getUuid).isNotNull();
|
||||
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePartnerRbacEntity::getUuid).isNotNull();
|
||||
assertThatPartnerIsPersisted(result.returnedValue());
|
||||
assertThat(partnerRepo.count()).isEqualTo(count + 1);
|
||||
}
|
||||
@@ -108,26 +110,27 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
.toList();
|
||||
|
||||
// when
|
||||
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);
|
||||
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);
|
||||
|
||||
final var newRelation = HsOfficeRelationRealEntity.builder()
|
||||
.holder(givenPartnerPerson)
|
||||
.type(HsOfficeRelationType.PARTNER)
|
||||
.anchor(givenMandantPerson)
|
||||
.contact(givenContact)
|
||||
.build();
|
||||
relationRepo.save(newRelation);
|
||||
final var newRelation = HsOfficeRelationRealEntity.builder()
|
||||
.holder(givenPartnerPerson)
|
||||
.type(HsOfficeRelationType.PARTNER)
|
||||
.anchor(givenMandantPerson)
|
||||
.contact(givenContact)
|
||||
.build();
|
||||
relationRepo.save(newRelation);
|
||||
|
||||
final var newPartner = HsOfficePartnerEntity.builder()
|
||||
.partnerNumber(20032)
|
||||
.partnerRel(newRelation)
|
||||
.details(HsOfficePartnerDetailsEntity.builder().build())
|
||||
.build();
|
||||
return partnerRepo.save(newPartner);
|
||||
}).assertSuccessful();
|
||||
final var newPartner = HsOfficePartnerRbacEntity.builder()
|
||||
.partnerNumber(20032)
|
||||
.partnerRel(newRelation)
|
||||
.details(HsOfficePartnerDetailsEntity.builder().build())
|
||||
.build();
|
||||
return partnerRepo.save(newPartner);
|
||||
}).assertSuccessful();
|
||||
|
||||
// then
|
||||
assertThat(distinctRoleNamesOf(rawRoleRepo.findAll())).containsExactlyInAnyOrder(from(
|
||||
@@ -179,7 +182,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
null)));
|
||||
}
|
||||
|
||||
private void assertThatPartnerIsPersisted(final HsOfficePartnerEntity saved) {
|
||||
private void assertThatPartnerIsPersisted(final HsOfficePartnerRbacEntity saved) {
|
||||
final var found = partnerRepo.findByUuid(saved.getUuid());
|
||||
assertThat(found).isNotEmpty().get().extracting(Object::toString).isEqualTo(saved.toString());
|
||||
}
|
||||
@@ -207,15 +210,32 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
}
|
||||
|
||||
@Test
|
||||
public void normalUser_canViewOnlyRelatedPartners() {
|
||||
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",
|
||||
"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)+null");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +243,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
class FindByNameLike {
|
||||
|
||||
@Test
|
||||
public void globalAdmin_withoutAssumedRole_canViewAllPartners() {
|
||||
public void globalAdmin_withoutAssumedRole_canViewAllPartnersWithDetails() {
|
||||
// given
|
||||
context("superuser-alex@hostsharing.net");
|
||||
|
||||
@@ -231,7 +251,8 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
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))");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,19 +310,20 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
}
|
||||
|
||||
@Test
|
||||
public void partnerRelationAgent_canUpdateRelatedPartner() {
|
||||
public void partnerRelationAgent_canUpdateRelatedPartnerDetails() {
|
||||
// given
|
||||
context("superuser-alex@hostsharing.net");
|
||||
final var givenPartner = givenSomeTemporaryHostsharingPartner(20037, "Erben Bessler", "ninth");
|
||||
assertThatPartnerIsVisibleForUserWithRole(
|
||||
givenPartner,
|
||||
"hs_office.person#ErbenBesslerMelBessler:ADMIN");
|
||||
givenPartner.getPartnerRel().roleId(AGENT));
|
||||
assertThatPartnerActuallyInDatabase(givenPartner);
|
||||
|
||||
// when
|
||||
final var result = jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net",
|
||||
"hs_office.person#ErbenBesslerMelBessler:ADMIN");
|
||||
context(
|
||||
"superuser-alex@hostsharing.net",
|
||||
givenPartner.getPartnerRel().roleId(AGENT));
|
||||
givenPartner.getDetails().setBirthName("new birthname");
|
||||
return partnerRepo.save(givenPartner);
|
||||
});
|
||||
@@ -310,37 +332,17 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
result.assertSuccessful();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void partnerRelationTenant_canNotUpdateRelatedPartner() {
|
||||
// given
|
||||
context("superuser-alex@hostsharing.net");
|
||||
final var givenPartner = givenSomeTemporaryHostsharingPartner(20037, "Erben Bessler", "ninth");
|
||||
assertThatPartnerIsVisibleForUserWithRole(
|
||||
givenPartner,
|
||||
"hs_office.person#ErbenBesslerMelBessler:ADMIN");
|
||||
assertThatPartnerActuallyInDatabase(givenPartner);
|
||||
|
||||
// when
|
||||
final var result = jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net",
|
||||
"hs_office.relation#HostsharingeG-with-PARTNER-ErbenBesslerMelBessler:TENANT");
|
||||
givenPartner.getDetails().setBirthName("new birthname");
|
||||
return partnerRepo.save(givenPartner);
|
||||
});
|
||||
|
||||
// then
|
||||
result.assertExceptionWithRootCauseMessage(JpaSystemException.class,
|
||||
"ERROR: [403] insert into hs_office.partner_details ",
|
||||
" not allowed for current subjects {hs_office.relation#HostsharingeG-with-PARTNER-ErbenBesslerMelBessler:TENANT}");
|
||||
}
|
||||
|
||||
private void assertThatPartnerActuallyInDatabase(final HsOfficePartnerEntity saved) {
|
||||
private void assertThatPartnerActuallyInDatabase(final HsOfficePartnerRbacEntity saved) {
|
||||
final var found = partnerRepo.findByUuid(saved.getUuid());
|
||||
assertThat(found).isNotEmpty().get().isNotSameAs(saved).extracting(HsOfficePartnerEntity::toString).isEqualTo(saved.toString());
|
||||
assertThat(found).isNotEmpty()
|
||||
.get()
|
||||
.isNotSameAs(saved)
|
||||
.extracting(HsOfficePartnerRbacEntity::toString)
|
||||
.isEqualTo(saved.toString());
|
||||
}
|
||||
|
||||
private void assertThatPartnerIsVisibleForUserWithRole(
|
||||
final HsOfficePartnerEntity entity,
|
||||
final HsOfficePartnerRbacEntity entity,
|
||||
final String assumedRoles) {
|
||||
jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net", assumedRoles);
|
||||
@@ -349,7 +351,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
}
|
||||
|
||||
private void assertThatPartnerIsNotVisibleForUserWithRole(
|
||||
final HsOfficePartnerEntity entity,
|
||||
final HsOfficePartnerRbacEntity entity,
|
||||
final String assumedRoles) {
|
||||
jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net", assumedRoles);
|
||||
@@ -437,7 +439,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
select currentTask, targetTable, targetOp, targetdelta->>'partnernumber'
|
||||
from base.tx_journal_v
|
||||
where targettable = 'hs_office.partner';
|
||||
""");
|
||||
""");
|
||||
|
||||
// when
|
||||
@SuppressWarnings("unchecked") final List<Object[]> customerLogEntries = query.getResultList();
|
||||
@@ -451,19 +453,22 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
"[creating partner test-data , hs_office.partner, INSERT, 10010]");
|
||||
}
|
||||
|
||||
private HsOfficePartnerEntity givenSomeTemporaryHostsharingPartner(
|
||||
private HsOfficePartnerRbacEntity givenSomeTemporaryHostsharingPartner(
|
||||
final Integer partnerNumber, final String person, final String contact) {
|
||||
return jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net");
|
||||
final var partnerRel = givenSomeTemporaryHostsharingPartnerRel(person, contact);
|
||||
|
||||
final var newPartner = HsOfficePartnerEntity.builder()
|
||||
final var newPartner = HsOfficePartnerRbacEntity.builder()
|
||||
.partnerNumber(partnerNumber)
|
||||
.partnerRel(partnerRel)
|
||||
.details(HsOfficePartnerDetailsEntity.builder().build())
|
||||
.build();
|
||||
|
||||
return partnerRepo.save(newPartner);
|
||||
final var savedPartner = partnerRepo.save(newPartner);
|
||||
em.flush();
|
||||
final var partner = em.find(savedPartner.getClass(), savedPartner.getUuid());
|
||||
return savedPartner;
|
||||
}).assertSuccessful().returnedValue();
|
||||
}
|
||||
|
||||
@@ -482,21 +487,23 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
return partnerRel;
|
||||
}
|
||||
|
||||
void exactlyThesePartnersAreReturned(final List<HsOfficePartnerEntity> actualResult, final String... partnerNames) {
|
||||
void exactlyThesePartnersAreReturned(final List<HsOfficePartnerRbacEntity> actualResult, final String... partnerNames) {
|
||||
assertThat(actualResult)
|
||||
.extracting(partnerEntity -> partnerEntity.toString())
|
||||
.extracting(partner ->
|
||||
partner.toString() + "+" +
|
||||
(partner.getDetails() != null ? ("(" + partner.getDetails() + ")") : "null"))
|
||||
.containsExactlyInAnyOrder(partnerNames);
|
||||
}
|
||||
|
||||
void allThesePartnersAreReturned(final List<HsOfficePartnerEntity> actualResult, final String... partnerNames) {
|
||||
void allThesePartnersAreReturned(final List<HsOfficePartnerRbacEntity> actualResult, final String... partnerNames) {
|
||||
assertThat(actualResult)
|
||||
.extracting(partnerEntity -> partnerEntity.toString())
|
||||
.extracting(HsOfficePartnerRbacEntity::toString)
|
||||
.contains(partnerNames);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void cleanup() {
|
||||
cleanupAllNew(HsOfficePartnerEntity.class);
|
||||
cleanupAllNew(HsOfficePartnerRbacEntity.class);
|
||||
}
|
||||
|
||||
private String[] distinct(final String[] strings) {
|
||||
+4
-4
@@ -7,12 +7,12 @@ import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
|
||||
|
||||
import static net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType.LEGAL_PERSON;
|
||||
|
||||
public class TestHsOfficePartner {
|
||||
public class HsOfficeTestRealPartner {
|
||||
|
||||
public static final HsOfficePartnerEntity TEST_PARTNER = hsOfficePartnerWithLegalPerson("Test Ltd.");
|
||||
public static final HsOfficePartnerRealEntity TEST_PARTNER = hsOfficePartnerWithLegalPerson("Test Ltd.");
|
||||
|
||||
static public HsOfficePartnerEntity hsOfficePartnerWithLegalPerson(final String tradeName) {
|
||||
return HsOfficePartnerEntity.builder()
|
||||
static public HsOfficePartnerRealEntity hsOfficePartnerWithLegalPerson(final String tradeName) {
|
||||
return HsOfficePartnerRealEntity.builder()
|
||||
.partnerNumber(10001)
|
||||
.partnerRel(
|
||||
HsOfficeRelationRealEntity.builder()
|
||||
-1
@@ -331,7 +331,6 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
||||
return jpaAttempt.transacted(() -> {
|
||||
context.define(creatingUser);
|
||||
final var newPerson = HsOfficePersonRealEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.personType(HsOfficePersonType.LEGAL_PERSON)
|
||||
.tradeName("Temp " + Context.getCallerMethodNameFromStackFrame(2))
|
||||
.familyName(RandomStringUtils.randomAlphabetic(10) + "@example.org")
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ 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.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
@@ -46,7 +46,7 @@ class HsOfficePersonRbacRepositoryIntegrationTest extends ContextBasedTestWithCl
|
||||
@Autowired
|
||||
JpaAttempt jpaAttempt;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Nested
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ 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.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
@@ -44,7 +44,7 @@ class HsOfficePersonRealRepositoryIntegrationTest extends ContextBasedTestWithCl
|
||||
@Autowired
|
||||
JpaAttempt jpaAttempt;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
@Autowired
|
||||
private HsOfficePersonRealRepository hsOfficePersonRealRepository;
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ 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.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
@@ -35,7 +35,7 @@ class HsOfficeRealRelationRepositoryIntegrationTest extends ContextBasedTestWith
|
||||
@PersistenceContext
|
||||
EntityManager em;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Nested
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ 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.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
|
||||
@@ -58,7 +58,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
@Autowired
|
||||
JpaAttempt jpaAttempt;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Nested
|
||||
|
||||
+4
-6
@@ -180,10 +180,9 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
|
||||
void globalAdmin_canNotPostNewSepaMandateWhenDebitorUuidIsMissing() {
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenDebitor = debitorRepo.findDebitorsByOptionalNameLike("Third").get(0);
|
||||
final var givenBankAccount = bankAccountRepo.findByIbanOrderByIbanAsc("DE02200505501015871393").get(0);
|
||||
|
||||
final var location = RestAssured // @formatter:off
|
||||
RestAssured // @formatter:off
|
||||
.given()
|
||||
.header("current-subject", "superuser-alex@hostsharing.net")
|
||||
.contentType(ContentType.JSON)
|
||||
@@ -227,12 +226,12 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
|
||||
.post("http://localhost/api/hs/office/sepamandates")
|
||||
.then().log().all().assertThat()
|
||||
.statusCode(400)
|
||||
.body("message", is("ERROR: [400] Unable to find BankAccount with uuid 00000000-0000-0000-0000-000000000000"));
|
||||
.body("message", is("ERROR: [400] bankAccount.uuid='00000000-0000-0000-0000-000000000000' not found or not accessible"));
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@Test
|
||||
void globalAdmin_canNotPostNewSepaMandate_ifPersonDoesNotExist() {
|
||||
void globalAdmin_canNotPostNewSepaMandate_ifDebitorDoesNotExist() {
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenDebitorUuid = UUID.fromString("00000000-0000-0000-0000-000000000000");
|
||||
@@ -257,7 +256,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
|
||||
.post("http://localhost/api/hs/office/sepamandates")
|
||||
.then().log().all().assertThat()
|
||||
.statusCode(400)
|
||||
.body("message", is("ERROR: [400] Unable to find Debitor with uuid 00000000-0000-0000-0000-000000000000"));
|
||||
.body("message", is("ERROR: [400] debitor.uuid='00000000-0000-0000-0000-000000000000' not found or not accessible"));
|
||||
// @formatter:on
|
||||
}
|
||||
}
|
||||
@@ -529,7 +528,6 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
|
||||
.orElse(givenDebitor.getPartner().getPartnerRel().getHolder().getFamilyName());
|
||||
final var givenBankAccount = bankAccountRepo.findByOptionalHolderLike(bankAccountHolder).get(0);
|
||||
final var newSepaMandate = HsOfficeSepaMandateEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.debitor(givenDebitor)
|
||||
.bankAccount(givenBankAccount)
|
||||
.reference("temp ref CAT Z")
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ 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.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
|
||||
@@ -55,7 +55,7 @@ class HsOfficeSepaMandateRepositoryIntegrationTest extends ContextBasedTestWithC
|
||||
@PersistenceContext
|
||||
EntityManager em;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Nested
|
||||
|
||||
@@ -2,13 +2,13 @@ package net.hostsharing.hsadminng.rbac.context;
|
||||
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.mapper.Array;
|
||||
import net.hostsharing.hsadminng.mapper.StandardMapper;
|
||||
import net.hostsharing.hsadminng.mapper.StrictMapper;
|
||||
import net.hostsharing.hsadminng.persistence.EntityManagerWrapper;
|
||||
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
|
||||
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.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -20,14 +20,14 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DataJpaTest
|
||||
@ComponentScan(basePackageClasses = { Context.class, JpaAttempt.class, EntityManagerWrapper.class, StandardMapper.class })
|
||||
@ComponentScan(basePackageClasses = { Context.class, JpaAttempt.class, EntityManagerWrapper.class, StrictMapper.class })
|
||||
@DirtiesContext
|
||||
class ContextIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
private Context context;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
@SuppressWarnings("unused") // the bean must be present, even though it's not used directly
|
||||
private HttpServletRequest request;
|
||||
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ 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.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
@@ -32,7 +32,7 @@ class RbacGrantRepositoryIntegrationTest extends ContextBasedTest {
|
||||
@Autowired
|
||||
Context context;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
@@ -28,7 +28,7 @@ class RbacGrantsDiagramServiceIntegrationTest extends ContextBasedTestWithCleanu
|
||||
@Autowired
|
||||
RbacGrantsDiagramService grantsMermaidService;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.hostsharing.hsadminng.rbac.role;
|
||||
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.mapper.StandardMapper;
|
||||
import net.hostsharing.hsadminng.mapper.StrictMapper;
|
||||
import net.hostsharing.hsadminng.persistence.EntityManagerWrapper;
|
||||
import net.hostsharing.hsadminng.config.DisableSecurityConfig;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
@@ -31,7 +31,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@WebMvcTest(RbacRoleController.class)
|
||||
@Import({StandardMapper.class, DisableSecurityConfig.class})
|
||||
@Import({StrictMapper.class, DisableSecurityConfig.class})
|
||||
@ActiveProfiles("test")
|
||||
@RunWith(SpringRunner.class)
|
||||
class RbacRoleControllerRestTest {
|
||||
@@ -39,16 +39,16 @@ class RbacRoleControllerRestTest {
|
||||
@Autowired
|
||||
MockMvc mockMvc;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
Context contextMock;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
RbacRoleRepository rbacRoleRepository;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
EntityManagerWrapper em;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
EntityManagerFactory emf;
|
||||
|
||||
@BeforeEach
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ 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.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
|
||||
@@ -31,7 +31,7 @@ class RbacRoleRepositoryIntegrationTest {
|
||||
@Autowired
|
||||
EntityManager em;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Nested
|
||||
|
||||
+6
-6
@@ -1,14 +1,14 @@
|
||||
package net.hostsharing.hsadminng.rbac.subject;
|
||||
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.mapper.StandardMapper;
|
||||
import net.hostsharing.hsadminng.mapper.StrictMapper;
|
||||
import net.hostsharing.hsadminng.persistence.EntityManagerWrapper;
|
||||
import net.hostsharing.hsadminng.config.DisableSecurityConfig;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
@@ -26,7 +26,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@WebMvcTest(RbacSubjectController.class)
|
||||
@Import({StandardMapper.class, DisableSecurityConfig.class})
|
||||
@Import({StrictMapper.class, DisableSecurityConfig.class})
|
||||
@ActiveProfiles("test")
|
||||
@RunWith(SpringRunner.class)
|
||||
class RbacSubjectControllerRestTest {
|
||||
@@ -34,13 +34,13 @@ class RbacSubjectControllerRestTest {
|
||||
@Autowired
|
||||
MockMvc mockMvc;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
Context contextMock;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
RbacSubjectRepository rbacSubjectRepository;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
EntityManagerWrapper em;
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ 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.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
@@ -37,7 +37,7 @@ class RbacSubjectRepositoryIntegrationTest extends ContextBasedTest {
|
||||
@PersistenceContext
|
||||
EntityManager em;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Nested
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.rbac.test;
|
||||
|
||||
import lombok.*;
|
||||
import net.hostsharing.hsadminng.errors.DisplayAs;
|
||||
import net.hostsharing.hsadminng.mapper.StandardMapper;
|
||||
import net.hostsharing.hsadminng.mapper.StrictMapper;
|
||||
import net.hostsharing.hsadminng.persistence.EntityManagerWrapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -27,7 +27,7 @@ class MapperUnitTest {
|
||||
EntityManagerWrapper em;
|
||||
|
||||
@InjectMocks
|
||||
StandardMapper mapper;
|
||||
StrictMapper mapper;
|
||||
|
||||
final UUID GIVEN_UUID = UUID.randomUUID();
|
||||
|
||||
|
||||
+5
-6
@@ -7,13 +7,12 @@ 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.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import jakarta.persistence.PersistenceException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -25,7 +24,7 @@ class TestCustomerRepositoryIntegrationTest extends ContextBasedTest {
|
||||
@Autowired
|
||||
TestCustomerRepository testCustomerRepository;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Nested
|
||||
@@ -40,7 +39,7 @@ class TestCustomerRepositoryIntegrationTest extends ContextBasedTest {
|
||||
// when
|
||||
final var result = attempt(em, () -> {
|
||||
final var newCustomer = new TestCustomerEntity(
|
||||
UUID.randomUUID(), 0, "www", 90001, "customer-admin@www.example.com");
|
||||
null, 0, "www", 90001, "customer-admin@www.example.com");
|
||||
return testCustomerRepository.save(newCustomer);
|
||||
});
|
||||
|
||||
@@ -59,7 +58,7 @@ class TestCustomerRepositoryIntegrationTest extends ContextBasedTest {
|
||||
// when
|
||||
final var result = attempt(em, () -> {
|
||||
final var newCustomer = new TestCustomerEntity(
|
||||
UUID.randomUUID(), 0, "www", 90001, "customer-admin@www.example.com");
|
||||
null, 0, "www", 90001, "customer-admin@www.example.com");
|
||||
return testCustomerRepository.save(newCustomer);
|
||||
});
|
||||
|
||||
@@ -78,7 +77,7 @@ class TestCustomerRepositoryIntegrationTest extends ContextBasedTest {
|
||||
// when
|
||||
final var result = attempt(em, () -> {
|
||||
final var newCustomer = new TestCustomerEntity(
|
||||
UUID.randomUUID(), 0, "www", 90001, "customer-admin@www.example.com");
|
||||
null, 0, "www", 90001, "customer-admin@www.example.com");
|
||||
return testCustomerRepository.save(newCustomer);
|
||||
});
|
||||
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ 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.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.orm.ObjectOptimisticLockingFailureException;
|
||||
|
||||
@@ -31,7 +31,7 @@ class TestPackageRepositoryIntegrationTest extends ContextBasedTest {
|
||||
@Autowired
|
||||
JpaAttempt jpaAttempt;
|
||||
|
||||
@MockBean
|
||||
@MockitoBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Nested
|
||||
|
||||
@@ -6,7 +6,7 @@ management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: info, health, metrics, metric-links
|
||||
include: info, health, metrics, metric-links, mappings, openapi, swaggerui
|
||||
|
||||
spring:
|
||||
sql:
|
||||
|
||||
Reference in New Issue
Block a user