From 051074d0bcdf32ea8b60e385e74d7de11f3c77bb Mon Sep 17 00:00:00 2001 From: James Agnew Date: Fri, 4 Jan 2019 13:05:39 -0500 Subject: [PATCH] Work on tests --- .../ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java | 10 +++++----- .../ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java index c4dc1af49a9..dce0a201659 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java @@ -59,6 +59,8 @@ import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.support.TransactionTemplate; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import javax.annotation.PostConstruct; import javax.persistence.NoResultException; import javax.persistence.TypedQuery; @@ -378,7 +380,7 @@ public abstract class BaseHapiFhirResourceDao extends B } else if (match.size() == 1) { Long pid = match.iterator().next(); entity = myEntityManager.find(ResourceTable.class, pid); - return toMethodOutcome(entity, theResource).setCreated(false); + return toMethodOutcome(entity, null).setCreated(false); } } @@ -1139,11 +1141,9 @@ public abstract class BaseHapiFhirResourceDao extends B return retVal; } - private DaoMethodOutcome toMethodOutcome(final ResourceTable theEntity, IBaseResource theResource) { + private DaoMethodOutcome toMethodOutcome(@Nonnull final ResourceTable theEntity, @Nullable IBaseResource theResource) { DaoMethodOutcome outcome = new DaoMethodOutcome(); - // FIXME: can theResource ever be null? why? - IIdType id = null; if (theResource != null) { id = theResource.getIdElement(); @@ -1294,7 +1294,7 @@ public abstract class BaseHapiFhirResourceDao extends B * directly. So we just bail now. */ if (!thePerformIndexing) { - DaoMethodOutcome outcome = toMethodOutcome(entity, theResource).setCreated(false); + DaoMethodOutcome outcome = toMethodOutcome(entity, null).setCreated(false); outcome.setPreviousResource(oldResource); return outcome; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java index 2abc6f11caf..f659f508577 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java @@ -2573,8 +2573,8 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { assertThat(nextEntry.getResponse().getLocation(), (containsString("test"))); assertEquals(id.toVersionless(), new IdType(nextEntry.getResponse().getLocation()).toVersionless()); - assertNotEquals(id, new IdType(nextEntry.getResponse().getLocation())); assertThat(nextEntry.getResponse().getLocation(), endsWith("/_history/2")); + assertNotEquals(id, new IdType(nextEntry.getResponse().getLocation())); nextEntry = resp.getEntry().get(1); assertEquals(Constants.STATUS_HTTP_201_CREATED + " Created", nextEntry.getResponse().getStatus());