@@ -516,6 +516,28 @@ public void eventsUserProps_propsSave() {
516516 Assert .assertEquals (TestUtils .json ("custom" , TestUtils .map ("after_event" , "value2" )), RQ [1 ].get ("user_details" ));
517517 }
518518
519+ /**
520+ * Recording events with user properties and with flushing events
521+ * Validating that if a user property save called, it does not flush EQ before saving user properties
522+ */
523+ @ Test
524+ public void eventsUserProps_propsSave_reversed () {
525+ init (TestUtils .getConfigEvents (4 ).disableAutoSendUserProperties ());
526+
527+ Countly .instance ().events ().recordEvent (eKeys [0 ]);
528+
529+ Map <String , String >[] RQ = TestUtils .getCurrentRQ ();
530+ Assert .assertEquals (0 , RQ .length );
531+ TestUtils .validateEventInEQ (eKeys [0 ], null , 1 , null , null , 0 , 1 , "_CLY_" , null , "" , null );
532+
533+ Countly .instance ().userProfile ().setProperty ("after_event" , "value2" );
534+ Countly .instance ().userProfile ().save ();
535+
536+ RQ = TestUtils .getCurrentRQ ();
537+ Assert .assertEquals (1 , RQ .length );
538+ Assert .assertEquals (TestUtils .json ("custom" , TestUtils .map ("after_event" , "value2" )), RQ [0 ].get ("user_details" ));
539+ }
540+
519541 /**
520542 * Validate that user properties are sent with timer tick if no events are recorded
521543 */
@@ -534,6 +556,23 @@ public void eventsUserProps_timer() throws InterruptedException {
534556 Assert .assertEquals (TestUtils .json ("custom" , TestUtils .map ("before_timer" , "value1" )), RQ [0 ].get ("user_details" ));
535557 }
536558
559+ /**
560+ * Validate that user properties does not send with timer tick if no events are recorded
561+ */
562+ @ Test
563+ public void eventsUserProps_timer_reversed () throws InterruptedException {
564+ init (TestUtils .getConfigEvents (4 ).setUpdateSessionTimerDelay (2 ).disableAutoSendUserProperties ());
565+
566+ Countly .instance ().userProfile ().setProperty ("before_timer" , "value1" );
567+
568+ Map <String , String >[] RQ = TestUtils .getCurrentRQ ();
569+ Assert .assertEquals (0 , RQ .length );
570+
571+ Thread .sleep (2500 ); // wait for the tick
572+ RQ = TestUtils .getCurrentRQ ();
573+ Assert .assertEquals (0 , RQ .length );
574+ }
575+
537576 private void validateTimedEventSize (int expectedQueueSize , int expectedTimedEventSize ) {
538577 TestUtils .validateEQSize (expectedQueueSize , TestUtils .getCurrentEQ (), moduleEvents .eventQueue );
539578 Assert .assertEquals (expectedTimedEventSize , moduleEvents .timedEvents .size ());
0 commit comments