From 6191b74492d068ec7e637ba7822e485105ba2f97 Mon Sep 17 00:00:00 2001 From: llorentelemmc Date: Mon, 2 Sep 2024 16:31:53 +0200 Subject: [PATCH] refactor: fixing tests --- .../business/domain/commons/CommonFilterService.java | 9 ++++++++- .../control/DeploymentNotificationServiceTest.java | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/AMW_business/src/main/java/ch/puzzle/itc/mobiliar/business/domain/commons/CommonFilterService.java b/AMW_business/src/main/java/ch/puzzle/itc/mobiliar/business/domain/commons/CommonFilterService.java index 7d784f131..2a9508eaa 100644 --- a/AMW_business/src/main/java/ch/puzzle/itc/mobiliar/business/domain/commons/CommonFilterService.java +++ b/AMW_business/src/main/java/ch/puzzle/itc/mobiliar/business/domain/commons/CommonFilterService.java @@ -78,7 +78,7 @@ public Query addFilterAndCreateQuery(StringBuilder stringQuery, List 0) { - appendWhereIfNotAlreadyExists(stringQuery); + appendWhereOrAndStatementsToQuery(stringQuery); stringQuery.append('(').append(filterQuery).append(')'); } } @@ -173,6 +173,13 @@ private String extractJoiningtableForFilter(List filters) { return (uniqueJoiningString.length() == 0) ? "" : (SPACE_STRING + uniqueJoiningString); } + private void appendWhereOrAndStatementsToQuery(StringBuilder stringQuery) { + appendWhereIfNotAlreadyExists(stringQuery); + if (stringQuery.toString().endsWith(") ")) { + stringQuery.append("and "); + } + } + private void appendWhereIfNotAlreadyExists(StringBuilder stringQuery) { if (!stringQuery.toString().contains(WHERE)) { stringQuery.append(WHERE + SPACE_STRING); diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/deploy/control/DeploymentNotificationServiceTest.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/deploy/control/DeploymentNotificationServiceTest.java index e0d1b8ce0..9aa6e4df3 100644 --- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/deploy/control/DeploymentNotificationServiceTest.java +++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/deploy/control/DeploymentNotificationServiceTest.java @@ -181,7 +181,7 @@ public void createAndSendMailForDeplyoments_oneDeployment_noAddress_sending_nok_ } @Test - public void createAndSendMailForDeplyoments_oneDeployment_noAddress_sending_Exception() throws MessagingException { + public void createAndSendMailForDeployments_oneDeployment_noAddress_sending_Exception() throws MessagingException { // given ArrayList deployments = new ArrayList(); @@ -206,7 +206,7 @@ public void createAndSendMailForDeplyoments_oneDeployment_noAddress_sending_Exce @Test - public void createAndSendMailForDeplyoments_oneDeployment_noAddress_sending_Recipients() throws MessagingException { + public void createAndSendMailForDeployments_oneDeployment_noAddress_sending_Recipients() throws MessagingException { // given ArrayList deployments = new ArrayList();