package com.ycwl.basic.facebody.adapter;

import com.ycwl.basic.facebody.entity.BceFaceBodyConfig;
import org.junit.Test;

import java.util.List;

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

public class BceFaceBodyAdapterTest {
    private BceFaceBodyAdapter getAdapter() {
        BceFaceBodyAdapter adapter = new BceFaceBodyAdapter();
        BceFaceBodyConfig config = new BceFaceBodyConfig();
        config.setAppId("118363478");
        config.setApiKey("3rXrDdU4cHZqLS8ICFSYZKse");
        config.setSecretKey("zgGFehERZKYXEiRQpqWs9AYchLxzXzYa");
        adapter.setConfig(config);
        return adapter;
    }

    @Test
    public void testDbCreate() {
        BceFaceBodyAdapter adapter = getAdapter();
        boolean b = adapter.addFaceDb("test");
        assertTrue(b);
        boolean b0 = adapter.assureFaceDb("test");
        assertTrue(b0);
        boolean b1 = adapter.deleteFaceDb("test");
        assertTrue(b1);
        boolean b2 = adapter.assureFaceDb("test");
        assertTrue(b2);
        boolean b3 = adapter.deleteFaceDb("test");
        assertTrue(b3);
    }

    @Test
    public void testAddFace() {
        BceFaceBodyAdapter adapter = getAdapter();
        adapter.assureFaceDb("test");
        adapter.addFace("test", "test", "https://frametour-assets.oss-cn-shanghai.aliyuncs.com/user-faces/user-face/c925d970-216a-4eff-b699-cd047c0f9088.jpg", "test");
        List<String> strings = adapter.listUserFace("test", "test");
        assertFalse(strings.isEmpty());
        adapter.deleteFace("test", "test");
        List<String> stringList = adapter.listUserFace("test", "test");
        assertTrue(stringList.isEmpty());
        List<String> listFace = adapter.listFace("test", null, 0, 10);
        assertTrue(listFace.isEmpty());
    }
}