@Autowired
private OrganizationService organizationService;
@Test
public void testClearDeletedGroupRelation() {
Group group = new Group();
group.setType(GroupType.organization);
group.setShow(false);
group.setName("123");
groupService.save(group);
Organization organization1 = new Organization();
organization1.setName("test1");
Organization organization2 = new Organization();
organization2.setName("test2");
organizationService.save(organization1);
organizationService.save(organization2);
GroupRelation groupRelation1 = new GroupRelation();
groupRelation1.setGroupId(group.getId());
groupRelation1.setOrganizationId(organization1.getId());
GroupRelation groupRelation2 = new GroupRelation();
groupRelation2.setGroupId(group.getId());
groupRelation2.setOrganizationId(organization2.getId());
groupRelationService.save(groupRelation1);
groupRelationService.save(groupRelation2);
Searchable searchable = Searchable.newSearchable();
searchable.addSearchFilter("groupId", SearchOperator.eq, group.getId());
Assert.assertEquals(2, groupRelationService.count());
organizationService.delete(organization1);
groupClearRelationTask.clearDeletedGroupRelation();