diff --git a/thehive/app/org/thp/thehive/services/CaseSrv.scala b/thehive/app/org/thp/thehive/services/CaseSrv.scala index 98fa27c87d..85015482ee 100644 --- a/thehive/app/org/thp/thehive/services/CaseSrv.scala +++ b/thehive/app/org/thp/thehive/services/CaseSrv.scala @@ -334,7 +334,7 @@ class CaseSrv @Inject() ( .richCustomFields .toList .toTry { c => - caseCustomFieldSrv.create(CaseCustomField(), richCase.`case`, c.customField) + createCustomField(richCase.`case`, EntityIdOrName(c.customField.name), c.value, c.order) } ) _ = cases.map(remove(_)) diff --git a/thehive/test/org/thp/thehive/services/CaseSrvTest.scala b/thehive/test/org/thp/thehive/services/CaseSrvTest.scala index 8753dbb560..0b2c5abe1c 100644 --- a/thehive/test/org/thp/thehive/services/CaseSrvTest.scala +++ b/thehive/test/org/thp/thehive/services/CaseSrvTest.scala @@ -409,7 +409,10 @@ class CaseSrvTest extends PlaySpecification with TestAppBuilder { case21.clone().procedure.toSeq.size mustEqual 1 case22.clone().procedure.toSeq.size mustEqual 2 case23.clone().procedure.toSeq.size mustEqual 0 - // TODO CustomFields + // CustomFields + case21.clone().customFields.toSeq.size mustEqual 0 + case22.clone().customFields.toSeq.size mustEqual 1 + case23.clone().customFields.toSeq.size mustEqual 1 for { c21 <- case21.clone().getOrFail("Case") @@ -423,6 +426,7 @@ class CaseSrvTest extends PlaySpecification with TestAppBuilder { mergedCase.clone().tasks.toSeq.size mustEqual 3 mergedCase.clone().observables.toSeq.size mustEqual 3 mergedCase.clone().procedure.toSeq.size mustEqual 3 + mergedCase.clone().customFields.toSeq.size mustEqual 2 } } } diff --git a/thehive/test/resources/data/CaseCustomField.json b/thehive/test/resources/data/CaseCustomField.json index 9e85e9ba03..fccc9c06d8 100644 --- a/thehive/test/resources/data/CaseCustomField.json +++ b/thehive/test/resources/data/CaseCustomField.json @@ -1,4 +1,6 @@ [ {"from": "case3", "to": "string1", "stringValue": "string1 custom field"}, - {"from": "case3", "to": "boolean1", "booleanValue": true} + {"from": "case3", "to": "boolean1", "booleanValue": true}, + {"from": "caseMerge22", "to": "string1", "stringValue": "merge string1"}, + {"from": "caseMerge23", "to": "boolean1", "booleanValue": true} ] \ No newline at end of file