Skip to content

Commit

Permalink
#325: Fix error messages and assertions.
Browse files Browse the repository at this point in the history
  • Loading branch information
heshamMassoud committed Nov 30, 2018
1 parent 978b2b9 commit 05aa759
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Expand Up @@ -33,8 +33,9 @@
* This class syncs product type drafts with the corresponding product types in the CTP project.
*/
public class ProductTypeSync extends BaseSync<ProductTypeDraft, ProductTypeSyncStatistics, ProductTypeSyncOptions> {
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.";
Expand Down
Expand Up @@ -33,7 +33,7 @@ class BaseService<T, U extends Resource<U>, S extends BaseSyncOptions> {
final Map<String, String> 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;
Expand Down
Expand Up @@ -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)
Expand Down

0 comments on commit 05aa759

Please sign in to comment.