post new contact: process postalAddress #145

Merged
hsh-timotheuspokorra merged 5 commits from TP-20250109_addcontact_putpostaladdress into master 2025-01-16 13:57:15 +01:00
4 changed files with 26 additions and 2 deletions

View File

@ -131,6 +131,7 @@ public class HsOfficeContactController implements HsOfficeContactsApi {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final BiConsumer<HsOfficeContactInsertResource, HsOfficeContactRbacEntity> RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> { final BiConsumer<HsOfficeContactInsertResource, HsOfficeContactRbacEntity> RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> {
entity.putPostalAddress(from(resource.getPostalAddress()));
hsh-michaelhoennig marked this conversation as resolved

das sollte noch in einen Test aufgenommen werden, z.B. in net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactControllerAcceptanceTest.AddContact#globalAdmin_withoutAssumedRole_canAddContact

das sollte noch in einen Test aufgenommen werden, z.B. in net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactControllerAcceptanceTest.AddContact#globalAdmin_withoutAssumedRole_canAddContact
entity.putEmailAddresses(from(resource.getEmailAddresses())); entity.putEmailAddresses(from(resource.getEmailAddresses()));
entity.putPhoneNumbers(from(resource.getPhoneNumbers())); entity.putPhoneNumbers(from(resource.getPhoneNumbers()));
}; };

View File

@ -185,6 +185,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final BiConsumer<HsOfficeContactInsertResource, HsOfficeContactRealEntity> CONTACT_RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> { final BiConsumer<HsOfficeContactInsertResource, HsOfficeContactRealEntity> CONTACT_RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> {
entity.putPostalAddress(from(resource.getPostalAddress()));
hsh-timotheuspokorra marked this conversation as resolved

das sollte noch in einen Test aufgenommen werden, z.B. in net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationControllerAcceptanceTest.AddRelation#globalAdmin_withoutAssumedRole_canAddRelationWithHolderAndContactData

das sollte noch in einen Test aufgenommen werden, z.B. in net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationControllerAcceptanceTest.AddRelation#globalAdmin_withoutAssumedRole_canAddRelationWithHolderAndContactData

das habe ich nun auch gelöst

das habe ich nun auch gelöst
entity.putEmailAddresses(from(resource.getEmailAddresses())); entity.putEmailAddresses(from(resource.getEmailAddresses()));
entity.putPhoneNumbers(from(resource.getPhoneNumbers())); entity.putPhoneNumbers(from(resource.getPhoneNumbers()));
}; };

View File

@ -110,6 +110,14 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
.body(""" .body("""
{ {
"caption": "Temp Contact", "caption": "Temp Contact",
"postalAddress": {
"name": "Herr Test Contact",
"firm": "Test Contact GmbH",
"street": "Am Schieferbruch 3",
"zipcode": "12345",
"city": "Dachstadt",
"country": "Germany"
},
"emailAddresses": { "emailAddresses": {
"main": "test@example.org" "main": "test@example.org"
} }
@ -124,6 +132,8 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
.body("uuid", isUuidValid()) .body("uuid", isUuidValid())
.body("caption", is("Temp Contact")) .body("caption", is("Temp Contact"))
.body("emailAddresses", is(Map.of("main", "test@example.org"))) .body("emailAddresses", is(Map.of("main", "test@example.org")))
.body("postalAddress", hasEntry("name", "Herr Test Contact"))
.body("postalAddress", hasEntry("street", "Am Schieferbruch 3"))
.header("Location", startsWith("http://localhost")) .header("Location", startsWith("http://localhost"))
.extract().header("Location"); // @formatter:on .extract().header("Location"); // @formatter:on

View File

@ -18,13 +18,14 @@ import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid; import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.hsadminng.test.JsonMatcher.lenientlyEquals; import static net.hostsharing.hsadminng.test.JsonMatcher.lenientlyEquals;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.startsWith; import static org.hamcrest.Matchers.hasEntry;
@SpringBootTest( @SpringBootTest(
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
@ -291,6 +292,14 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
}, },
"contact": { "contact": {
"caption": "Temp Contact", "caption": "Temp Contact",
"postalAddress": {
"name": "Herr Test Contact",
"firm": "Test Contact GmbH",
"street": "Am Schieferbruch 3",
"zipcode": "12345",
"city": "Dachstadt",
"country": "Germany"
},
"emailAddresses": { "emailAddresses": {
"main": "test@example.org" "main": "test@example.org"
} }
@ -315,6 +324,9 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
.body("holder.givenName", is("Temp")) .body("holder.givenName", is("Temp"))
.body("holder.familyName", is("Person")) .body("holder.familyName", is("Person"))
.body("contact.caption", is("Temp Contact")) .body("contact.caption", is("Temp Contact"))
.body("contact.emailAddresses", is(Map.of("main", "test@example.org")))
.body("contact.postalAddress", hasEntry("name", "Herr Test Contact"))
.body("contact.postalAddress", hasEntry("street", "Am Schieferbruch 3"))
.header("Location", startsWith("http://localhost")) .header("Location", startsWith("http://localhost"))
.extract().header("Location"); // @formatter:on .extract().header("Location"); // @formatter:on