junit测试用例

yqhsw0fo  于 2021-08-20  发布在  Java
关注(0)|答案(0)|浏览(267)

我必须为curd操作的restapi编写一个junit测试用例。我正在寻找控制器和服务类的测试用例流。我无法模拟firestore相关对象,请使用基于spring boot应用程序的rest api junit测试用例提供一些示例。
控制器示例代码:

@RestController
@RequestMapping("/subscription/v1")
public class SubscriptionController {

    private static final Logger LOGGER = LoggerFactory.getLogger(SubscriptionController.class);

    @Autowired
    ISubscriptionService iSubscriptionService;
    final HttpHeaders httpHeaders = new HttpHeaders();

    @PostMapping(value = "/account", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<String> addSubscription(@RequestBody UserSubscription userSubscription) {
        ......
    }

    @GetMapping(value = "/account/{accountId}", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<String> getSubscription(@PathVariable("accountId") String accountId)
            throws InterruptedException, ExecutionException {
        .....
    }

    @PutMapping(value = "/account/{accountId}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<String> updateSubscription(@RequestBody UserSubscription userSubscription,
            @PathVariable(Constants.ACC_ID) String accountId) throws InterruptedException, ExecutionException {
        .....
    }

}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题