From 38c03e73da5be95edd8d010fa4ac9ae4e17d0e0b Mon Sep 17 00:00:00 2001 From: hongwei Date: Tue, 20 Jun 2023 18:28:52 +0800 Subject: [PATCH] bugfix/added the guard for emptyList of atms for MxOF --- .../scala/code/api/MxOF/JSONFactory_MXOF_1_0_0.scala | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/obp-api/src/main/scala/code/api/MxOF/JSONFactory_MXOF_1_0_0.scala b/obp-api/src/main/scala/code/api/MxOF/JSONFactory_MXOF_1_0_0.scala index 0036c10882..16086b5621 100644 --- a/obp-api/src/main/scala/code/api/MxOF/JSONFactory_MXOF_1_0_0.scala +++ b/obp-api/src/main/scala/code/api/MxOF/JSONFactory_MXOF_1_0_0.scala @@ -1,7 +1,7 @@ package code.api.MxOF import code.api.util.{APIUtil, CustomJsonFormats} -import code.api.util.APIUtil.{defaultBankId, listOrNone, stringOrNone} +import code.api.util.APIUtil.{defaultBankId, listOrNone, stringOrNone, theEpochTime} import code.atms.MappedAtm import code.bankattribute.BankAttribute import com.openbankproject.commons.model.Bank @@ -170,10 +170,16 @@ object JSONFactory_MXOF_0_0_1 extends CustomJsonFormats { ) } ) - val lastUpdated: Date = MappedAtm.findAll( + val mappedAtmList: List[MappedAtm] = MappedAtm.findAll( NotNullRef(MappedAtm.updatedAt), OrderBy(MappedAtm.updatedAt, Descending), - ).head.updatedAt.get + ) + + val lastUpdated: Date = if(mappedAtmList.nonEmpty) { + mappedAtmList.head.updatedAt.get + }else{ + theEpochTime + } val agreement = attributes.find(_.name.equals(BANK_ATTRIBUTE_AGREEMENT)).map(_.value).getOrElse("") val license = attributes.find(_.name.equals(BANK_ATTRIBUTE_LICENSE)).map(_.value).getOrElse("")