diff --git a/csw-params/jvm/src/test/scala/csw/params/core/formats/JsonContractTest.scala b/csw-params/jvm/src/test/scala/csw/params/core/formats/JsonContractTest.scala index 68227364ff..1821705696 100644 --- a/csw-params/jvm/src/test/scala/csw/params/core/formats/JsonContractTest.scala +++ b/csw-params/jvm/src/test/scala/csw/params/core/formats/JsonContractTest.scala @@ -127,10 +127,13 @@ class JsonContractTest extends AnyFunSpec with Matchers { val arrayDataParam = arrayDataKey.set(ArrayData.fromArray(a1), ArrayData.fromArrays[Byte](10, 20, 30, 40, 50)) val systemEvent = SystemEvent(eventId, prefix, eventName, eventTime, Set(arrayDataParam)) + val systemEvent2 = SystemEvent(prefix, eventName, Set(arrayDataParam)).withEventTime(eventTime).copy(eventId = eventId) val systemEventToJson = JsonSupport.writeEvent(systemEvent) + val systemEventToJson2 = JsonSupport.writeEvent(systemEvent2) val expectedSystemEventJson = Json.parse(Source.fromResource("json/system_event.json").mkString) systemEventToJson shouldEqual expectedSystemEventJson + systemEventToJson2 shouldEqual expectedSystemEventJson } } diff --git a/csw-params/shared/src/main/scala/csw/params/events/events.scala b/csw-params/shared/src/main/scala/csw/params/events/events.scala index 111aac9263..fb1e497972 100644 --- a/csw-params/shared/src/main/scala/csw/params/events/events.scala +++ b/csw-params/shared/src/main/scala/csw/params/events/events.scala @@ -123,6 +123,12 @@ case class SystemEvent private[csw] ( */ override protected def create(data: Set[Parameter[?]]): SystemEvent = copy(eventId = Id(), eventTime = UTCTime.now(), paramSet = data) + + /** + * Returns a new SystemEvent with the same values and the given time and a new id + */ + def withEventTime(eventTime: UTCTime): SystemEvent = + copy(eventId = Id(), eventTime = eventTime) } object SystemEvent {