FINERACT-1694-External-events-date-unit-change-to-milliseconds
This commit is contained in:
committed by
Arnold Gálovics
parent
e9e31a8190
commit
ca5c7d8747
+5
@@ -66,6 +66,11 @@ public final class DateUtils {
|
|||||||
return OffsetDateTime.now(zone).truncatedTo(ChronoUnit.SECONDS);
|
return OffsetDateTime.now(zone).truncatedTo(ChronoUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static OffsetDateTime getOffsetDateTimeOfTenantWithMilliseconds() {
|
||||||
|
final ZoneId zone = getDateTimeZoneOfTenant();
|
||||||
|
return OffsetDateTime.now(zone).truncatedTo(ChronoUnit.MILLIS);
|
||||||
|
}
|
||||||
|
|
||||||
public static LocalDateTime getLocalDateTimeOfSystem() {
|
public static LocalDateTime getLocalDateTimeOfSystem() {
|
||||||
return LocalDateTime.now(ZoneId.systemDefault()).truncatedTo(ChronoUnit.SECONDS);
|
return LocalDateTime.now(ZoneId.systemDefault()).truncatedTo(ChronoUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -98,7 +98,7 @@ public class SendAsynchronousEventsTasklet implements Tasklet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void markEventsAsSent(List<Long> eventIds) {
|
private void markEventsAsSent(List<Long> eventIds) {
|
||||||
OffsetDateTime sentAt = DateUtils.getOffsetDateTimeOfTenant();
|
OffsetDateTime sentAt = DateUtils.getOffsetDateTimeOfTenantWithMilliseconds();
|
||||||
|
|
||||||
// Partitioning dataset to avoid exception: PreparedStatement can have at most 65,535 parameters
|
// Partitioning dataset to avoid exception: PreparedStatement can have at most 65,535 parameters
|
||||||
List<List<Long>> partitions = Lists.partition(eventIds, 5_000);
|
List<List<Long>> partitions = Lists.partition(eventIds, 5_000);
|
||||||
|
|||||||
+1
-1
@@ -79,7 +79,7 @@ public class ExternalEvent extends AbstractPersistableCustom {
|
|||||||
this.schema = schema;
|
this.schema = schema;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.idempotencyKey = idempotencyKey;
|
this.idempotencyKey = idempotencyKey;
|
||||||
this.createdAt = DateUtils.getOffsetDateTimeOfTenant();
|
this.createdAt = DateUtils.getOffsetDateTimeOfTenantWithMilliseconds();
|
||||||
this.status = ExternalEventStatus.TO_BE_SENT;
|
this.status = ExternalEventStatus.TO_BE_SENT;
|
||||||
this.businessDate = DateUtils.getBusinessLocalDate();
|
this.businessDate = DateUtils.getBusinessLocalDate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,4 +115,5 @@
|
|||||||
<include file="parts/0093_update_general_accounting_table_reports.xml" relativeToChangelogFile="true" />
|
<include file="parts/0093_update_general_accounting_table_reports.xml" relativeToChangelogFile="true" />
|
||||||
<include file="parts/0094_add_external_event_default_configuration.xml" relativeToChangelogFile="true" />
|
<include file="parts/0094_add_external_event_default_configuration.xml" relativeToChangelogFile="true" />
|
||||||
<include file="parts/0095_add_delinquency_and_arrears_display_configuration.xml" relativeToChangelogFile="true" />
|
<include file="parts/0095_add_delinquency_and_arrears_display_configuration.xml" relativeToChangelogFile="true" />
|
||||||
|
<include file="parts/0096_modify_created_and_sent_at_date_external_events.xml" relativeToChangelogFile="true" />
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
|
|||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
|
||||||
|
-->
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
|
||||||
|
<changeSet id="1" author="fineract">
|
||||||
|
<modifyDataType columnName="created_at"
|
||||||
|
newDataType="timestamp(6)"
|
||||||
|
tableName="m_external_event"/>
|
||||||
|
</changeSet>
|
||||||
|
<changeSet author="fineract" id="2-postgres" context="postgresql">
|
||||||
|
<modifyDataType columnName="sent_at"
|
||||||
|
newDataType="timestamp(6)"
|
||||||
|
tableName="m_external_event"/>
|
||||||
|
</changeSet>
|
||||||
|
<changeSet author="fineract" id="2-mysql" context="mysql">
|
||||||
|
<modifyDataType columnName="sent_at"
|
||||||
|
newDataType="timestamp(6) NULL"
|
||||||
|
tableName="m_external_event"/>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
</databaseChangeLog>
|
||||||
+28
@@ -29,6 +29,7 @@ import java.io.IOException;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -186,4 +187,31 @@ class ExternalEventServiceTest {
|
|||||||
assertThat(externalEvent.getCategory()).isEqualTo(eventCategory);
|
assertThat(externalEvent.getCategory()).isEqualTo(eventCategory);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEventShouldSaveDatesInMilliSecondFormat() throws IOException {
|
||||||
|
// given
|
||||||
|
ArgumentCaptor<ExternalEvent> externalEventArgumentCaptor = ArgumentCaptor.forClass(ExternalEvent.class);
|
||||||
|
String eventSchema = "org.apache.fineract.avro.loan.v1.LoanAccountDataV1";
|
||||||
|
String eventType = "TestType";
|
||||||
|
String eventCategory = "TestCategory";
|
||||||
|
String idempotencyKey = "key";
|
||||||
|
BusinessEvent event = mock(BusinessEvent.class);
|
||||||
|
BusinessEventSerializer eventSerializer = mock(BusinessEventSerializer.class);
|
||||||
|
byte[] data = new byte[0];
|
||||||
|
|
||||||
|
given(event.getType()).willReturn(eventType);
|
||||||
|
given(event.getCategory()).willReturn(eventCategory);
|
||||||
|
given(idempotencyKeyGenerator.generate(event)).willReturn(idempotencyKey);
|
||||||
|
given(serializerFactory.create(event)).willReturn(eventSerializer);
|
||||||
|
given(eventSerializer.getSupportedSchema()).will(invocation -> LoanAccountDataV1.class);
|
||||||
|
given(eventSerializer.serialize(event)).willReturn(data);
|
||||||
|
// when
|
||||||
|
underTest.postEvent(event);
|
||||||
|
// then
|
||||||
|
verify(repository).save(externalEventArgumentCaptor.capture());
|
||||||
|
ExternalEvent externalEvent = externalEventArgumentCaptor.getValue();
|
||||||
|
assertThat(externalEvent.getCreatedAt().isSupported(ChronoUnit.MILLIS)).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user