From 42cbd4db97423861021cd79d66f0006879967f81 Mon Sep 17 00:00:00 2001 From: Walt Jones Date: Fri, 5 Jun 2020 15:17:00 -0700 Subject: [PATCH] fix: don't add custom key if it's null --- force-app/main/default/classes/DataBuilder.cls | 5 ++++- force-app/main/default/tests/DataBuilderTest.cls | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/force-app/main/default/classes/DataBuilder.cls b/force-app/main/default/classes/DataBuilder.cls index eaee3c9..9605b63 100644 --- a/force-app/main/default/classes/DataBuilder.cls +++ b/force-app/main/default/classes/DataBuilder.cls @@ -81,7 +81,10 @@ public with sharing class DataBuilder { structure.put('environment', environment); structure.put('framework', 'apex'); structure.put('body', body); - structure.put('custom', custom); + + if (custom != null) { + structure.put('custom', custom); + } return structure; } diff --git a/force-app/main/default/tests/DataBuilderTest.cls b/force-app/main/default/tests/DataBuilderTest.cls index cdd94eb..f071b54 100644 --- a/force-app/main/default/tests/DataBuilderTest.cls +++ b/force-app/main/default/tests/DataBuilderTest.cls @@ -11,6 +11,8 @@ public class DataBuilderTest Map data = (Map)result.get('data'); + System.assertEquals(data.containsKey('custom'), false); + Map notifierMap = (Map)data.get('notifier'); System.assertEquals(Notifier.NAME, (String)notifierMap.get('name')); @@ -87,6 +89,8 @@ public class DataBuilderTest Map data = (Map)result.get('data'); + System.assertEquals(data.containsKey('custom'), false); + Map notifierMap = (Map)data.get('notifier'); System.assertEquals(Notifier.NAME, (String)notifierMap.get('name')); System.assertEquals(Notifier.VERSION, (String)notifierMap.get('version'));