如何为循环使用junit / mockito编写测试用例

时间:2019-07-31 08:26:38

标签: java junit mockito

我有一种需要编写测试用例的方法

List<ProductDetailsResponse> getProductDetailsList(final List<String> productsCinList, final String fields,
            final String shiptos) throws InterruptedException, ExecutionException {
        final long startTime = System.currentTimeMillis();
        int count = 0;
        List<ProductDetailsResponse> productDetails = new ArrayList<>();
        String productStr = productsCinList.stream().limit(Long.parseLong(productCinProcessingLimit))
                .collect(Collectors.joining(","));

        while (!(productStr.isEmpty())) {
            List<CompletableFuture<ResponseEntity<List<ProductDetailsResponse>>>> productDetailCompletableFuture = new ArrayList<>();
            for (int i = 0; i < noOfProductThread; i++) {
                if (!(productStr.isEmpty())) {
                    productDetailCompletableFuture.add(getCardinalProductDetails(productStr, shiptos, fields));
                    productStr = productsCinList.stream().skip(++count * Long.parseLong(productCinProcessingLimit))
                            .limit(Long.parseLong(productCinProcessingLimit)).collect(Collectors.joining(","));
                }
            }
            productDetailCompletableFuture.forEach(prd -> CompletableFuture.allOf(prd).join());
            if (!productDetailCompletableFuture.isEmpty()) {
                for (CompletableFuture<ResponseEntity<List<ProductDetailsResponse>>> prd : productDetailCompletableFuture) {
                    if (null != prd && prd.get().getStatusCode().equals(org.springframework.http.HttpStatus.OK)) {
                        productDetails.addAll(prd.get().getBody());
                    }
                }
            }
        }

我不确定要为此写些什么。

0 个答案:

没有答案