问题描述
使用concatMaps的父通量转到第一个concatMap,然后再使用其中一个带有内部flux.concatMap.collectList()的concatMap完成工作。
-
获取所有测试案例
-
获取会话中的工作ID
-
对于每个作业ID, a)使用WebClient击中http并获得响应 b)对于每个测试用例 i)使用WebClient打一个http呼叫并获得响应 ii)比较测试用例的预期结果与实际生成的结果。 c)一旦执行完所有测试用例,就会生成带有“通过Vs失败”的转贴。
Mono.fromCallable(() -> iRegressionTestSuiteDao.getMasterTestCases()) .flatMap(listofTestCases -> { System.out.println("testCases list : " + listofTestCases.size()); return Mono.fromCallable(() -> iRegressionTestSuiteDao.getPeriodicJobIds()).flatMapMany(listofJobs -> { System.out.println("jobs list : " + listofJobs.size()); return Flux.fromStream(listofJobs.stream()); }).concatMap(periodicJob -> { System.out.println("Job : " + periodicJob.getJobId()); return iSandBoxRuleEngineClient.populateSandBoxCache(periodicJob); }).concatMap(sandBoxResult -> { List<String> refId = (List<String>) sandBoxResult; System.out.println(" Ref Id 1: " + refId.get(0)+ "Ref Id 2: "+refId.get(1)); listofTestCases.forEach(c -> { c.setRefId(refId.get(0)); }); return Mono.fromsupplier(() -> listofTestCases); } }).concatMap(listofMTC -> { List<MasterTestCases> masterTestCasesList = (List<MasterTestCases>) listofMTC; System.out.println("No of tcs :" + masterTestCasesList.size()); return Flux.fromIterable(masterTestCasesList) //.publishOn(Schedulers.boundedElastic()) .concatMap(tc -> { MasterTestCases m = (MasterTestCases) tc; System.out.println(" Ref Id: " + m.getRefId() + " TestCase : " + m.getTestCaseId()); Gson gson = new Gson(); RoutePlanServiceRequest rr = gson.fromJson(m.getRequest(),RoutePlanServiceRequest.class); return iSandBoxRuleEngineClient.getRoutePlanResponseForTestCase(rr,m); }) .concatMap(respObj -> { RoutePlanServiceResponse masterResp = (RoutePlanServiceResponse)respObj; RefIdTestCaseResult refIdTestCaseResult = null; try { boolean b = isMatched(masterResp.getResponse().getLegs(),rpsr.getResponse().getLegs()); System.out.println(" Ref Id: " + mtc.getRefId() + " TestCase : " + mtc.getTestCaseId() + " Is matched " + b); refIdTestCaseResult = new RefIdTestCaseResult(); refIdTestCaseResult.setRefId(mtc.getRefId()); refIdTestCaseResult.setTestCaseId(mtc.getTestCaseId()); refIdTestCaseResult.setPassed(b); } catch (Throwable t) { System.out.println("Exception :" + t); } return Mono.just(refIdTestCaseResult); }).collectList(); }).concatMap(listofRefBools -> { List<RefIdTestCaseResult> ismatchedList = (List<RefIdTestCaseResult>) listofRefBools; Map<Boolean,List<RefIdTestCaseResult>> partitioned = ismatchedList.stream() .collect(Collectors.partitioningBy(RefIdTestCaseResult::isPassed)); List<RefIdTestCaseResult> matchedList = partitioned.get(true); List<RefIdTestCaseResult> unMatchedList = partitioned.get(false); System.out.println( " Ref Id: " + ismatchedList.get(0).getRefId() + " TestCase no : " + ismatchedList.size() + " matched : " + matchedList.size() + "unmatched : " + unMatchedList.size()); return Mono.just("TASK DONE"); }).then(); }).block();
输出:enter image description here
预期输出:enter image description here
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)