Skip to content

Commit 3868443

Browse files
committed
Trying to fixing tests
1 parent 2931d85 commit 3868443

File tree

6 files changed

+13
-20
lines changed

6 files changed

+13
-20
lines changed

hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/topic/SubscriptionTopicPayloadBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ private void addResources(
241241
BundleBuilder theBundleBuilder) {
242242

243243
org.hl7.fhir.r5.model.Subscription.SubscriptionPayloadContent content =
244-
ObjectUtils.defaultIfNull(theCanonicalSubscription.getContent(), FULLRESOURCE);
244+
ObjectUtils.getIfNull(theCanonicalSubscription.getContent(), FULLRESOURCE);
245245

246246
switch (content) {
247247
case IDONLY:

hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4IndexStorageOptimizedTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ private List<? extends BaseResourceIndexedSearchParam> getAndValidateIndexedSear
300300
JpaRepository<? extends BaseResourceIndexedSearchParam, Long> theIndexedSpRepository,
301301
IIdType theId, String theSearchParam, String theResourceType) {
302302
long hashIdentity = BaseResourceIndexedSearchParam.calculateHashIdentity(new PartitionSettings(),
303-
RequestPartitionId.defaultPartition(), theResourceType, theSearchParam);
303+
RequestPartitionId.allPartitions(), theResourceType, theSearchParam);
304304

305305
await().atMost(30, TimeUnit.SECONDS).untilAsserted(() -> {
306306
IndexedSearchParamIdentity spIdentity = runInTransaction(() ->

hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/PartitionedStrictTransactionR4Test.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public void before() throws Exception {
4747

4848
@Override
4949
public void after() {
50-
super.after();
5150
myTransactionService.setTransactionPropagationWhenChangingPartitions(HapiTransactionService.DEFAULT_TRANSACTION_PROPAGATION_WHEN_CHANGING_PARTITIONS);
52-
myInterceptorRegistry.unregisterInterceptorsIf(t -> t instanceof MyPartitionSelectorInterceptor);
51+
myInterceptorRegistry.unregisterInterceptorsIf(MyPartitionSelectorInterceptor.class::isInstance);
52+
super.after();
5353
}
5454

5555
/**
@@ -89,6 +89,7 @@ public void testSinglePartitionCreate(String theBundleType, int theExpectedCommi
8989
IdType id = new IdType(output.getEntry().get(0).getResponse().getLocation());
9090
Patient actualPatient = myPatientDao.read(id, mySrd);
9191
RequestPartitionId actualPartitionId = (RequestPartitionId) actualPatient.getUserData(Constants.RESOURCE_PARTITION_ID);
92+
assertThat(actualPartitionId).isNotNull();
9293
assertThat(actualPartitionId.getPartitionIds()).containsExactly(myPartitionId);
9394
}
9495

hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/delete/ThreadSafeResourceDeleterSvcTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import ca.uhn.test.util.LogbackTestExtension;
1717
import ca.uhn.test.util.LogbackTestExtensionAssert;
1818
import jakarta.annotation.Nullable;
19-
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
2019
import org.hl7.fhir.instance.model.api.IBaseResource;
2120
import org.hl7.fhir.instance.model.api.IIdType;
2221
import org.hl7.fhir.r4.model.HumanName;
@@ -42,7 +41,7 @@ public class ThreadSafeResourceDeleterSvcTest extends BaseJpaR4Test {
4241
private ThreadSafeResourceDeleterSvc myThreadSafeResourceDeleterSvc;
4342

4443
@RegisterExtension
45-
final LogbackTestExtension mySqlExceptionHelperLog = new LogbackTestExtension(SqlExceptionHelper.class);
44+
final LogbackTestExtension mySqlExceptionHelperLog = new LogbackTestExtension("org.hibernate.orm.jdbc.error");
4645

4746
@Autowired
4847
IInterceptorBroadcaster myIdInterceptorBroadcaster;
@@ -57,7 +56,7 @@ public class ThreadSafeResourceDeleterSvcTest extends BaseJpaR4Test {
5756

5857

5958
@BeforeEach
60-
void beforeEach() {
59+
void beforeEach() throws Exception {
6160
myThreadSafeResourceDeleterSvc = new ThreadSafeResourceDeleterSvc(myDaoRegistry, myIdInterceptorBroadcaster, myHapiTransactionService);
6261
}
6362

@@ -176,7 +175,7 @@ void delete_update_retryTest() throws ExecutionException, InterruptedException {
176175
// Unpause and succeed in deleting the second patient because we will get the correct version now
177176
// Red Green: If you delete the updatePatient above, it will timeout here
178177
phaser.arriveAndAwaitSharedEndOf(UpdateSteps.DEL_BEFORE_SECOND_PATIENT_DELETE_SUCCEED);
179-
LogbackTestExtensionAssert.assertThat(mySqlExceptionHelperLog).hasErrorMessage("Unique index or primary key violation");
178+
LogbackTestExtensionAssert.assertThat(mySqlExceptionHelperLog).hasWarnMessage("Unique index or primary key violation");
180179

181180
phaser.assertInPhase(UpdateSteps.BOTH_COMPLETE);
182181

hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/BaseTransactionProcessor.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,7 @@ public <BUNDLE extends IBaseBundle> BUNDLE transaction(
258258
}
259259

260260
List<IBase> entries = myVersionAdapter.getEntries(response);
261-
for (int i = 0; i < entries.size(); i++) {
262-
if (ElementUtil.isEmpty(entries.get(i))) {
263-
entries.remove(i);
264-
i--;
265-
}
266-
}
261+
entries.removeIf(ElementUtil::isEmpty);
267262

268263
return (BUNDLE) response;
269264
}
@@ -344,7 +339,7 @@ private void handleTransactionCreateOrUpdateOutcome(
344339
theRes = theIdToPersistedOutcome.get(newId).getResource();
345340
}
346341

347-
if (theOutcome.getCreated()) {
342+
if (Boolean.TRUE.equals(theOutcome.getCreated())) {
348343
myVersionAdapter.setResponseStatus(theNewEntry, toStatusString(Constants.STATUS_HTTP_201_CREATED));
349344
} else {
350345
myVersionAdapter.setResponseStatus(theNewEntry, toStatusString(Constants.STATUS_HTTP_200_OK));
@@ -766,9 +761,7 @@ private void setRequestPartitionHeaderIfEntryHasTheExtension(IBase theReqEntry,
766761
Optional<IBaseExtension<?, ?>> partitionIdsExtensionOptional =
767762
myVersionAdapter.getEntryRequestExtensionByUrl(theReqEntry, EXTENSION_TRANSACTION_ENTRY_PARTITION_IDS);
768763
if (partitionIdsExtensionOptional.isPresent()
769-
&& partitionIdsExtensionOptional.get().getValue() instanceof IPrimitiveType<?>) {
770-
IPrimitiveType<?> valueAsPrimitiveType =
771-
(IPrimitiveType<?>) partitionIdsExtensionOptional.get().getValue();
764+
&& partitionIdsExtensionOptional.get().getValue() instanceof IPrimitiveType<?> valueAsPrimitiveType) {
772765
String value = valueAsPrimitiveType.getValueAsString();
773766
theRequestDetails.setHeaders(Constants.HEADER_X_REQUEST_PARTITION_IDS, List.of(value));
774767
}

hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogbackTestExtension.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void setLoggerLevel(Level theLevel) {
140140
/**
141141
* @deprecated Use {@link #setLoggerLevel(Level)} instead
142142
*/
143-
@Deprecated
143+
@Deprecated(forRemoval = true)
144144
public void setUp(Level theLevel) {
145145
setLoggerLevel(theLevel);
146146
}
@@ -149,7 +149,7 @@ public void setUp(Level theLevel) {
149149
* @deprecated This class should be registered as a junit5 extension, and will be set
150150
* up automatically.
151151
*/
152-
@Deprecated
152+
@Deprecated(forRemoval = true)
153153
public void setUp() {
154154
// nothing
155155
}

0 commit comments

Comments
 (0)