use "YYYY-MM-DD" format when writing LocalDate to JSON

This commit is contained in:
Michael Hoennig 2022-10-14 12:37:59 +02:00
parent c6d92e271f
commit 4f22dffe5d
4 changed files with 25 additions and 7 deletions

View File

@ -59,6 +59,7 @@ dependencies {
implementation 'org.springdoc:springdoc-openapi-ui:1.6.11'
implementation 'org.liquibase:liquibase-core'
implementation 'com.vladmihalcea:hibernate-types-55:2.19.2'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.4'
implementation 'org.openapitools:jackson-databind-nullable:0.2.3'
implementation 'org.modelmapper:modelmapper:3.1.0'
implementation 'org.iban4j:iban4j:3.2.3-RELEASE'

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.config;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.openapitools.jackson.nullable.JsonNullableModule;
import org.springframework.context.annotation.Bean;
@ -14,6 +15,7 @@ public class JsonObjectMapperConfiguration {
@Primary
public Jackson2ObjectMapperBuilder customObjectMapper() {
return new Jackson2ObjectMapperBuilder()
.modules(new JsonNullableModule(), new JavaTimeModule());
.modules(new JsonNullableModule(), new JavaTimeModule())
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
}
}

View File

@ -8,28 +8,37 @@
/*
Creates a single partner test record.
*/
create or replace procedure createHsOfficePartnerTestData( personTradeName varchar, contactLabel varchar )
create or replace procedure createHsOfficePartnerTestData( personTradeOrFamilyName varchar, contactLabel varchar )
language plpgsql as $$
declare
currentTask varchar;
idName varchar;
relatedPerson hs_office_person;
relatedContact hs_office_contact;
birthday date;
begin
idName := cleanIdentifier( personTradeName|| '-' || contactLabel);
idName := cleanIdentifier( personTradeOrFamilyName|| '-' || contactLabel);
currentTask := 'creating partner test-data ' || idName;
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global.admin');
execute format('set local hsadminng.currentTask to %L', currentTask);
select p.* from hs_office_person p where p.tradeName = personTradeName into relatedPerson;
select c.* from hs_office_contact c where c.label = contactLabel into relatedContact;
select p.* from hs_office_person p
where p.tradeName = personTradeOrFamilyName or p.familyName = personTradeOrFamilyName
into relatedPerson;
select c.* from hs_office_contact c
where c.label = contactLabel
into relatedContact;
if relatedPerson.persontype = 'NATURAL' then
birthday := '1987-10-31'::date;
end if;
raise notice 'creating test partner: %', idName;
raise notice '- using person (%): %', relatedPerson.uuid, relatedPerson;
raise notice '- using contact (%): %', relatedContact.uuid, relatedContact;
insert
into hs_office_partner (uuid, personuuid, contactuuid)
values (uuid_generate_v4(), relatedPerson.uuid, relatedContact.uuid);
into hs_office_partner (uuid, personuuid, contactuuid, birthday)
values (uuid_generate_v4(), relatedPerson.uuid, relatedContact.uuid, birthDay);
end; $$;
--//
@ -67,6 +76,7 @@ do language plpgsql $$
call createHsOfficePartnerTestData('Second e.K.', 'second contact');
call createHsOfficePartnerTestData('Third OHG', 'third contact');
call createHsOfficePartnerTestData('Fourth e.G.', 'forth contact');
call createHsOfficePartnerTestData('Smith', 'fifth contact');
end;
$$;
--//

View File

@ -76,6 +76,11 @@ class HsOfficePartnerControllerAcceptanceTest {
.contentType("application/json")
.body("", lenientlyEquals("""
[
{
"person": { "familyName": "Smith" },
"contact": { "label": "fifth contact" },
"birthday": "1987-10-31"
},
{
"person": { "tradeName": "First GmbH" },
"contact": { "label": "first contact" }