Source:
<code>public void shouldAggregateNumberAndValueOfPaymentsForGatewayAccount() { DatabaseFixtures.TestAccount gatewayAccount = DatabaseFixtures .withDatabaseTestHelper(databaseTestHelper) .aTestAccount() .withAccountId(173L) .withType(GatewayAccountEntity.Type.LIVE) .insert(); DatabaseFixtures.TestAccount anotherGatewayAccount = DatabaseFixtures .withDatabaseTestHelper(databaseTestHelper) .aTestAccount() .withAccountId(174L) .withType(GatewayAccountEntity.Type.LIVE) .insert(); insertCharge(gatewayAccount, 10L, ZonedDateTime.now()); insertCharge(gatewayAccount, 2L, ZonedDateTime.now()); insertCharge(anotherGatewayAccount, 6L, ZonedDateTime.now()); insertCharge(anotherGatewayAccount, 3L, ZonedDateTime.now()); insertCharge(anotherGatewayAccount, 6L, ZonedDateTime.now()); <START> Object[] gatewayAccountPerformanceReportEntities = performanceReportDao.aggregateNumberAndValueOfPaymentsByGatewayAccount().toArray(); <END> assertThat(gatewayAccountPerformanceReportEntities.length, is(2)); GatewayAccountPerformanceReportEntity first = (GatewayAccountPerformanceReportEntity) gatewayAccountPerformanceReportEntities[0]; GatewayAccountPerformanceReportEntity second = (GatewayAccountPerformanceReportEntity) gatewayAccountPerformanceReportEntities[1]; assertThat(first.getAverageAmount(), is(closeTo(new BigDecimal("6"), ZERO))); assertThat(first.getTotalAmount(), is(closeTo(new BigDecimal("12"), ZERO))); assertThat(first.getTotalVolume(), is(2L)); assertThat(second.getAverageAmount(), is(closeTo(new BigDecimal("5"), ZERO))); assertThat(second.getTotalAmount(), is(closeTo(new BigDecimal("15"), ZERO))); assertThat(second.getTotalVolume(), is(3L)); }</code><technical_language>This argument change return types in PerformanceReportDao. converting array, recommend .collect( )ing a List: Lists generally preferable avoid casting later</technical_language>

Target:
public void shouldAggregateNumberAndValueOfPaymentsForGatewayAccount() { DatabaseFixtures.TestAccount gatewayAccount = DatabaseFixtures .withDatabaseTestHelper(databaseTestHelper) .aTestAccount() .withAccountId(173L) .withType(GatewayAccountEntity.Type.LIVE) .insert(); DatabaseFixtures.TestAccount anotherGatewayAccount = DatabaseFixtures .withDatabaseTestHelper(databaseTestHelper) .aTestAccount() .withAccountId(174L) .withType(GatewayAccountEntity.Type.LIVE) .insert(); insertCharge(gatewayAccount, 10L, ZonedDateTime.now()); insertCharge(gatewayAccount, 2L, ZonedDateTime.now()); insertCharge(anotherGatewayAccount, 6L, ZonedDateTime.now()); insertCharge(anotherGatewayAccount, 3L, ZonedDateTime.now()); insertCharge(anotherGatewayAccount, 6L, ZonedDateTime.now()); List<GatewayAccountPerformanceReportEntity> gatewayAccountPerformanceReportEntities = performanceReportDao.aggregateNumberAndValueOfPaymentsByGatewayAccount().collect(Collectors.toList()); assertThat(gatewayAccountPerformanceReportEntities.size(), is(2)); GatewayAccountPerformanceReportEntity first = gatewayAccountPerformanceReportEntities.get(0); GatewayAccountPerformanceReportEntity second = gatewayAccountPerformanceReportEntities.get(1); assertThat(first.getAverageAmount(), is(closeTo(new BigDecimal("6"), ZERO))); assertThat(first.getTotalAmount(), is(closeTo(new BigDecimal("12"), ZERO))); assertThat(first.getTotalVolume(), is(2L)); assertThat(second.getAverageAmount(), is(closeTo(new BigDecimal("5"), ZERO))); assertThat(second.getTotalAmount(), is(closeTo(new BigDecimal("15"), ZERO))); assertThat(second.getTotalVolume(), is(3L)); }