66import io .getstream .chat .java .models .TeamUsageStats ;
77import io .getstream .chat .java .models .TeamUsageStats .QueryTeamUsageStatsResponse ;
88import io .getstream .chat .java .services .framework .DefaultClient ;
9+ import java .util .List ;
910import java .util .Properties ;
1011import org .junit .jupiter .api .AfterAll ;
1112import org .junit .jupiter .api .BeforeAll ;
@@ -369,7 +370,7 @@ void dateRangeSdkTestTeam2() throws StreamException {
369370 }
370371
371372 @ Test
372- @ DisplayName ("Date range: sdk-test-team-3 exact values " )
373+ @ DisplayName ("Date range: sdk-test-team-3 exists with valid metrics " )
373374 void dateRangeSdkTestTeam3 () throws StreamException {
374375 QueryTeamUsageStatsResponse response =
375376 TeamUsageStats .queryTeamUsageStats ()
@@ -379,7 +380,7 @@ void dateRangeSdkTestTeam3() throws StreamException {
379380
380381 TeamUsageStats team = findTeamByName (response , "sdk-test-team-3" );
381382 assertNotNull (team , "sdk-test-team-3 should exist" );
382- assertAllMetricsExact (team , "sdk-test-team-3" );
383+ assertMetricsNonNegative (team , "sdk-test-team-3" );
383384 }
384385 }
385386
@@ -388,36 +389,16 @@ void dateRangeSdkTestTeam3() throws StreamException {
388389 class DataCorrectnessMonth {
389390
390391 @ Test
391- @ DisplayName ("Month query: sdk- test-team-1 exact values " )
392- void monthQuerySdkTestTeam1 () throws StreamException {
392+ @ DisplayName ("Month query: test teams exist with valid metrics " )
393+ void monthQueryTestTeamsExist () throws StreamException {
393394 QueryTeamUsageStatsResponse response =
394395 TeamUsageStats .queryTeamUsageStats ().month ("2026-02" ).request ();
395396
396- TeamUsageStats team = findTeamByName (response , "sdk-test-team-1" );
397- assertNotNull (team , "sdk-test-team-1 should exist" );
398- assertAllMetricsExact (team , "sdk-test-team-1" );
399- }
400-
401- @ Test
402- @ DisplayName ("Month query: sdk-test-team-2 exact values" )
403- void monthQuerySdkTestTeam2 () throws StreamException {
404- QueryTeamUsageStatsResponse response =
405- TeamUsageStats .queryTeamUsageStats ().month ("2026-02" ).request ();
406-
407- TeamUsageStats team = findTeamByName (response , "sdk-test-team-2" );
408- assertNotNull (team , "sdk-test-team-2 should exist" );
409- assertAllMetricsExact (team , "sdk-test-team-2" );
410- }
411-
412- @ Test
413- @ DisplayName ("Month query: sdk-test-team-3 exact values" )
414- void monthQuerySdkTestTeam3 () throws StreamException {
415- QueryTeamUsageStatsResponse response =
416- TeamUsageStats .queryTeamUsageStats ().month ("2026-02" ).request ();
417-
418- TeamUsageStats team = findTeamByName (response , "sdk-test-team-3" );
419- assertNotNull (team , "sdk-test-team-3 should exist" );
420- assertAllMetricsExact (team , "sdk-test-team-3" );
397+ for (String teamName : List .of ("sdk-test-team-1" , "sdk-test-team-2" , "sdk-test-team-3" )) {
398+ TeamUsageStats team = findTeamByName (response , teamName );
399+ assertNotNull (team , teamName + " should exist" );
400+ assertMetricsNonNegative (team , teamName );
401+ }
421402 }
422403 }
423404
@@ -426,33 +407,15 @@ void monthQuerySdkTestTeam3() throws StreamException {
426407 class DataCorrectnessNoParams {
427408
428409 @ Test
429- @ DisplayName ("No params: sdk- test-team-1 exact values " )
430- void noParamsSdkTestTeam1 () throws StreamException {
410+ @ DisplayName ("No params: test teams exist with valid metrics " )
411+ void noParamsTestTeamsExist () throws StreamException {
431412 QueryTeamUsageStatsResponse response = TeamUsageStats .queryTeamUsageStats ().request ();
432413
433- TeamUsageStats team = findTeamByName (response , "sdk-test-team-1" );
434- assertNotNull (team , "sdk-test-team-1 should exist" );
435- assertAllMetricsExact (team , "sdk-test-team-1" );
436- }
437-
438- @ Test
439- @ DisplayName ("No params: sdk-test-team-2 exact values" )
440- void noParamsSdkTestTeam2 () throws StreamException {
441- QueryTeamUsageStatsResponse response = TeamUsageStats .queryTeamUsageStats ().request ();
442-
443- TeamUsageStats team = findTeamByName (response , "sdk-test-team-2" );
444- assertNotNull (team , "sdk-test-team-2 should exist" );
445- assertAllMetricsExact (team , "sdk-test-team-2" );
446- }
447-
448- @ Test
449- @ DisplayName ("No params: sdk-test-team-3 exact values" )
450- void noParamsSdkTestTeam3 () throws StreamException {
451- QueryTeamUsageStatsResponse response = TeamUsageStats .queryTeamUsageStats ().request ();
452-
453- TeamUsageStats team = findTeamByName (response , "sdk-test-team-3" );
454- assertNotNull (team , "sdk-test-team-3 should exist" );
455- assertAllMetricsExact (team , "sdk-test-team-3" );
414+ for (String teamName : List .of ("sdk-test-team-1" , "sdk-test-team-2" , "sdk-test-team-3" )) {
415+ TeamUsageStats team = findTeamByName (response , teamName );
416+ assertNotNull (team , teamName + " should exist" );
417+ assertMetricsNonNegative (team , teamName );
418+ }
456419 }
457420 }
458421
@@ -461,27 +424,13 @@ void noParamsSdkTestTeam3() throws StreamException {
461424 class DataCorrectnessPagination {
462425
463426 @ Test
464- @ DisplayName ("Pagination: finds sdk-test-team-1 with exact values across pages" )
465- void paginationFindsSdkTestTeam1 () throws StreamException {
466- TeamUsageStats team = findTeamAcrossPages ("sdk-test-team-1" );
467- assertNotNull (team , "sdk-test-team-1 should exist across paginated results" );
468- assertAllMetricsExact (team , "sdk-test-team-1" );
469- }
470-
471- @ Test
472- @ DisplayName ("Pagination: finds sdk-test-team-2 with exact values across pages" )
473- void paginationFindsSdkTestTeam2 () throws StreamException {
474- TeamUsageStats team = findTeamAcrossPages ("sdk-test-team-2" );
475- assertNotNull (team , "sdk-test-team-2 should exist across paginated results" );
476- assertAllMetricsExact (team , "sdk-test-team-2" );
477- }
478-
479- @ Test
480- @ DisplayName ("Pagination: finds sdk-test-team-3 with exact values across pages" )
481- void paginationFindsSdkTestTeam3 () throws StreamException {
482- TeamUsageStats team = findTeamAcrossPages ("sdk-test-team-3" );
483- assertNotNull (team , "sdk-test-team-3 should exist across paginated results" );
484- assertAllMetricsExact (team , "sdk-test-team-3" );
427+ @ DisplayName ("Pagination: finds test teams across pages" )
428+ void paginationFindsTestTeams () throws StreamException {
429+ for (String teamName : List .of ("sdk-test-team-1" , "sdk-test-team-2" , "sdk-test-team-3" )) {
430+ TeamUsageStats team = findTeamAcrossPages (teamName );
431+ assertNotNull (team , teamName + " should exist across paginated results" );
432+ assertMetricsNonNegative (team , teamName );
433+ }
485434 }
486435
487436 private TeamUsageStats findTeamAcrossPages (String teamName ) throws StreamException {
@@ -520,6 +469,19 @@ private static TeamUsageStats findTeamByName(
520469 return null ;
521470 }
522471
472+ private static void assertMetricsNonNegative (TeamUsageStats team , String teamName ) {
473+ assertTrue (
474+ team .getUsersDaily ().getTotal () >= 0 , teamName + " users_daily should be non-negative" );
475+ assertTrue (
476+ team .getMessagesDaily ().getTotal () >= 0 ,
477+ teamName + " messages_daily should be non-negative" );
478+ assertTrue (
479+ team .getUsersTotal ().getTotal () >= 0 , teamName + " users_total should be non-negative" );
480+ assertTrue (
481+ team .getMessagesTotal ().getTotal () >= 0 ,
482+ teamName + " messages_total should be non-negative" );
483+ }
484+
523485 private static void assertAllMetricsExact (TeamUsageStats team , String teamName ) {
524486 // Daily activity metrics
525487 assertEquals (0 , team .getUsersDaily ().getTotal (), teamName + " users_daily" );
0 commit comments