package com.crm.manager.service;

import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.core.dto.custom.login.special.CustomLoginSpecialCalcDto;
import com.crm.rely.backend.core.entity.custom.login.special.CustomLoginSpecialCalcAddEntity;
import com.crm.rely.backend.core.entity.custom.login.special.CustomLoginSpecialCalcUpdateEntity;
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.SpringJUnit4ClassRunner;

@SpringBootTest
@RunWith(SpringJUnit4ClassRunner.class)
public class CustomLoginSpecialCalcServiceTest {

    @Autowired
    private CustomLoginSpecialCalcService customLoginSpecialCalcService;


    @Test
    public void testAdd(){
        try {
            CustomLoginSpecialCalcAddEntity entity = new CustomLoginSpecialCalcAddEntity();
            entity.setLogin(123L);
            entity.setAgentHiddenValid(1);
            entity.setAgentRebateValid(0);
            customLoginSpecialCalcService.add(entity);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @Test
    public void testUpdate(){
        try {
            CustomLoginSpecialCalcUpdateEntity entity = new CustomLoginSpecialCalcUpdateEntity();
            entity.setId(5L);
            entity.setLogin(321L);
            entity.setAgentHiddenValid(1);
            entity.setAgentRebateValid(1);
            customLoginSpecialCalcService.updateById(entity);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @Test
    public void searchSingle(){
        try {
            BaseResultDto<CustomLoginSpecialCalcDto> resultDto = customLoginSpecialCalcService.searchSingle(5L);
            System.out.println(resultDto);
        }catch (Exception e){
            e.printStackTrace();
        }
    }


    @Test
    public void deleteById(){
        try {
            customLoginSpecialCalcService.deleteById(5L);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

}
