diff options
author | Stanislav Marszalek <s.marszalek2@partner.samsung.com> | 2021-07-27 09:14:02 +0200 |
---|---|---|
committer | Stanislav Marszalek <s.marszalek2@partner.samsung.com> | 2021-07-28 13:04:28 +0000 |
commit | 024a5ea23d7f17d182576f0d2b11a019a4e3b8a9 (patch) | |
tree | 2b6aab31b1c0bb599f409c7756d3037d18aa73af | |
parent | 5995a778e7a5a7718c480a8099b9c2f47549530d (diff) |
O1 PM Bulk support - Start and End date changes
Issue-ID: INT-1945
Signed-off-by: Stanislav Marszalek <s.marszalek2@partner.samsung.com>
Change-Id: I02d3684c98d563d7f386de2fdf032e930ac44b3f
4 files changed, 18 insertions, 7 deletions
diff --git a/src/main/java/org/onap/a1pesimulator/data/fileready/FileData.java b/src/main/java/org/onap/a1pesimulator/data/fileready/FileData.java index 7e47897..9eb8c5f 100644 --- a/src/main/java/org/onap/a1pesimulator/data/fileready/FileData.java +++ b/src/main/java/org/onap/a1pesimulator/data/fileready/FileData.java @@ -1,6 +1,7 @@ package org.onap.a1pesimulator.data.fileready; import java.io.File; +import java.time.ZonedDateTime; import lombok.Builder; import lombok.Data; @@ -15,4 +16,6 @@ public class FileData { File pmBulkFile; File archivedPmBulkFile; FileReadyEvent fileReadyEvent; + ZonedDateTime startEventDate; + ZonedDateTime endEventDate; } diff --git a/src/main/java/org/onap/a1pesimulator/service/fileready/FileReadyEventService.java b/src/main/java/org/onap/a1pesimulator/service/fileready/FileReadyEventService.java index 644ce3b..bf5b88a 100644 --- a/src/main/java/org/onap/a1pesimulator/service/fileready/FileReadyEventService.java +++ b/src/main/java/org/onap/a1pesimulator/service/fileready/FileReadyEventService.java @@ -5,7 +5,9 @@ import static org.onap.a1pesimulator.util.Constants.FILE_READY_CHANGE_IDENTIFIER import static org.onap.a1pesimulator.util.Constants.FILE_READY_CHANGE_TYPE; import java.io.File; +import java.time.Instant; import java.time.ZonedDateTime; +import java.time.temporal.ChronoUnit; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -16,7 +18,6 @@ import org.onap.a1pesimulator.data.fileready.FileReadyEvent; import org.onap.a1pesimulator.data.fileready.NotificationFields; import org.onap.a1pesimulator.data.fileready.NotificationFields.ArrayOfNamedHashMap; import org.onap.a1pesimulator.data.ves.CommonEventHeader; -import org.onap.a1pesimulator.util.RanVesUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -81,8 +82,10 @@ public class FileReadyEventService { */ protected FileData createFileReadyEvent(FileData fileData) { FileReadyEvent event = new FileReadyEvent(); - event.setCommonEventHeader(getCommonHeader()); - RanVesUtils.updateHeader(event); + CommonEventHeader commonEventHeader = getCommonHeader(); + event.setCommonEventHeader(commonEventHeader); + commonEventHeader.setStartEpochMicrosec(ChronoUnit.MICROS.between(Instant.EPOCH, fileData.getStartEventDate())); + commonEventHeader.setLastEpochMicrosec(ChronoUnit.MICROS.between(Instant.EPOCH, fileData.getEndEventDate())); event.setNotificationFields(getNotificationFields(fileData.getArchivedPmBulkFile().getName())); fileData.setFileReadyEvent(event); return fileData; diff --git a/src/main/java/org/onap/a1pesimulator/service/fileready/PMBulkFileService.java b/src/main/java/org/onap/a1pesimulator/service/fileready/PMBulkFileService.java index 37b3440..4534b7e 100644 --- a/src/main/java/org/onap/a1pesimulator/service/fileready/PMBulkFileService.java +++ b/src/main/java/org/onap/a1pesimulator/service/fileready/PMBulkFileService.java @@ -140,9 +140,11 @@ public class PMBulkFileService { File xmlFile = writeDocumentIntoXmlFile(doc, collectedEvents); + Mono<FileData> justMono = Mono.just(FileData.builder().pmBulkFile(xmlFile).startEventDate(earliestEventTime(collectedEvents)) + .endEventDate(latestEventTime(collectedEvents)).build()); log.trace("Removing all VES events from memory: {}", collectedEvents.size()); collectedEvents.clear(); - return Mono.just(FileData.builder().pmBulkFile(xmlFile).build()); + return justMono; } catch (ParserConfigurationException | TransformerException pce) { log.error("Error occurs while creating PM Bulk File", pce); diff --git a/src/test/java/org/onap/a1pesimulator/service/fileready/FileReadyEventServiceTest.java b/src/test/java/org/onap/a1pesimulator/service/fileready/FileReadyEventServiceTest.java index 11ae637..18ab5c5 100644 --- a/src/test/java/org/onap/a1pesimulator/service/fileready/FileReadyEventServiceTest.java +++ b/src/test/java/org/onap/a1pesimulator/service/fileready/FileReadyEventServiceTest.java @@ -7,6 +7,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.nio.file.InvalidPathException; +import java.time.ZonedDateTime; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -33,8 +34,9 @@ class FileReadyEventServiceTest extends CommonFileReady { @Test void createFileReadyEventAndDeleteTmpFile() { - Mono<FileData> fileMono = Mono.just(getTestFileData()); - FileData expectedFileData = fileReadyEventService.createFileReadyEvent(getTestFileData()); + FileData testData = getTestFileData(); + Mono<FileData> fileMono = Mono.just(testData); + FileData expectedFileData = fileReadyEventService.createFileReadyEvent(testData); StepVerifier.create(fileReadyEventService.createFileReadyEventAndDeleteTmpFile(fileMono)) .expectNext(expectedFileData) .verifyComplete(); @@ -66,7 +68,8 @@ class FileReadyEventServiceTest extends CommonFileReady { */ private FileData getTestFileData() { try { - return FileData.builder().pmBulkFile(createTempFile(PM_BULK_FILE)).archivedPmBulkFile(createTempFile(ARCHIVED_PM_BULK_FILE)).build(); + return FileData.builder().pmBulkFile(createTempFile(PM_BULK_FILE)).startEventDate(ZonedDateTime.now()) + .endEventDate(ZonedDateTime.now().plusMinutes(5)).archivedPmBulkFile(createTempFile(ARCHIVED_PM_BULK_FILE)).build(); } catch (InvalidPathException e) { e.printStackTrace(); } |