@Testvoid shouldCorrectlyAggregate_whenMultipleFetchParamsResults() { // 准备数据 List<FetchParam> fetchParams = Arrays.asList(new FetchParam(), new FetchParam()); Set<OriginalFieldFetcher> fetchers = new HashSet<>(singletonList(mockFetcher1));
Map<OriginalFieldDef, Object> dataMap1 = new HashMap<>(); dataMap1.put(OriginalFieldDef.orderId, "value1");
Map<OriginalFieldDef, Object> dataMap2 = new HashMap<>(); dataMap2.put(OriginalFieldDef.orderStatus, "value2");
when(mockFetcher1.batchQuery(fetchParams)) .thenReturn(Arrays.asList( new FetchTargetOriginalData(1L, dataMap1), new FetchTargetOriginalData(2L, dataMap2) ));
// 执行 Map<Long, Map<OriginalFieldDef, Object>> result = executor.doFetchersBatchQuery(fetchParams, fetchers);
// 验证 assertEquals(2, result.size(), "应处理并返回两个不同主体ID的结果"); assertEquals(1, result.get(1L).size(), "第一个主体ID下应有一个字段数据"); assertEquals(1, result.get(2L).size(), "第二个主体ID下应有一个字段数据");}
评论