### Question:
PriceService { public Collection<PriceSource> getSources(BozhuPrice bozhuPrice) { try (SqlSession session = sessionFactory.openSession()) { PriceMapper mapper = session.getMapper(PriceMapper.class); Map<Integer, PriceSource> sources = new HashMap<>(); for (Price price : mapper.getPricesByUsername(bozhuPrice.getUsername())) { PriceSource source = sources.get(price.getSourceId()); if (source == null) { source = mapper.getSource(bozhuPrice.getUsername(), price.getSourceId()); sources.put(source.getId(), source); } source.addPrice(price); } session.commit(); return new ArrayList<>(sources.values()); } } PriceService(); Price addPrice(BozhuPrice bozhuPrice, int sourceId, Price price); PriceSource addSource(BozhuPrice bozhuPrice, PriceSource source); void deletePrice(BozhuPrice bozhuPrice, int sourceId, int typeId); void deleteSource(BozhuPrice bozhuPrice, int sourceId); PriceSource getDefaultPriceSource(BozhuPrice bozhuPrice); int getSourceCount(); int getSourceCount(String keyword); Collection<PriceSource> getSources(BozhuPrice bozhuPrice); Collection<PriceSource> getSources(int offset, int limit); Collection<PriceSource> getSources(String keyword, int offset, int limit); PriceSource getSource(BozhuPrice bozhuPrice, int sourceId); Collection<PriceType> getTypes(); void setDefaultPriceSource(BozhuPrice bozhuPrice, Integer sourceId); PriceSource getSourceByQq(String qq); PriceSource getSourceByTelephone(String telephone);  }### Answer:
@Test public void testGetPrices() throws Exception { Collection<PriceSource> prices = priceService.getSources(bozhuPrice); List<PriceSource> expectedList = new ArrayList<PriceSource>(); expectedList.add(new PriceSource(1, "博主报价", "", "18888888888", 1).addPrice(new Price(1772605247, 1, 1, 5)).addPrice(new Price(1772605247, 1, 2, 5)).addPrice(new Price(1772605247, 1, 3, 5)).addPrice(new Price(1772605247, 1, 4, 5))); expectedList.add(new PriceSource(2, "分析价", "123456", "", 0).addPrice(new Price(1772605247, 2, 1, 5)).addPrice(new Price(1772605247, 2, 3, 5))); for (PriceSource expected : expectedList) { assertTrue(prices.contains(expected)); } }