package com.ycwl.basic.facebody.adapter;

import com.ycwl.basic.facebody.entity.AliFaceBodyConfig;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

import static org.junit.jupiter.api.Assertions.*;

public class AliFaceBodyAdapterIT {
    private AliFaceBodyAdapter getAdapter() {
        AliFaceBodyAdapter adapter = new AliFaceBodyAdapter();
        AliFaceBodyConfig config = new AliFaceBodyConfig();
        config.setAccessKeyId("LTAI5tBr8gLs7oRVzwjmwy5s");
        config.setAccessKeySecret("ZMQcmY97tly9jypfoVqnlnPX2wqvYh");
        config.setRegion("cn-shanghai");
        adapter.setConfig(config);
        return adapter;
    };
    @Test
    public void test() {
//        String dbName = "3940097994925412352";
        String dbName = "3975985126059413504";
        AliFaceBodyAdapter adapter = getAdapter();
        while (true) {
            AtomicInteger count = new AtomicInteger(0);
            List<String> strings = adapter.listFace(dbName, "", 0, 200);
            if (strings == null || strings.isEmpty()) {
                continue;
            }
            for (String s : strings) {
                if (StringUtils.contains(s, "_")) {
                    count.incrementAndGet();
                    System.out.println(s);
                    adapter.deleteFace(dbName, s);
                }
            }
            if (count.get() == 0) {
                break;
            }
        }
    }

    @Test
    public void testDeleteDb() {
        AliFaceBodyAdapter adapter = getAdapter();
        adapter.deleteFaceDb("userFace3972138108618674176");
    }
}