package com.trade.client.companyrelated.service;

import com.trade.client.enterprise.companyrelated.service.ImporterEntityCService;
import com.trade.service.enterprise.companyrelated.domain.ImporterEntity;
import com.trade.service.enterprise.companyrelated.domain.vo.ImporterEntitySearch;
import com.trade.service.trade.salesorder.service.ISalesOrderContainerService;
import com.trade.service.trade.salesorder.vo.SalesOrderContainerVO;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;

import java.util.List;

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

@SpringBootTest
class ImporterEntityCServiceTest {

    @Resource
    private ImporterEntityCService importerEntityCService;
    @Resource
    ISalesOrderContainerService salesOrderContainerService;



    @Test
    void testGerContainerByLogisticsId() {
        List<SalesOrderContainerVO> salesOrderContainerVOList = salesOrderContainerService.listByLogisticsId(1844647984394313729L);
        Assertions.assertEquals(1, salesOrderContainerVOList.size());
    }

    @Test
    void add() {
        ImporterEntity importerEntity = new ImporterEntity();
        importerEntity.setCustomerUserId(1L);
        importerEntity.setCertNo("1234567890");
        importerEntityCService.add(importerEntity);
    }

    @Test
    void update() {
        ImporterEntity importerEntity = new ImporterEntity();
        importerEntity.setId(1L);
        importerEntity.setCertNo("7777777");
        importerEntityCService.update(importerEntity);
        Assertions.assertEquals("7777777", importerEntityCService.getByEntityId(1L).getCertNo());
    }

    @Test
    void deleteByEntityId() {
        importerEntityCService.deleteByEntityId(1L);
        assertNull(importerEntityCService.getByEntityId(1L));
    }

    @Test
    void queryListBySearch() {
        ImporterEntitySearch search = new ImporterEntitySearch();
        search.setCustomerUserId(1L);
        Assertions.assertEquals(1, importerEntityCService.queryListBySearch(search).getList().size());
    }
}
