Newer
Older
newfiber-termite / newfiber-termites / newfiber-termites-package / src / test / java / ServiceTest.java
@xiongkai xiongkai on 29 May 2 KB 基础代码调整
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.newfiber.common.core.utils.file.FileUtils;
import com.newfiber.termite.NewfiberTermiteApplication;
import com.newfiber.termite.domain.Termite;
import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
import com.newfiber.termite.domain.dto.TermiteDataDto;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.enums.EExistsAnt;
import com.newfiber.termite.mapper.TermiteMapper;
import com.newfiber.termite.service.impl.TermiteServiceImpl;
import java.io.File;
import java.util.Date;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.multipart.MultipartFile;

@SpringBootTest(classes = NewfiberTermiteApplication.class)
@RunWith(SpringRunner.class)
public class ServiceTest {

    @Resource
    private TermiteMapper termiteMapper;

    @Resource
    private TermiteServiceImpl termiteService;

    @Test
    public void uploadTest(){
//        termiteMapper.addtermiteData("ANT231031002", DateUtil.formatDateTime(new Date()),"1",new Date(),"123","123","123","123","123","123","123","123");
        termiteMapper.updatephotoIdentify("2959", "2", "123");
    }

    @Test
    public void termiteDataupTest() throws Exception{
        TermiteDataDto termiteDataDto = new TermiteDataDto();
        termiteDataDto.setSn("ANT231031003");
        MultipartFile multipartFile = FileUtils.getMultipartFile(new File("C:\\Users\\Administrator\\Downloads\\复位.png"));
        DataUpResponse dataUpResponse = termiteService.termiteDataup(termiteDataDto, multipartFile);
        System.out.println(dataUpResponse.toString());
    }

    @Test
    public void photoIdentifyTest() throws Exception{
        PhotoIdentifyDto photoIdentifyDto = new PhotoIdentifyDto();
        photoIdentifyDto.setId("1795644012890468354");
        photoIdentifyDto.setYesnoant(EExistsAnt.True.getCode());
        MultipartFile multipartFile = FileUtils.getMultipartFile(new File("C:\\Users\\Administrator\\Downloads\\复位.png"));
        String url = termiteService.photoIdentify(photoIdentifyDto, multipartFile);
        System.out.println(url);
    }
}