From 05aa75965a8ede21b63012cd1c72114cb806b3b4 Mon Sep 17 00:00:00 2001 From: Hesham Massoud Date: Fri, 30 Nov 2018 16:46:46 +0100 Subject: [PATCH] #325: Fix error messages and assertions. --- .../externalsource/producttypes/ProductTypeSyncIT.java | 8 ++++---- .../commercetools/sync/producttypes/ProductTypeSync.java | 5 +++-- .../com/commercetools/sync/services/impl/BaseService.java | 2 +- .../sync/producttypes/ProductTypeSyncTest.java | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/integration-test/java/com/commercetools/sync/integration/externalsource/producttypes/ProductTypeSyncIT.java b/src/integration-test/java/com/commercetools/sync/integration/externalsource/producttypes/ProductTypeSyncIT.java index d3c00553c1..36803f838e 100644 --- a/src/integration-test/java/com/commercetools/sync/integration/externalsource/producttypes/ProductTypeSyncIT.java +++ b/src/integration-test/java/com/commercetools/sync/integration/externalsource/producttypes/ProductTypeSyncIT.java @@ -406,7 +406,7 @@ public void sync_WithErrorCreatingTheProductType_ShouldExecuteCallbackOnErrorAnd assertThat(errorMessages) .hasSize(1) .hasOnlyOneElementSatisfying(message -> - assertThat(message).isEqualTo("Failed to create product type of key 'key_2'.") + assertThat(message).contains("Failed to create draft with key 'key_2'.") ); assertThat(exceptions) @@ -459,7 +459,7 @@ public void sync_WithErrorUpdatingTheProductType_ShouldExecuteCallbackOnErrorAnd assertThat(errorMessages) .hasSize(1) .hasOnlyOneElementSatisfying(message -> - assertThat(message).contains("Failed to update product type of key 'key_1'.") + assertThat(message).contains("Failed to update product type with key 'key_1'.") ); assertThat(exceptions) @@ -506,7 +506,7 @@ public void sync_WithoutName_ShouldExecuteCallbackOnErrorAndIncreaseFailedCounte assertThat(errorMessages) .hasSize(1) .hasOnlyOneElementSatisfying(message -> - assertThat(message).contains("Failed to update product type of key 'key_1'.") + assertThat(message).contains("Failed to update product type with key 'key_1'.") ); assertThat(exceptions) @@ -565,7 +565,7 @@ public void sync_WithoutAttributeType_ShouldExecuteCallbackOnErrorAndIncreaseFai assertThat(errorMessages) .hasSize(1) .hasOnlyOneElementSatisfying(message -> - assertThat(message).contains("Failed to update product type of key 'key_1'.") + assertThat(message).contains("Failed to update product type with key 'key_1'.") ); assertThat(exceptions) diff --git a/src/main/java/com/commercetools/sync/producttypes/ProductTypeSync.java b/src/main/java/com/commercetools/sync/producttypes/ProductTypeSync.java index c1cf8c6dd8..e73c7001eb 100644 --- a/src/main/java/com/commercetools/sync/producttypes/ProductTypeSync.java +++ b/src/main/java/com/commercetools/sync/producttypes/ProductTypeSync.java @@ -33,8 +33,9 @@ * This class syncs product type drafts with the corresponding product types in the CTP project. */ public class ProductTypeSync extends BaseSync { - private static final String CTP_PRODUCT_TYPE_FETCH_FAILED = "Failed to fetch existing product types of keys '%s'."; - private static final String CTP_PRODUCT_TYPE_UPDATE_FAILED = "Failed to update product type of key '%s'." + private static final String CTP_PRODUCT_TYPE_FETCH_FAILED = "Failed to fetch existing product types with keys" + + " '%s'."; + private static final String CTP_PRODUCT_TYPE_UPDATE_FAILED = "Failed to update product type with key '%s'." + " Reason: %s"; private static final String PRODUCT_TYPE_DRAFT_HAS_NO_KEY = "Failed to process product type draft without key."; private static final String PRODUCT_TYPE_DRAFT_IS_NULL = "Failed to process null product type draft."; diff --git a/src/main/java/com/commercetools/sync/services/impl/BaseService.java b/src/main/java/com/commercetools/sync/services/impl/BaseService.java index 0a2295627b..9284fb75cc 100644 --- a/src/main/java/com/commercetools/sync/services/impl/BaseService.java +++ b/src/main/java/com/commercetools/sync/services/impl/BaseService.java @@ -33,7 +33,7 @@ class BaseService, S extends BaseSyncOptions> { final Map keyToIdCache = new ConcurrentHashMap<>(); private static final int MAXIMUM_ALLOWED_UPDATE_ACTIONS = 500; - private static final String CREATE_FAILED = "Failed to create draft with key: '%s'. Reason: %s"; + private static final String CREATE_FAILED = "Failed to create draft with key '%s'. Reason: %s"; BaseService(@Nonnull final S syncOptions) { this.syncOptions = syncOptions; diff --git a/src/test/java/com/commercetools/sync/producttypes/ProductTypeSyncTest.java b/src/test/java/com/commercetools/sync/producttypes/ProductTypeSyncTest.java index ff60ae3503..d4810651c9 100644 --- a/src/test/java/com/commercetools/sync/producttypes/ProductTypeSyncTest.java +++ b/src/test/java/com/commercetools/sync/producttypes/ProductTypeSyncTest.java @@ -69,7 +69,7 @@ public void sync_WithErrorFetchingExistingKeys_ShouldExecuteCallbackOnErrorAndIn assertThat(errorMessages) .hasSize(1) .hasOnlyOneElementSatisfying(message -> - assertThat(message).isEqualTo("Failed to fetch existing product types of keys '[foo]'.") + assertThat(message).isEqualTo("Failed to fetch existing product types with keys '[foo]'.") ); assertThat(exceptions)