1
0

add department to contact.postalAddress test data (#192)

Co-authored-by: Michael Hoennig <michael@hoennig.de>
Reviewed-on: https://dev.hostsharing.net/hostsharing/hs.hsadmin.ng/pulls/192
Reviewed-by: Marc Sandlus <marc.sandlus@hostsharing.net>
This commit is contained in:
Michael Hoennig
2025-09-01 15:20:49 +02:00
parent c0991d96d9
commit bc06001ce9
4 changed files with 32 additions and 6 deletions
@@ -42,6 +42,7 @@ public class HsOfficeContact implements Stringifyable, BaseEntity<HsOfficeContac
private static Stringify<HsOfficeContact> toString = stringify(HsOfficeContact.class, "contact")
.withProp(Fields.caption, HsOfficeContact::getCaption)
.withProp(Fields.postalAddress, HsOfficeContact::getPostalAddress)
.withProp(Fields.emailAddresses, HsOfficeContact::getEmailAddresses);
@Id
@@ -59,6 +60,7 @@ public class HsOfficeContact implements Stringifyable, BaseEntity<HsOfficeContac
@Setter(AccessLevel.NONE)
@Type(JsonType.class)
@Column(name = "postaladdress")
// Map can contain keys like: "department", "street", "zipcode", "city", "country", etc.
private Map<String, String> postalAddress = new HashMap<>();
@Transient
@@ -18,7 +18,6 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@WebMvcTest(controllers = RestResponseEntityExceptionHandlerRestTest.TestController.class)
@@ -3,6 +3,9 @@ package net.hostsharing.hsadminng.hs.office.contact;
import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator;
import org.junit.jupiter.api.Test;
import java.util.Map;
import static java.util.Map.entry;
import static org.assertj.core.api.Assertions.assertThat;
class HsOfficeContactUnitTest {
@@ -14,9 +17,31 @@ class HsOfficeContactUnitTest {
}
@Test
void toStringReturnsCaption() {
final var givenContact = HsOfficeContactRbacEntity.builder().caption("given caption").build();
assertThat("" + givenContact).isEqualTo("contact(caption='given caption')");
void toStringDescribesAllDomainProperties() {
final var givenContact = HsOfficeContactRbacEntity.builder()
.caption("given caption")
.postalAddress(Map.ofEntries(
entry("department", "Rechnungsabteilung"),
entry("street", "Teststraße 11"),
entry("zipcode", "D-12345"),
entry("city", "Berlin")
))
.emailAddresses(Map.ofEntries(
Map.entry("main", "main@example.org"),
Map.entry("sender", "sender@example.org")
))
.build();
assertThat("" + givenContact).isEqualTo("""
contact(caption='given caption', postalAddress='{
"city" : "Berlin",
"department" : "Rechnungsabteilung",
"street" : "Teststraße 11",
"zipcode" : "D-12345"
}', emailAddresses='{
"main" : "main@example.org",
"sender" : "sender@example.org"
}')
""".trim());
}
@Test
@@ -119,6 +119,7 @@ class HsOfficeScenarioTests extends ScenarioTest {
.given(
"postalAddress", """
"firm": "Test AG",
"department": "Geschäftsleitung",
"street": "Shanghai-Allee 1",
"zipcode": "20123",
"city": "Hamburg",
@@ -261,8 +262,7 @@ class HsOfficeScenarioTests extends ScenarioTest {
.given("newContactCaption", "Test AG - China")
.given(
"newPostalAddress", """
"firm": "Test AG",
"name": "Fi Zhong-Kha",
"department": "Executive Board",
"building": "Thi Chi Koh Building",
"street": "No.2 Commercial Second Street",
"district": "Niushan Wei Wu",