Я получаю ошибку:
java .lang.IndexOutOfBoundsException: Index: 0, Size: 0
в 5-й строке. Потому что ответ имеет только пустой массив. Массив отлично заполняется в режиме отладки. Отладка не легка. Не уверен, если это имеет значение. Спасибо за ваше время.
Пожалуйста, найдите файл теста и свойств Java ниже.
@Test
public void testApplicationLargeDataEndPointIR() throws Exception {
String ResourceUrl = "/mdh/v1/source/totem/asset_class/interest%20rates/service/basis/valuation_date/20191231?start=1&size=1";
String values = "205,2019-12-31,Interest Rates,Basis,ME,56,40,Swap,AUD,BBSW,Onshore,SYD 16:30,AUD BBSW/LIBOR,Basis Point Spread,ACT365,2020-01-02,2028-01-04,0,96.0,21.8681872,*,21.96231177,0.08552537,7,0.02779477,-0.51077285,-0.5648386,21.91447463,22.0,-4,1,1,0,0,3,0,1,1,";
ResponseEntity<String> response = testRestTemplate.getForEntity(ResourceUrl, String.class);
@SuppressWarnings("unchecked")
List<Map<String, String>> list = objectMapper.readValue(response.getBody(), List.class);
Iterator<Map.Entry<String, String>> it = list.get(0).entrySet().iterator();
String expected_values[] = values.split(",", -1);
int i = 0;
while (it.hasNext()) {
Map.Entry<String, String> entry = it.next();
if (expected_values[i].isEmpty())
assertEquals(String.valueOf("null"), String.valueOf(entry.getValue()));
else if (isValidInteger(expected_values[i].trim(), 10)) {
assertEquals(Integer.valueOf(expected_values[i]), Integer.valueOf(String.valueOf(entry.getValue())));
} else if (isValidDouble(expected_values[i].trim())) {
assertEquals(Double.valueOf(expected_values[i]), Double.valueOf(String.valueOf(entry.getValue())));
} else if (isValidDate(expected_values[i].trim())
&& (expected_values[i].contentEquals(String.valueOf(entry.getValue())) == false)) {
Long ts = Long.valueOf(String.valueOf(entry.getValue()));
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dt = formatter.format(ts);
assertEquals(expected_values[i], dt);
} else {
assertEquals(expected_values[i], String.valueOf(entry.getValue()));
}
i++;
}
assertThat(response.getStatusCode(), equalTo(HttpStatus.OK));
HttpHeaders httpHeaders = testRestTemplate.headForHeaders(ResourceUrl);
assertTrue(httpHeaders.getContentType().includes(MediaType.APPLICATION_JSON));
}
application-test.properties:
spring.datasource.url=jdbc:h2:mem:testdb;MODE=MYSQL;
spring.datasource.username=sa
spring.datasource.password=password
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.platform=h2
mdh.totem.tableName=MOCK_TF_MDH_TOTEM_RESULT
spring.datasource.hikari.connection-timeout=600000
spring.datasource.hikari.minimum-idle=80
spring.datasource.hikari.maximum-pool-size=80
spring.datasource.hikari.idle-timeout=60000
spring.datasource.hikari.max-lifetime=6000
spring.datasource.hikari.auto-commit=true
spring.datasource.hikari.maxLifetime=6000000
#mdh.totem.marketData.where[1] = WHERE upper(${mdh.totem.assetClass.column}) = upper('%1$s') AND upper(${mdh.totem.service.column}) = upper('%2$s') AND ${mdh.totem.valuationDate.column} = DATE '%3$s'
#mdh.totem.marketData.where[2] = WHERE upper(${mdh.totem.assetClass.column}) = upper('%1$s') AND upper(${mdh.totem.service.column}) = upper('%2$s') AND ${mdh.totem.valuationDate.column} = DATE '%3$s' AND upper(${mdh.totem.valuationDate.subArea.column}) = upper('%4$s') AND upper(${mdh.totem.valuationDate.serviceFrequency.column}) = upper('%5$s')
#mdh.totem.marketData.sql[0]= SELECT ${mdh-totem-result.columnList.commodities} FROM ${mdh.totem.tableName} WHERE upper(${mdh.totem.assetClass.column}) = upper('%1$s') AND upper(${mdh.totem.service.column}) = upper('%2$s') AND ${mdh.totem.valuationDate.column} = '%3$s';
#mdh.totem.marketData.sql[0]= SELECT ${mdh-totem-result.columnList.commodities} FROM MOCK_TF_MDH_TOTEM_RESULT WHERE upper(${mdh.totem.assetClass.column}) = upper('%1$s') AND upper(${mdh.totem.service.column}) = upper('%2$s') AND ${mdh.totem.valuationDate.column} = PARSEDATETIME('%3$s','dd-MMMM-yy');
mdh.totem.marketData.valuationDate.Condn = ${mdh.totem.valuationDate.column} = PARSEDATETIME('%3$s','dd-MMMM-yy')
mdh-totem-result.columnList.interestRates=ClientID,ValuationDate,AssetClass,ServiceName,ServiceFrequency,SubArea,SchemaVersion,InstrumentType,Currency,Underlying,OnshoreOffshore,PricingTime,CollateralConvention,PriceConvention,PaymentDCC,StartDate,FinalMaturity,ForwardTerm,Term,ClientPrice,KnockoutPrice,ConsensusPrice,RangePrice,NumberAcceptedPrice,StandardDeviationPrice,SkewnessPrice,KurtosisPrice,Percentile10Price,Percentile90Price,ClientDistributionBucket,DistributionMinus4,DistributionMinus3,DistributionMinus2,DistributionMinus1,Distribution0,DistributionPlus1,DistributionPlus2,DistributionPlus3,DistributionPlus4
#spring.jpa.hibernate.ddl-auto=none
#disable spring.jpa.hibernate.ddl-auto if you use schema.sql.
#spring.jpa.database-platform=org.hibernate.dialect.H2Dialect