Skip to content

Commit 1924def

Browse files
feat: with disabled using
1 parent e85b36b commit 1924def

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

sdk-java/src/test/java/ly/count/sdk/java/internal/SessionImplTests.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,38 @@ public void userPropsOnSessions() throws InterruptedException {
672672
Assert.assertEquals("1", RQ[5].get("end_session"));
673673
}
674674

675+
/**
676+
* Validates that when session calls are made, if any user properties are set,
677+
* they are not packed because auto-send is disabled
678+
*
679+
* @throws InterruptedException if thread is interrupted
680+
*/
681+
@Test
682+
public void userPropsOnSessions_reversed() throws InterruptedException {
683+
Countly.instance().init(TestUtils.getConfigSessions(Config.Feature.UserProfiles).disableAutoSendUserPropertiesOnSessions());
684+
Countly.instance().userProfile().setProperty("name", "John Doe");
685+
Countly.instance().userProfile().setProperty("custom_key", "custom_value");
686+
687+
Countly.session().begin();
688+
Map<String, String>[] RQ = TestUtils.getCurrentRQ();
689+
Assert.assertEquals(1, RQ.length);
690+
Assert.assertEquals("1", RQ[0].get("begin_session"));
691+
692+
Thread.sleep(2000); // wait for session to update
693+
Countly.session().update();
694+
RQ = TestUtils.getCurrentRQ();
695+
696+
Assert.assertEquals(2, RQ.length);
697+
Assert.assertEquals("2", RQ[1].get("session_duration"));
698+
699+
Thread.sleep(2000);
700+
Countly.session().end();
701+
RQ = TestUtils.getCurrentRQ();
702+
703+
Assert.assertEquals(3, RQ.length);
704+
Assert.assertEquals("1", RQ[2].get("end_session"));
705+
}
706+
675707
private void validateNotEquals(int idOffset, BiFunction<SessionImpl, SessionImpl, Consumer<Long>> setter) {
676708
Countly.instance().init(TestUtils.getConfigSessions());
677709
long ts = TimeUtils.timestampMs();

0 commit comments

Comments
 (0)