package cd.casic.server;

import cd.casic.ci.commons.properties.TargetFileUploadProperties;
import cd.casic.ci.process.dto.resp.aflCrashesAnalyzer.AflCrashesAnalyzerListResp;
import cd.casic.ci.process.dto.resp.resource.ResourceDetailResp;
import cd.casic.ci.process.process.dataObject.history.PipPipelineHisInstance;
import cd.casic.ci.process.process.dataObject.resource.PipResourceManager;
import cd.casic.ci.process.process.service.aflAnalyzer.AflCrashesAnalyzerService;
import cd.casic.ci.process.process.service.history.PipelineHistoryService;
import cd.casic.ci.process.process.service.resource.ResourceManagerService;
import cd.casic.framework.commons.pojo.PageParam;
import cd.casic.framework.commons.pojo.PageResult;
import com.jcraft.jsch.*;
import jakarta.annotation.Resource;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.web.WebAppConfiguration;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

@SpringBootTest(classes = {OpsServerApplication.class})
@ActiveProfiles("local")
@WebAppConfiguration
public class AflCrashesAnalyzerTest {
    @Resource
    AflCrashesAnalyzerService crashesAnalyzerService;
    @Resource
    PipelineHistoryService historyService;
    @Resource
    ResourceManagerService resourceManagerService;
    @Test
    public void test01(){
        PipPipelineHisInstance byId = historyService.getById("743101099321462784");
        System.out.println(byId);
        ResourceDetailResp resource = resourceManagerService.findResourceDetailById("735516490182299648");
        crashesAnalyzerService.saveCrashesByOutputPath("/home/casic/706/yunqi/PIP_"+byId.getPipelineId()+"/aflCrash",resource,byId.getPipelineId(),"738805555593875459",byId.getId());
    }
    @Test
    public void test02(){
        PageResult<AflCrashesAnalyzerListResp> crashesPageList = crashesAnalyzerService.getCrashesPageList(new PageParam());
        System.out.println(crashesPageList);
    }
}
