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:
@@ -42,6 +42,7 @@ public class HsOfficeContact implements Stringifyable, BaseEntity<HsOfficeContac
|
|||||||
|
|
||||||
private static Stringify<HsOfficeContact> toString = stringify(HsOfficeContact.class, "contact")
|
private static Stringify<HsOfficeContact> toString = stringify(HsOfficeContact.class, "contact")
|
||||||
.withProp(Fields.caption, HsOfficeContact::getCaption)
|
.withProp(Fields.caption, HsOfficeContact::getCaption)
|
||||||
|
.withProp(Fields.postalAddress, HsOfficeContact::getPostalAddress)
|
||||||
.withProp(Fields.emailAddresses, HsOfficeContact::getEmailAddresses);
|
.withProp(Fields.emailAddresses, HsOfficeContact::getEmailAddresses);
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@@ -59,6 +60,7 @@ public class HsOfficeContact implements Stringifyable, BaseEntity<HsOfficeContac
|
|||||||
@Setter(AccessLevel.NONE)
|
@Setter(AccessLevel.NONE)
|
||||||
@Type(JsonType.class)
|
@Type(JsonType.class)
|
||||||
@Column(name = "postaladdress")
|
@Column(name = "postaladdress")
|
||||||
|
// Map can contain keys like: "department", "street", "zipcode", "city", "country", etc.
|
||||||
private Map<String, String> postalAddress = new HashMap<>();
|
private Map<String, String> postalAddress = new HashMap<>();
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
|
|||||||
-1
@@ -18,7 +18,6 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
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;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
@WebMvcTest(controllers = RestResponseEntityExceptionHandlerRestTest.TestController.class)
|
@WebMvcTest(controllers = RestResponseEntityExceptionHandlerRestTest.TestController.class)
|
||||||
|
|||||||
+28
-3
@@ -3,6 +3,9 @@ package net.hostsharing.hsadminng.hs.office.contact;
|
|||||||
import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator;
|
import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static java.util.Map.entry;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
class HsOfficeContactUnitTest {
|
class HsOfficeContactUnitTest {
|
||||||
@@ -14,9 +17,31 @@ class HsOfficeContactUnitTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void toStringReturnsCaption() {
|
void toStringDescribesAllDomainProperties() {
|
||||||
final var givenContact = HsOfficeContactRbacEntity.builder().caption("given caption").build();
|
final var givenContact = HsOfficeContactRbacEntity.builder()
|
||||||
assertThat("" + givenContact).isEqualTo("contact(caption='given caption')");
|
.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
|
@Test
|
||||||
|
|||||||
+2
-2
@@ -119,6 +119,7 @@ class HsOfficeScenarioTests extends ScenarioTest {
|
|||||||
.given(
|
.given(
|
||||||
"postalAddress", """
|
"postalAddress", """
|
||||||
"firm": "Test AG",
|
"firm": "Test AG",
|
||||||
|
"department": "Geschäftsleitung",
|
||||||
"street": "Shanghai-Allee 1",
|
"street": "Shanghai-Allee 1",
|
||||||
"zipcode": "20123",
|
"zipcode": "20123",
|
||||||
"city": "Hamburg",
|
"city": "Hamburg",
|
||||||
@@ -261,8 +262,7 @@ class HsOfficeScenarioTests extends ScenarioTest {
|
|||||||
.given("newContactCaption", "Test AG - China")
|
.given("newContactCaption", "Test AG - China")
|
||||||
.given(
|
.given(
|
||||||
"newPostalAddress", """
|
"newPostalAddress", """
|
||||||
"firm": "Test AG",
|
"department": "Executive Board",
|
||||||
"name": "Fi Zhong-Kha",
|
|
||||||
"building": "Thi Chi Koh Building",
|
"building": "Thi Chi Koh Building",
|
||||||
"street": "No.2 Commercial Second Street",
|
"street": "No.2 Commercial Second Street",
|
||||||
"district": "Niushan Wei Wu",
|
"district": "Niushan Wei Wu",
|
||||||
|
|||||||
Reference in New Issue
Block a user