@@ -937,4 +937,105 @@ void testChannelBatchUpdate() throws Exception {
937937 }
938938 }
939939 }
940+
941+ @ Test
942+ @ Order (20 )
943+ void testSetRetentionPolicy () throws Exception {
944+ try {
945+ var resp =
946+ client
947+ .chat ()
948+ .setRetentionPolicy (
949+ SetRetentionPolicyRequest .builder ()
950+ .policy ("old-messages" )
951+ .maxAgeHours (720 )
952+ .build ())
953+ .execute ();
954+
955+ assertNotNull (resp .getData (), "SetRetentionPolicy response should not be null" );
956+ assertNotNull (resp .getData ().getDuration (), "Duration should not be null" );
957+ assertNotNull (resp .getData ().getPolicy (), "Policy should not be null" );
958+ } catch (Exception e ) {
959+ String msg = e .getMessage () != null ? e .getMessage () : "" ;
960+ Assumptions .assumeTrue (
961+ !msg .contains ("not available" )
962+ && !msg .contains ("not supported" )
963+ && !msg .contains ("not enabled" )
964+ && !msg .contains ("retention" ),
965+ "Retention policy feature not available on this app: " + msg );
966+ throw e ;
967+ }
968+ }
969+
970+ @ Test
971+ @ Order (21 )
972+ void testGetRetentionPolicy () throws Exception {
973+ try {
974+ var resp = client .chat ().getRetentionPolicy ().execute ();
975+
976+ assertNotNull (resp .getData (), "GetRetentionPolicy response should not be null" );
977+ assertNotNull (resp .getData ().getDuration (), "Duration should not be null" );
978+ assertNotNull (resp .getData ().getPolicies (), "Policies list should not be null" );
979+ } catch (Exception e ) {
980+ String msg = e .getMessage () != null ? e .getMessage () : "" ;
981+ Assumptions .assumeTrue (
982+ !msg .contains ("not available" )
983+ && !msg .contains ("not supported" )
984+ && !msg .contains ("not enabled" )
985+ && !msg .contains ("retention" ),
986+ "Retention policy feature not available on this app: " + msg );
987+ throw e ;
988+ }
989+ }
990+
991+ @ Test
992+ @ Order (22 )
993+ void testGetRetentionPolicyRuns () throws Exception {
994+ try {
995+ var resp =
996+ client
997+ .chat ()
998+ .getRetentionPolicyRuns (
999+ GetRetentionPolicyRunsRequest .builder ().Limit (10 ).Offset (0 ).build ())
1000+ .execute ();
1001+
1002+ assertNotNull (resp .getData (), "GetRetentionPolicyRuns response should not be null" );
1003+ assertNotNull (resp .getData ().getDuration (), "Duration should not be null" );
1004+ assertNotNull (resp .getData ().getRuns (), "Runs list should not be null" );
1005+ } catch (Exception e ) {
1006+ String msg = e .getMessage () != null ? e .getMessage () : "" ;
1007+ Assumptions .assumeTrue (
1008+ !msg .contains ("not available" )
1009+ && !msg .contains ("not supported" )
1010+ && !msg .contains ("not enabled" )
1011+ && !msg .contains ("retention" ),
1012+ "Retention policy feature not available on this app: " + msg );
1013+ throw e ;
1014+ }
1015+ }
1016+
1017+ @ Test
1018+ @ Order (23 )
1019+ void testDeleteRetentionPolicy () throws Exception {
1020+ try {
1021+ var resp =
1022+ client
1023+ .chat ()
1024+ .deleteRetentionPolicy (
1025+ DeleteRetentionPolicyRequest .builder ().policy ("old-messages" ).build ())
1026+ .execute ();
1027+
1028+ assertNotNull (resp .getData (), "DeleteRetentionPolicy response should not be null" );
1029+ assertNotNull (resp .getData ().getDuration (), "Duration should not be null" );
1030+ } catch (Exception e ) {
1031+ String msg = e .getMessage () != null ? e .getMessage () : "" ;
1032+ Assumptions .assumeTrue (
1033+ !msg .contains ("not available" )
1034+ && !msg .contains ("not supported" )
1035+ && !msg .contains ("not enabled" )
1036+ && !msg .contains ("retention" ),
1037+ "Retention policy feature not available on this app: " + msg );
1038+ throw e ;
1039+ }
1040+ }
9401041}
0 commit comments