<reponame>itsoo/nfs-web
package com.sncfc.nfs.module.empower;

import com.sncfc.baseframework.core.pojo.User;
import com.sncfc.nfs.common.BaseFrameworkTest;
import com.sncfc.nfs.module.file.core.Power;
import com.sncfc.nfs.module.file.entity.FileInfoDTO;
import com.sncfc.nfs.module.user.entity.TreeUserBO;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.ArrayList;

/**
 * @author zxy
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class EmpowerTest extends BaseFrameworkTest {

    @Autowired
    private EmpowerService empowerService;

    @Test
    public void test1() {
        Power power = empowerService.postPowered(
                new FileInfoDTO() {{
                    setFileId(BaseFrameworkTest.ID);
                    setCreateUserNo("test");
                    setSncfcNo("test");
                }}, new ArrayList<TreeUserBO>() {{
                    add(new TreeUserBO().setId("test"));
                }}, new User() {{ setSncfcNo("test"); }});
        Assert.assertEquals(Power.NONE_POWERED, power);
    }

    @Test
    public void test2() {
        Power power = empowerService.postPowered(
                new FileInfoDTO()
                        .setFileId(BaseFrameworkTest.ID)
                        .setCreateUserNo("test")
                        .setSncfcNo("test"), new ArrayList<TreeUserBO>() {{
                    add(new TreeUserBO().setId("88377760"));
                    add(new TreeUserBO().setId("88376854"));
                }}, new User() {{ setSncfcNo("test"); }});
        Assert.assertEquals(Power.ALL_PASSING, power);
    }

    @Test
    public void test3() {
        Power power = empowerService.postPowered(
                new FileInfoDTO()
                        .setFileId(BaseFrameworkTest.ID)
                        .setCreateUserNo("test")
                        .setSncfcNo("test"), new ArrayList<TreeUserBO>() {{
                    add(new TreeUserBO().setId("test"));
                }}, new User() {{ setSncfcNo("test"); }});
        Assert.assertEquals(Power.ALL_PASSING, power);
    }
}
