From aa292021043b140f482e6db7849a6a7ade4a69ef Mon Sep 17 00:00:00 2001 From: salander85 Date: Mon, 23 Oct 2023 11:39:11 +0200 Subject: [PATCH] Add check for "null" - string for productTypeReference key attribute --- .../sync/producttypes/helpers/ProductTypeBatchValidator.java | 2 +- .../producttypes/helpers/ProductTypeBatchValidatorTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/commercetools/sync/producttypes/helpers/ProductTypeBatchValidator.java b/src/main/java/com/commercetools/sync/producttypes/helpers/ProductTypeBatchValidator.java index d4895a7cd0..231d40d89a 100644 --- a/src/main/java/com/commercetools/sync/producttypes/helpers/ProductTypeBatchValidator.java +++ b/src/main/java/com/commercetools/sync/producttypes/helpers/ProductTypeBatchValidator.java @@ -167,7 +167,7 @@ private static String getProductTypeKey(@Nonnull final AttributeNestedType neste throws InvalidReferenceException { final String key = nestedAttributeType.getTypeReference().getId(); - if (isBlank(key)) { + if (isBlank(key) || "null".equals(key)) { throw new InvalidReferenceException(BLANK_ID_VALUE_ON_REFERENCE); } return key; diff --git a/src/test/java/com/commercetools/sync/producttypes/helpers/ProductTypeBatchValidatorTest.java b/src/test/java/com/commercetools/sync/producttypes/helpers/ProductTypeBatchValidatorTest.java index f091736bdc..dc809c313b 100644 --- a/src/test/java/com/commercetools/sync/producttypes/helpers/ProductTypeBatchValidatorTest.java +++ b/src/test/java/com/commercetools/sync/producttypes/helpers/ProductTypeBatchValidatorTest.java @@ -264,7 +264,7 @@ void validateAndCollectReferencedKeys_WithEmptyDraft_ShouldHaveEmptyResult() { attributeTypeBuilder .nestedBuilder() .typeReference( - productTypeReferenceBuilder -> productTypeReferenceBuilder.id(""))) + productTypeReferenceBuilder -> productTypeReferenceBuilder.id("null"))) .name("invalidNested") .label(ofEnglish("koko")) .isRequired(true) @@ -282,7 +282,7 @@ void validateAndCollectReferencedKeys_WithEmptyDraft_ShouldHaveEmptyResult() { .nestedBuilder() .typeReference( productTypeReferenceBuilder -> - productTypeReferenceBuilder.id("")))) + productTypeReferenceBuilder.id("null")))) .name("setOfInvalidNested") .label(ofEnglish("koko")) .isRequired(true)