测试rabbitMQ

This commit is contained in:
Guoqs
2024-11-05 16:44:26 +08:00
parent 5a1cf19699
commit 45a2920981
3 changed files with 54 additions and 10 deletions

View File

@@ -28,6 +28,7 @@ import com.jsowell.adapay.vo.DrawCashDetailVO;
import com.jsowell.adapay.vo.PaymentInfo;
import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.constant.Constants;
import com.jsowell.common.constant.RabbitConstants;
import com.jsowell.common.core.domain.entity.SysDictData;
import com.jsowell.common.core.domain.ykc.LoginRequestData;
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
@@ -89,6 +90,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
@@ -267,6 +269,46 @@ public class SpringBootTestController {
@Autowired
private CarCouponRecordService carCouponRecordService;
@Autowired
private RabbitTemplate rabbitTemplate;
@Test
public void sendRabbitMqTest() {
OrderBasicInfo orderBasicInfo = OrderBasicInfo.builder()
.orderCode("C123456789")
.merchantId("1")
.stationId("2")
.payAmount(new BigDecimal(100))
.orderAmount(new BigDecimal(100))
.settleAmount(new BigDecimal(100))
.refundAmount(new BigDecimal(0))
.build();
OrderDetail orderDetail = OrderDetail.builder()
.totalElectricityAmount(new BigDecimal(50))
.discountElectricityAmount(new BigDecimal(0))
.totalServiceAmount(new BigDecimal(50))
.discountElectricityAmount(new BigDecimal(0))
.build();
AfterSettleOrderDTO afterSettleOrderDTO = AfterSettleOrderDTO.builder()
.orderCode(orderBasicInfo.getOrderCode())
.merchantId(orderBasicInfo.getMerchantId())
.stationId(orderBasicInfo.getStationId())
.orderPayAmount(orderBasicInfo.getPayAmount())
.orderConsumeAmount(orderBasicInfo.getOrderAmount())
.orderSettleAmount(orderBasicInfo.getSettleAmount())
.orderElectricityAmount(orderDetail.getTotalElectricityAmount())
.orderElectricityDiscountAmount(orderDetail.getDiscountElectricityAmount())
.orderServiceAmount(orderDetail.getTotalServiceAmount())
.orderServiceDiscountAmount(orderDetail.getDiscountServiceAmount())
.orderRefundAmount(orderBasicInfo.getRefundAmount())
.build();
for (int i = 0; i < 10; i++) {
rabbitTemplate.convertAndSend(RabbitConstants.YKC_EXCHANGE_NAME, RabbitConstants.QUEUE_CHARGE_ORDER_DATA, afterSettleOrderDTO);
}
}
@Test
public void selectPileConnectorInfoListByPileSnListTest() {
List<String> pileSnList = Lists.newArrayList();