Commit 6c2e1d96 authored by Hando Lukats's avatar Hando Lukats
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Hando Lukats

See merge request teis/xroad-gateway!135
parents c80af15f 103beffb
# Changelog
## [2.3.0] - 2022-09-16
* TEIS-3434: fixed datetime conversion for ljvis xml
## [2.2.0] - 2022-08-26
* TEIS-3402: improved getting certs from KIRST logic; minor other fixes
......
theGroup=ee.sm.ti.teis
theVersion=2.2.0
theVersion=2.3.0
commonsVersion=2.7.0
commonApiGatewayVersion=2.6.0
pluginVersion=2.3.0
......
......@@ -113,9 +113,13 @@ public class LJVISXroadComposeService {
return infringementsNumbers;
}
private XMLGregorianCalendar getXMLGregorianCalendar(LocalDateTime dateTime) {
public XMLGregorianCalendar getXMLGregorianCalendar(LocalDateTime dateTime) {
String dateTimeString = dateTime.toString();
if (dateTime.getSecond() == 0 && dateTime.getNano() == 0) {
dateTimeString += ":00";
}
try {
return DatatypeFactory.newInstance().newXMLGregorianCalendar(dateTime.toString());
return DatatypeFactory.newInstance().newXMLGregorianCalendar(dateTimeString);
} catch (DatatypeConfigurationException e) {
throw new TeisIllegalArgumentException("Error encoding LocalDate to XMLGregorianCalendar format");
}
......
......@@ -11,6 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.junit.jupiter.MockitoExtension;
import javax.xml.datatype.XMLGregorianCalendar;
import java.time.LocalDateTime;
import java.util.List;
......@@ -67,6 +68,20 @@ class LJVISXroadComposeServiceTest {
assertThrows(ArithmeticException.class, () -> composeService.composeInspectionData(payload));
}
@Test
void getXMLGregorianCalendar_keepsProvidedSeconds_seconds() {
LocalDateTime dateTime = LocalDateTime.of(2012, 10, 1, 12, 12, 12);
XMLGregorianCalendar xmlGregorianCalendar = composeService.getXMLGregorianCalendar(dateTime);
assertThat(xmlGregorianCalendar.getSecond()).isEqualTo(12);
}
@Test
void getXMLGregorianCalendar_addsSecondsIfNotProvided_success() {
LocalDateTime dateTime = LocalDateTime.of(2012, 10, 1, 12, 12);
XMLGregorianCalendar xmlGregorianCalendar = composeService.getXMLGregorianCalendar(dateTime);
assertThat(xmlGregorianCalendar.getSecond()).isEqualTo(0);
}
private LJVISDriversInspectionData composeData() {
return LJVISDriversInspectionData.builder()
.convictedPersonCode("12")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment