From 7dd87474f182ef4987eff13b31d184ad67dae7f3 Mon Sep 17 00:00:00 2001 From: Sergey Grigoriev Date: Tue, 29 Oct 2024 10:31:18 +0100 Subject: [PATCH] chore: sonarcloud quality gate fixes (#60) --- .../extension/excel_importer/service/ImportService.java | 2 +- .../excel_importer/settings/ExcelSheetMappingSettingsTest.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/sbb/polarion/extension/excel_importer/service/ImportService.java b/src/main/java/ch/sbb/polarion/extension/excel_importer/service/ImportService.java index 2ee3b25..ce722e3 100644 --- a/src/main/java/ch/sbb/polarion/extension/excel_importer/service/ImportService.java +++ b/src/main/java/ch/sbb/polarion/extension/excel_importer/service/ImportService.java @@ -137,7 +137,7 @@ private void fillWorkItemFields(IWorkItem workItem, Map mappingR boolean ensureValidValue(String fieldId, Object value, Set fieldMetadataSet) { FieldMetadata fieldMetadata = getFieldMetadataForField(fieldMetadataSet, fieldId); if (FieldType.BOOLEAN.getType().equals(fieldMetadata.getType()) && - (!(value instanceof String) || !("true".equalsIgnoreCase((String) value) || "false".equalsIgnoreCase((String) value)))) { + (!(value instanceof String stringValue) || !("true".equalsIgnoreCase(stringValue) || "false".equalsIgnoreCase(stringValue)))) { throw new IllegalArgumentException(String.format("'%s' isn't a valid boolean value", value == null ? "" : value)); } return true; diff --git a/src/test/java/ch/sbb/polarion/extension/excel_importer/settings/ExcelSheetMappingSettingsTest.java b/src/test/java/ch/sbb/polarion/extension/excel_importer/settings/ExcelSheetMappingSettingsTest.java index 89a74c7..4c0fd54 100644 --- a/src/test/java/ch/sbb/polarion/extension/excel_importer/settings/ExcelSheetMappingSettingsTest.java +++ b/src/test/java/ch/sbb/polarion/extension/excel_importer/settings/ExcelSheetMappingSettingsTest.java @@ -48,8 +48,9 @@ void testSettingDoesNotExist() { ExcelSheetMappingSettingsModel model = excelSheetMappingSettings.defaultValues(); model.setBundleTimestamp("default"); + SettingId settingId = SettingId.fromName("Any setting name"); assertThrows(ObjectNotFoundException.class, () -> { - ExcelSheetMappingSettingsModel loadedModel = excelSheetMappingSettings.load(projectName, SettingId.fromName("Any setting name")); + excelSheetMappingSettings.load(projectName, settingId); }); } }