Make busywait more clear
This commit is contained in:
parent
7d1d5a102c
commit
e819b83a94
|
@ -212,7 +212,7 @@ public class SystemProviderDstu2Test extends BaseJpaDstu2Test {
|
||||||
myObservationDao.update(obs, mySrd);
|
myObservationDao.update(obs, mySrd);
|
||||||
|
|
||||||
// Try to wait for the indexing to complete
|
// Try to wait for the indexing to complete
|
||||||
waitToParamsToIndex(ptId);
|
waitForSize(2, ()-> fetchSuggestionCount(ptId));
|
||||||
|
|
||||||
HttpGet get = new HttpGet(ourServerBase + "/$suggest-keywords?context=Patient/" + ptId.getIdPart() + "/$everything&searchParam=_content&text=zxc&_pretty=true&_format=xml");
|
HttpGet get = new HttpGet(ourServerBase + "/$suggest-keywords?context=Patient/" + ptId.getIdPart() + "/$everything&searchParam=_content&text=zxc&_pretty=true&_format=xml");
|
||||||
try (CloseableHttpResponse http = ourHttpClient.execute(get)) {
|
try (CloseableHttpResponse http = ourHttpClient.execute(get)) {
|
||||||
|
@ -230,16 +230,14 @@ public class SystemProviderDstu2Test extends BaseJpaDstu2Test {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void waitToParamsToIndex(IIdType thePtId) throws Exception {
|
private Number fetchSuggestionCount(IIdType thePtId) throws IOException {
|
||||||
waitForSize(2, ()->{
|
HttpGet get = new HttpGet(ourServerBase + "/$suggest-keywords?context=Patient/" + thePtId.getIdPart() + "/$everything&searchParam=_content&text=zxc&_pretty=true&_format=xml");
|
||||||
HttpGet get = new HttpGet(ourServerBase + "/$suggest-keywords?context=Patient/" + thePtId.getIdPart() + "/$everything&searchParam=_content&text=zxc&_pretty=true&_format=xml");
|
try (CloseableHttpResponse http = ourHttpClient.execute(get)) {
|
||||||
try (CloseableHttpResponse http = ourHttpClient.execute(get)) {
|
assertEquals(200, http.getStatusLine().getStatusCode());
|
||||||
assertEquals(200, http.getStatusLine().getStatusCode());
|
String output = IOUtils.toString(http.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
String output = IOUtils.toString(http.getEntity().getContent(), StandardCharsets.UTF_8);
|
Parameters parameters = ourCtx.newXmlParser().parseResource(Parameters.class, output);
|
||||||
Parameters parameters = ourCtx.newXmlParser().parseResource(Parameters.class, output);
|
return parameters.getParameter().size();
|
||||||
return parameters.getParameter().size();
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -280,7 +280,7 @@ public class SystemProviderR4Test extends BaseJpaR4Test {
|
||||||
myObservationDao.update(obs, mySrd);
|
myObservationDao.update(obs, mySrd);
|
||||||
|
|
||||||
// Try to wait for the indexing to complete
|
// Try to wait for the indexing to complete
|
||||||
waitForParamsToIndex(ptId);
|
waitForSize(2, ()-> fetchSuggestionCount(ptId));
|
||||||
|
|
||||||
HttpGet get = new HttpGet(ourServerBase + "/$suggest-keywords?context=Patient/" + ptId.getIdPart() + "/$everything&searchParam=_content&text=zxc&_pretty=true&_format=xml");
|
HttpGet get = new HttpGet(ourServerBase + "/$suggest-keywords?context=Patient/" + ptId.getIdPart() + "/$everything&searchParam=_content&text=zxc&_pretty=true&_format=xml");
|
||||||
CloseableHttpResponse http = ourHttpClient.execute(get);
|
CloseableHttpResponse http = ourHttpClient.execute(get);
|
||||||
|
@ -301,16 +301,14 @@ public class SystemProviderR4Test extends BaseJpaR4Test {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void waitForParamsToIndex(IIdType thePtId) throws Exception {
|
private Number fetchSuggestionCount(IIdType thePtId) throws IOException {
|
||||||
waitForSize(2, ()->{
|
HttpGet get = new HttpGet(ourServerBase + "/$suggest-keywords?context=Patient/" + thePtId.getIdPart() + "/$everything&searchParam=_content&text=zxc&_pretty=true&_format=xml");
|
||||||
HttpGet get = new HttpGet(ourServerBase + "/$suggest-keywords?context=Patient/" + thePtId.getIdPart() + "/$everything&searchParam=_content&text=zxc&_pretty=true&_format=xml");
|
try (CloseableHttpResponse http = ourHttpClient.execute(get)) {
|
||||||
try (CloseableHttpResponse http = ourHttpClient.execute(get)) {
|
assertEquals(200, http.getStatusLine().getStatusCode());
|
||||||
assertEquals(200, http.getStatusLine().getStatusCode());
|
String output = IOUtils.toString(http.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
String output = IOUtils.toString(http.getEntity().getContent(), StandardCharsets.UTF_8);
|
Parameters parameters = ourCtx.newXmlParser().parseResource(Parameters.class, output);
|
||||||
Parameters parameters = ourCtx.newXmlParser().parseResource(Parameters.class, output);
|
return parameters.getParameter().size();
|
||||||
return parameters.getParameter().size();
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue