Fix sonar findings (#2705)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-09-29 13:19:08 +03:00
committed by GitHub
parent a2929757d8
commit ebfaa1d51e
3 changed files with 15 additions and 7 deletions

View File

@@ -375,26 +375,27 @@ class RsqlTargetFieldTest extends AbstractJpaIntegrationTest {
*/
@Test
void rsqlValidTargetFields() {
QLSupport.getInstance().validate(
final QLSupport qlSupport = QLSupport.getInstance();
qlSupport.validate(
"ID == '0123' and NAME == abcd and DESCRIPTION == absd and CREATEDAT =lt= 0123 and LASTMODIFIEDAT =gt= 0123" +
" and CONTROLLERID == 0123 and UPDATESTATUS == PENDING and IPADDRESS == 0123 and LASTCONTROLLERREQUESTAT == 0123" +
" and tag == beta",
TargetFields.class, JpaTarget.class);
QLSupport.getInstance().validate(
qlSupport.validate(
"ASSIGNEDDS.name == abcd and ASSIGNEDDS.version == 0123 and INSTALLEDDS.name == abcd and INSTALLEDDS.version == 0123",
TargetFields.class, JpaTarget.class);
QLSupport.getInstance().validate(
qlSupport.validate(
"ATTRIBUTE.subkey1 == test and ATTRIBUTE.subkey2 == test and METADATA.metakey1 == abcd and METADATA.metavalue2 == asdfg",
TargetFields.class, JpaTarget.class);
QLSupport.getInstance().validate(
qlSupport.validate(
"CREATEDAT =lt= ${NOW_TS} and LASTMODIFIEDAT =ge= ${OVERDUE_TS}",
TargetFields.class, JpaTarget.class);
QLSupport.getInstance().validate(
qlSupport.validate(
"ATTRIBUTE.test.dot == test and ATTRIBUTE.subkey2 == test and METADATA.test.dot == abcd and METADATA.metavalue2 == asdfg",
TargetFields.class, JpaTarget.class);
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
.isThrownBy(() -> QLSupport.getInstance().validate("wrongfield == abcd", TargetFields.class, JpaTarget.class));
.isThrownBy(() -> qlSupport.validate("wrongfield == abcd", TargetFields.class, JpaTarget.class));
}
/**
@@ -448,7 +449,8 @@ class RsqlTargetFieldTest extends AbstractJpaIntegrationTest {
}
private void assertRSQLQueryThrowsException(final String rsql) {
final QLSupport qlSupport = QLSupport.getInstance();
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
.isThrownBy(() -> QLSupport.getInstance().validate(rsql, TargetFields.class, JpaTarget.class));
.isThrownBy(() -> qlSupport.validate(rsql, TargetFields.class, JpaTarget.class));
}
}