@@ -421,6 +421,116 @@ void whenUpdatingTeamWithPartialUpdate_thenIsUpdated() {
421421 Assertions .assertEquals (updatedTeam , updateChannel .getTeam ());
422422 }
423423
424+ @ DisplayName ("Can add filter tags to a channel" )
425+ @ Test
426+ void whenAddingFilterTags_thenHasFilterTags () {
427+ // Create a fresh channel to not modify testChannel
428+ ChannelGetResponse channelGetResponse =
429+ Assertions .assertDoesNotThrow (() -> createRandomChannel ());
430+ Channel channel = channelGetResponse .getChannel ();
431+
432+ // Add filter tags
433+ ChannelUpdateResponse channelUpdateResponse =
434+ Assertions .assertDoesNotThrow (
435+ () ->
436+ Channel .update (channel .getType (), channel .getId ())
437+ .user (testUserRequestObject )
438+ .addFilterTag ("tag1" )
439+ .addFilterTag ("tag2" )
440+ .request ());
441+
442+ Channel updatedChannel = channelUpdateResponse .getChannel ();
443+ Assertions .assertNotNull (updatedChannel .getFilterTags ());
444+ Assertions .assertEquals (2 , updatedChannel .getFilterTags ().size ());
445+ Assertions .assertTrue (updatedChannel .getFilterTags ().contains ("tag1" ));
446+ Assertions .assertTrue (updatedChannel .getFilterTags ().contains ("tag2" ));
447+ }
448+
449+ @ DisplayName ("Can remove filter tags from a channel" )
450+ @ Test
451+ void whenRemovingFilterTags_thenFilterTagsRemoved () {
452+ // Create a channel and add filter tags via update
453+ ChannelGetResponse channelGetResponse =
454+ Assertions .assertDoesNotThrow (() -> createRandomChannel ());
455+ Channel channel = channelGetResponse .getChannel ();
456+
457+ // First add filter tags using update
458+ ChannelUpdateResponse addResponse =
459+ Assertions .assertDoesNotThrow (
460+ () ->
461+ Channel .update (channel .getType (), channel .getId ())
462+ .user (testUserRequestObject )
463+ .addFilterTag ("tag1" )
464+ .addFilterTag ("tag2" )
465+ .addFilterTag ("tag3" )
466+ .request ());
467+
468+ Channel channelWithTags = addResponse .getChannel ();
469+ Assertions .assertNotNull (channelWithTags .getFilterTags ());
470+ Assertions .assertEquals (3 , channelWithTags .getFilterTags ().size ());
471+
472+ // Now remove some filter tags
473+ ChannelUpdateResponse removeResponse =
474+ Assertions .assertDoesNotThrow (
475+ () ->
476+ Channel .update (channel .getType (), channel .getId ())
477+ .user (testUserRequestObject )
478+ .removeFilterTag ("tag1" )
479+ .removeFilterTag ("tag2" )
480+ .request ());
481+
482+ Channel updatedChannel = removeResponse .getChannel ();
483+ Assertions .assertNotNull (updatedChannel .getFilterTags ());
484+ Assertions .assertEquals (1 , updatedChannel .getFilterTags ().size ());
485+ Assertions .assertTrue (updatedChannel .getFilterTags ().contains ("tag3" ));
486+ }
487+
488+ @ DisplayName ("Can create channel with filter tags" )
489+ @ Test
490+ void whenCreatingChannelWithFilterTags_thenHasFilterTags () {
491+ var channelReq =
492+ ChannelRequestObject .builder ()
493+ .createdBy (testUserRequestObject )
494+ .members (buildChannelMembersList ())
495+ .filterTag ("important" )
496+ .filterTag ("urgent" )
497+ .build ();
498+ var channelType = "messaging" ;
499+ var channelId = RandomStringUtils .randomAlphabetic (12 );
500+
501+ ChannelGetResponse channelGetResponse =
502+ Assertions .assertDoesNotThrow (
503+ () -> Channel .getOrCreate (channelType , channelId ).data (channelReq ).request ());
504+
505+ Channel channel = channelGetResponse .getChannel ();
506+ Assertions .assertNotNull (channel .getFilterTags ());
507+ Assertions .assertEquals (2 , channel .getFilterTags ().size ());
508+ Assertions .assertTrue (channel .getFilterTags ().contains ("important" ));
509+ Assertions .assertTrue (channel .getFilterTags ().contains ("urgent" ));
510+ }
511+
512+ @ DisplayName ("Can set filter tags using partial update" )
513+ @ Test
514+ void whenSettingFilterTagsWithPartialUpdate_thenFilterTagsSet () {
515+ // Create a fresh channel
516+ Channel channel = Assertions .assertDoesNotThrow (() -> createRandomChannel ()).getChannel ();
517+
518+ // Set filter tags using partial update
519+ Channel updatedChannel =
520+ Assertions .assertDoesNotThrow (
521+ () ->
522+ Channel .partialUpdate (channel .getType (), channel .getId ())
523+ .setValue ("filter_tags" , List .of ("partial1" , "partial2" ))
524+ .user (testUserRequestObject )
525+ .request ()
526+ .getChannel ());
527+
528+ Assertions .assertNotNull (updatedChannel .getFilterTags ());
529+ Assertions .assertEquals (2 , updatedChannel .getFilterTags ().size ());
530+ Assertions .assertTrue (updatedChannel .getFilterTags ().contains ("partial1" ));
531+ Assertions .assertTrue (updatedChannel .getFilterTags ().contains ("partial2" ));
532+ }
533+
424534 @ DisplayName ("Can assign roles" )
425535 @ Test
426536 void whenAssigningRole_throwsNoError () {
0 commit comments