如何编写POST Api

时间:2019-09-12 06:59:52

标签: rest spring-boot functional-testing

我需要为POST api编写功能测试,这仅仅是一个回调。我无法为此编写功能测试

@RequestMapping("/api/v1/controller/callback")
@Slf4j
public class DominosController {

    @Autowired
    private PartnerFactory partnerFactory;

    @RequestMapping(value = "/dominos", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    public void processDominosCallback(@RequestBody TestCallbackPojo test
CallbackPojo) {
        log.info("Dominos callback received {}", Json.serialize(dominosCallbackPojo));
        partnerFactory.getPartnerService(DeliveryPartnersEnum.DOMINOS.getValue()).processDominosCallback(dominosCallbackPojo);
    }
}

这是processDominosCallback()方法。

@Override
    public void processDominosCallback(DominosCallbackPojo dominosCallbackPojo) {
        DominosCurrentTracker dominosCurrentTracker = dominosCallbackPojo.getDominosCurrentTracker();
        if (dominosCurrentTracker == null ||  dominosCurrentTracker.getDominosTrackerStage() == null) {
            return;
        }

        PartnerOrderMapping partnerOrderMapping = PartnerOrderMapping.builder()
                .orderId(dominosCallbackPojo.getOrderId())
                .build();

        if (dominosCurrentTracker.getDominosTrackerStage().getValue() == DominosTrackerEnum.ORDER_PUNCH.getValue()) {

            CallbackPojo callbackPojo = CallbackPojo.builder()
                    .orderId(partnerOrderMapping.getOrderId())
                    .orderStatus(DominosStatusEnum.CONFIRMED.getValue())
                    .deliveryPartnersEnum(DeliveryPartnersEnum.DOMINOS)
                    .build();

            partnerStatusUpdateService.processDeConfirmed(callbackPojo);
            return;
        }
}

0 个答案:

没有答案