BrokerageTest.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import cn.hutool.core.lang.Assert;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  4. import com.dayou.BaseApplication;
  5. import com.dayou.bo.LeaderRatioBO;
  6. import com.dayou.brokerage.config.LandBrokerageDataConfiguration;
  7. import com.dayou.brokerage.validator.BrokerageValidator;
  8. import com.dayou.common.BaseEntity;
  9. import com.dayou.dto.ItemDTO;
  10. import com.dayou.entity.GlobalConfig;
  11. import com.dayou.entity.ItemBrokerageDetail;
  12. import com.dayou.entity.ItemBrokerageGeneral;
  13. import com.dayou.service.*;
  14. import com.google.common.collect.Sets;
  15. import lombok.extern.slf4j.Slf4j;
  16. import org.checkerframework.checker.units.qual.A;
  17. import org.junit.Test;
  18. import org.junit.runner.RunWith;
  19. import org.springframework.beans.factory.annotation.Autowired;
  20. import org.springframework.beans.factory.support.DefaultListableBeanFactory;
  21. import org.springframework.boot.test.context.SpringBootTest;
  22. import org.springframework.context.ApplicationContext;
  23. import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  24. import java.math.BigDecimal;
  25. import java.util.HashSet;
  26. import java.util.Set;
  27. /**
  28. * 类说明:
  29. *
  30. * @author: wucl
  31. * @since: 2023/3/6
  32. * created with IntelliJ IDEA.
  33. */
  34. @Slf4j
  35. @SpringBootTest(classes = BaseApplication.class)
  36. @RunWith(SpringJUnit4ClassRunner.class)
  37. public class BrokerageTest {
  38. @Autowired
  39. private ApplicationContext applicationContext;
  40. @Autowired
  41. private IGlobalConfigService globalConfigService;
  42. @Autowired
  43. private IItemBrokerageDetailService iItemBrokerageDetailService;
  44. @Autowired
  45. private IItemService iItemService;
  46. @Autowired
  47. private IItemBrokerageGeneralService iItemBrokerageGeneralService;
  48. @Autowired
  49. private LandBrokerageDataConfiguration brokerageMarketerRatioSet;
  50. @Autowired
  51. private IUserService userService;
  52. @Test
  53. public void testBrokerageValidator(){
  54. DefaultListableBeanFactory defaultListableBeanFactory = (DefaultListableBeanFactory) applicationContext.getAutowireCapableBeanFactory();
  55. BrokerageValidator brokerageValidator = defaultListableBeanFactory.getBean("brokerageValidator",BrokerageValidator.class);
  56. log.info("brokerageValidator ===="+ brokerageMarketerRatioSet.monthOfYear.toPlainString());
  57. log.info("brokerageValidator ===="+ brokerageMarketerRatioSet.nonMarketerMonthBrokerage.toPlainString());
  58. System.out.println(brokerageValidator);
  59. globalConfigService.update(new LambdaUpdateWrapper<GlobalConfig>().eq(BaseEntity::getId,18).set(GlobalConfig::getValue,"100"));
  60. globalConfigService.update(new LambdaUpdateWrapper<GlobalConfig>().eq(BaseEntity::getId,17).set(GlobalConfig::getValue,"999"));
  61. brokerageValidator.reloadBrokerageValidator();
  62. BrokerageValidator brokerageValidatorNew = defaultListableBeanFactory.getBean("brokerageValidator",BrokerageValidator.class);
  63. log.info("brokerageValidatorNew ===="+ brokerageMarketerRatioSet.monthOfYear.toPlainString());
  64. log.info("brokerageValidatorNew ===="+ brokerageMarketerRatioSet.nonMarketerMonthBrokerage.toPlainString());
  65. System.out.println(brokerageValidatorNew);
  66. }
  67. @Test
  68. public void testBrokerageMarketerRatioSet(){
  69. DefaultListableBeanFactory defaultListableBeanFactory = (DefaultListableBeanFactory) applicationContext.getAutowireCapableBeanFactory();
  70. LandBrokerageDataConfiguration brokerageMarketerRatioSet = defaultListableBeanFactory.getBean("brokerageMarketerRatioSet", LandBrokerageDataConfiguration.class);
  71. System.out.println(brokerageMarketerRatioSet);
  72. }
  73. @Test
  74. public void testCreate(){
  75. ItemDTO dto = new ItemDTO();
  76. dto.setName("BROKERAGE_TEST");
  77. dto.setBelongTo("TJC");
  78. dto.setCate(3L);
  79. dto.setBusinessSource(2L);
  80. dto.setUserId(117L);
  81. dto.setCustomerId(57L);
  82. dto.setAmount(new BigDecimal("200000"));
  83. dto.setPaymentMethod("分期付款");
  84. dto.setDepartmentId(26L);
  85. Long add = iItemService.add(dto);
  86. Assert.isTrue(add!=null);
  87. }
  88. @Test
  89. public void testORM(){
  90. ItemBrokerageGeneral general = iItemBrokerageGeneralService
  91. .getOne(new LambdaQueryWrapper<ItemBrokerageGeneral>().eq(ItemBrokerageGeneral::getItemId, 365));
  92. System.out.println(general.toString());
  93. }
  94. @Test
  95. public void testLeaderPost(){
  96. Set<LeaderRatioBO> leaderRatioBO = userService.getLeaderRatioBO(129L);
  97. System.out.println(leaderRatioBO);
  98. }
  99. }