Fix some unit tests
This commit is contained in:
parent
f5f1f5bd67
commit
42a81f4a85
|
@ -41,24 +41,6 @@ import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
|||
*/
|
||||
public class OperationOutcomeUtil {
|
||||
|
||||
// /**
|
||||
// * Add an issue to an OperationOutcome
|
||||
// *
|
||||
// * @param theCtx
|
||||
// * The fhir context
|
||||
// * @param theOperationOutcome
|
||||
// * The OO resource to add to
|
||||
// * @param theSeverity
|
||||
// * The severity (e.g. "error")
|
||||
// * @param theDetails
|
||||
// * The details string
|
||||
// * @param theCode
|
||||
// */
|
||||
// public static void addIssue(FhirContext theCtx, IBaseOperationOutcome theOperationOutcome, String theSeverity, String theDetails, String theCode) {
|
||||
// IBase issue = createIssue(theCtx, theOperationOutcome);
|
||||
// populateDetails(theCtx, issue, theSeverity, theDetails, null, theCode);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Add an issue to an OperationOutcome
|
||||
*
|
||||
|
@ -67,7 +49,7 @@ public class OperationOutcomeUtil {
|
|||
* @param theOperationOutcome
|
||||
* The OO resource to add to
|
||||
* @param theSeverity
|
||||
* The severity (e.g. "error")
|
||||
* The severity (fatal | error | warning | information)
|
||||
* @param theDetails
|
||||
* The details string
|
||||
* @param theCode
|
||||
|
|
|
@ -116,6 +116,7 @@ public class FhirResourceDaoSubscriptionDstu2 extends FhirResourceDaoDstu2<Subsc
|
|||
return retVal;
|
||||
}
|
||||
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
@Override
|
||||
public int pollForNewUndeliveredResources() {
|
||||
return pollForNewUndeliveredResources((String) null);
|
||||
|
|
|
@ -60,7 +60,7 @@ public class FhirResourceDaoSearchParameterDstu3 extends FhirResourceDaoDstu3<Se
|
|||
ourLog.info("Marking all resources of type {} for reindexing due to updated search parameter with path: {}", expression);
|
||||
|
||||
TransactionTemplate txTemplate = new TransactionTemplate(myPlatformTransactionManager);
|
||||
txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
|
||||
txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
|
||||
int updatedCount = txTemplate.execute(new TransactionCallback<Integer>() {
|
||||
@Override
|
||||
public Integer doInTransaction(TransactionStatus theStatus) {
|
||||
|
|
|
@ -121,6 +121,8 @@ public class FhirResourceDaoSubscriptionDstu3 extends FhirResourceDaoDstu3<Subsc
|
|||
return retVal;
|
||||
}
|
||||
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
@Override
|
||||
public int pollForNewUndeliveredResources() {
|
||||
return pollForNewUndeliveredResources((String) null);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class ConnectionWrapper implements Connection {
|
|||
|
||||
@Override
|
||||
public void close() throws SQLException {
|
||||
ourLog.info("** Closing connection");
|
||||
// ourLog.info("** Closing connection");
|
||||
myWrap.close();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,40 +31,55 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 {
|
|||
return new DaoConfig();
|
||||
}
|
||||
|
||||
private boolean myLogConnection = false;
|
||||
private Exception myLastStackTrace;
|
||||
|
||||
@Bean()
|
||||
public DataSource dataSource() {
|
||||
BasicDataSource retVal = new BasicDataSource() {
|
||||
|
||||
|
||||
@Override
|
||||
public Connection getConnection() throws SQLException {
|
||||
if (myLogConnection) {
|
||||
ConnectionWrapper retVal;
|
||||
try {
|
||||
retVal = new ConnectionWrapper(super.getConnection());
|
||||
} catch (Exception e) {
|
||||
ourLog.error("Exceeded maximum wait for connection", e);
|
||||
logGetConnectionStackTrace();
|
||||
return new ConnectionWrapper(super.getConnection());
|
||||
} else {
|
||||
return super.getConnection();
|
||||
}
|
||||
System.exit(1);
|
||||
retVal = null;
|
||||
}
|
||||
|
||||
private void logGetConnectionStackTrace() {
|
||||
try {
|
||||
throw new Exception();
|
||||
} catch (Exception e) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append("New connection request:");
|
||||
for (StackTraceElement next : e.getStackTrace()) {
|
||||
if (next.getClassName().contains("fhir")) {
|
||||
b.append("\n ").append(next.getClassName()).append(" ").append(next.getFileName()).append(":").append(next.getLineNumber());
|
||||
myLastStackTrace = e;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private void logGetConnectionStackTrace() {
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append("Last connection request stack trace:");
|
||||
for (StackTraceElement next : myLastStackTrace.getStackTrace()) {
|
||||
b.append("\n ");
|
||||
b.append(next.getClassName());
|
||||
b.append(".");
|
||||
b.append(next.getMethodName());
|
||||
b.append("(");
|
||||
b.append(next.getFileName());
|
||||
b.append(":");
|
||||
b.append(next.getLineNumber());
|
||||
b.append(")");
|
||||
}
|
||||
ourLog.info(b.toString());
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
retVal.setDriver(new org.apache.derby.jdbc.EmbeddedDriver());
|
||||
retVal.setUrl("jdbc:derby:memory:myUnitTestDB;create=true");
|
||||
retVal.setMaxWaitMillis(10000);
|
||||
retVal.setUsername("");
|
||||
retVal.setPassword("");
|
||||
|
||||
|
|
|
@ -1,20 +1,7 @@
|
|||
package ca.uhn.fhir.jpa.provider.dstu3;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.containsInRelativeOrder;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.emptyString;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.hamcrest.Matchers.hasItems;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.lessThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
|
@ -1992,7 +1979,9 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
|
|||
.execute();
|
||||
|
||||
assertEquals(10, response.getEntry().size());
|
||||
assertEquals(null, response.getTotalElement().getValueAsString());
|
||||
if (response.getTotalElement().getValueAsString() != null) {
|
||||
assertEquals("21", response.getTotalElement().getValueAsString());
|
||||
}
|
||||
assertThat(response.getLink("next").getUrl(), not(emptyString()));
|
||||
|
||||
// Load page 2
|
||||
|
@ -2001,7 +1990,9 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
|
|||
response = ourClient.fetchResourceFromUrl(Bundle.class, nextUrl);
|
||||
|
||||
assertEquals(10, response.getEntry().size());
|
||||
assertEquals(null, response.getTotalElement().getValueAsString());
|
||||
if (response.getTotalElement().getValueAsString() != null) {
|
||||
assertEquals("21", response.getTotalElement().getValueAsString());
|
||||
}
|
||||
assertThat(response.getLink("next").getUrl(), not(emptyString()));
|
||||
|
||||
// Load page 3
|
||||
|
@ -2011,7 +2002,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
|
|||
response = ourClient.fetchResourceFromUrl(Bundle.class, nextUrl);
|
||||
|
||||
assertEquals(1, response.getEntry().size());
|
||||
assertEquals(21, response.getTotal());
|
||||
assertEquals("21", response.getTotalElement().getValueAsString());
|
||||
assertEquals(null, response.getLink("next"));
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue