diff --git a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceService.java b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceService.java index fc61cbbbb0..f7ea4ad459 100644 --- a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceService.java +++ b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceService.java @@ -368,9 +368,9 @@ public Mono> createContact(Message message) { contactId -> contactRepository .findById(contactId) - .flatMap(submissionContact -> + .flatMapMany(submissionContact -> legacyR2dbcEntityTemplate - .selectOne( + .select( Query .query( Criteria @@ -382,13 +382,14 @@ public Mono> createContact(Message message) { ) ) .and("CONTACT_NAME").is( - String.format("%s %s", submissionContact.getFirstName(), - submissionContact.getLastName()) + String.format("%s %s", submissionContact.getFirstName().toUpperCase(), + submissionContact.getLastName().toUpperCase()) ) ), ForestClientContactEntity.class ) ) + .next() .doOnNext(forestClientContact -> log.info( "Forest client contact {} {} already exists for submission {}", diff --git a/processor/src/test/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceServiceTest.java b/processor/src/test/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceServiceTest.java index 0df79fda1c..59c0723128 100644 --- a/processor/src/test/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceServiceTest.java +++ b/processor/src/test/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceServiceTest.java @@ -227,8 +227,8 @@ void shouldCreateContacts(boolean contactExisted) { when(insert.using(any())) .thenReturn(Mono.just(contactEntity)); - when(legacyR2dbcEntityTemplate.selectOne(any(), any())) - .thenReturn(contactExisted ? Mono.just(contactEntity) :Mono.empty()); + when(legacyR2dbcEntityTemplate.select(any(), any())) + .thenReturn(contactExisted ? Flux.just(contactEntity) : Flux.empty()); when(legacyR2dbcEntityTemplate.getDatabaseClient()) .thenReturn(dbCLient); when(dbCLient.sql(any(String.class)))