@@ -142,6 +142,54 @@ public class StreamingMonitorControllerTest {
142142 Assert .areEqual (' TestSC' , channels .get (0 ).value );
143143 }
144144
145+ @isTest
146+ static void getBlankPlatformEvent_works () {
147+ // Using standard SObject here instead of Platform Event because we can't create Platform Events in tests
148+ Map <String , Object > event = StreamingMonitorController .getBlankPlatformEvent (
149+ ' Contact'
150+ );
151+
152+ Assert .isFalse (event .containsKey (' createddate' ));
153+ Assert .areEqual (
154+ StreamingMonitorController .DEFAULT_FIELD_VALUES .get (
155+ Schema .SOAPType .DATE
156+ ),
157+ event .get (' birthdate' )
158+ );
159+ Assert .areEqual (
160+ StreamingMonitorController .DEFAULT_FIELD_VALUES .get (
161+ Schema .SOAPType .STRING
162+ ),
163+ event .get (' name' )
164+ );
165+ Assert .areEqual (
166+ StreamingMonitorController .DEFAULT_FIELD_VALUES .get (
167+ Schema .SOAPType .BOOLEAN
168+ ),
169+ event .get (' isdeleted' )
170+ );
171+ Assert .areEqual (
172+ StreamingMonitorController .DEFAULT_FIELD_VALUES .get (
173+ Schema .SOAPType .DATETIME
174+ ),
175+ event .get (' lastcurequestdate' )
176+ );
177+ }
178+
179+ @isTest
180+ static void getBlankPlatformEvent_fails_when_eventName_is_unknown_sObject () {
181+ try {
182+ StreamingMonitorController .getBlankPlatformEvent (' unknown' );
183+ Assert .fail (' Exception was expected' );
184+ } catch (Exception e ) {
185+ Assert .isInstanceOfType (
186+ e ,
187+ StreamingMonitorController .StreamingException .class
188+ );
189+ assertContains (e .getMessage (), ' Unknown platform event type' );
190+ }
191+ }
192+
145193 private static void assertContains (String actual , String expectedContent ) {
146194 System .assert (
147195 actual ?. contains (expectedContent ),
0 commit comments