import cn.hutool.core.lang.Assert; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.dayou.BaseApplication; import com.dayou.bo.LeaderRatioBO; import com.dayou.brokerage.config.LandBrokerageDataConfiguration; import com.dayou.brokerage.validator.BrokerageValidator; import com.dayou.common.BaseEntity; import com.dayou.dto.ItemDTO; import com.dayou.entity.GlobalConfig; import com.dayou.entity.ItemBrokerageDetail; import com.dayou.entity.ItemBrokerageGeneral; import com.dayou.service.*; import com.google.common.collect.Sets; import lombok.extern.slf4j.Slf4j; import org.checkerframework.checker.units.qual.A; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.ApplicationContext; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import java.math.BigDecimal; import java.util.HashSet; import java.util.Set; /** * 类说明: * * @author: wucl * @since: 2023/3/6 * created with IntelliJ IDEA. */ @Slf4j @SpringBootTest(classes = BaseApplication.class) @RunWith(SpringJUnit4ClassRunner.class) public class BrokerageTest { @Autowired private ApplicationContext applicationContext; @Autowired private IGlobalConfigService globalConfigService; @Autowired private IItemBrokerageDetailService iItemBrokerageDetailService; @Autowired private IItemService iItemService; @Autowired private IItemBrokerageGeneralService iItemBrokerageGeneralService; @Autowired private LandBrokerageDataConfiguration brokerageMarketerRatioSet; @Autowired private IUserService userService; @Test public void testBrokerageValidator(){ DefaultListableBeanFactory defaultListableBeanFactory = (DefaultListableBeanFactory) applicationContext.getAutowireCapableBeanFactory(); BrokerageValidator brokerageValidator = defaultListableBeanFactory.getBean("brokerageValidator",BrokerageValidator.class); log.info("brokerageValidator ===="+ brokerageMarketerRatioSet.monthOfYear.toPlainString()); log.info("brokerageValidator ===="+ brokerageMarketerRatioSet.nonMarketerMonthBrokerage.toPlainString()); System.out.println(brokerageValidator); globalConfigService.update(new LambdaUpdateWrapper().eq(BaseEntity::getId,18).set(GlobalConfig::getValue,"100")); globalConfigService.update(new LambdaUpdateWrapper().eq(BaseEntity::getId,17).set(GlobalConfig::getValue,"999")); brokerageValidator.reloadBrokerageValidator(); BrokerageValidator brokerageValidatorNew = defaultListableBeanFactory.getBean("brokerageValidator",BrokerageValidator.class); log.info("brokerageValidatorNew ===="+ brokerageMarketerRatioSet.monthOfYear.toPlainString()); log.info("brokerageValidatorNew ===="+ brokerageMarketerRatioSet.nonMarketerMonthBrokerage.toPlainString()); System.out.println(brokerageValidatorNew); } @Test public void testBrokerageMarketerRatioSet(){ DefaultListableBeanFactory defaultListableBeanFactory = (DefaultListableBeanFactory) applicationContext.getAutowireCapableBeanFactory(); LandBrokerageDataConfiguration brokerageMarketerRatioSet = defaultListableBeanFactory.getBean("brokerageMarketerRatioSet", LandBrokerageDataConfiguration.class); System.out.println(brokerageMarketerRatioSet); } @Test public void testCreate(){ ItemDTO dto = new ItemDTO(); dto.setName("BROKERAGE_TEST"); dto.setBelongTo("TJC"); dto.setCate(3L); dto.setBusinessSource(2L); dto.setUserId(117L); dto.setCustomerId(57L); dto.setAmount(new BigDecimal("200000")); dto.setPaymentMethod("分期付款"); dto.setDepartmentId(26L); Long add = iItemService.add(dto); Assert.isTrue(add!=null); } @Test public void testORM(){ ItemBrokerageGeneral general = iItemBrokerageGeneralService .getOne(new LambdaQueryWrapper().eq(ItemBrokerageGeneral::getItemId, 365)); System.out.println(general.toString()); } @Test public void testLeaderPost(){ Set leaderRatioBO = userService.getLeaderRatioBO(129L); System.out.println(leaderRatioBO); } }