|
5 | 5 | import com.commercetools.sync.categories.CategorySyncOptionsBuilder; |
6 | 6 | import com.commercetools.sync.categories.helpers.CategorySyncStatistics; |
7 | 7 | import com.commercetools.sync.commons.exceptions.ReferenceResolutionException; |
8 | | -import com.fasterxml.jackson.core.JsonProcessingException; |
9 | 8 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
10 | 9 | import io.sphere.sdk.categories.Category; |
11 | 10 | import io.sphere.sdk.categories.CategoryDraft; |
|
18 | 17 | import org.junit.Before; |
19 | 18 | import org.junit.BeforeClass; |
20 | 19 | import org.junit.Test; |
21 | | -import org.slf4j.Logger; |
22 | | -import org.slf4j.LoggerFactory; |
23 | 20 |
|
24 | 21 | import java.util.ArrayList; |
25 | 22 | import java.util.Collections; |
|
43 | 40 | import static com.commercetools.sync.integration.commons.utils.CategoryITUtils.getCustomFieldsJsons; |
44 | 41 | import static com.commercetools.sync.integration.commons.utils.CategoryITUtils.syncBatches; |
45 | 42 | import static com.commercetools.sync.integration.commons.utils.ITUtils.deleteTypesFromTargetAndSource; |
46 | | -import static com.commercetools.sync.integration.commons.utils.ITUtils.getStatisticsAsJSONString; |
47 | 43 | import static com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_SOURCE_CLIENT; |
48 | 44 | import static com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_TARGET_CLIENT; |
49 | 45 | import static java.lang.String.format; |
50 | 46 | import static org.assertj.core.api.Assertions.assertThat; |
51 | 47 |
|
52 | 48 | public class CategorySyncIT { |
53 | | - private static final Logger LOGGER = LoggerFactory.getLogger(CategorySyncIT.class); |
54 | 49 | private CategorySync categorySync; |
55 | 50 |
|
56 | 51 | private List<String> callBackErrorResponses = new ArrayList<>(); |
@@ -90,12 +85,8 @@ public void setupTest() { |
90 | 85 | .setErrorCallBack((errorMessage, exception) -> { |
91 | 86 | callBackErrorResponses.add(errorMessage); |
92 | 87 | callBackExceptions.add(exception); |
93 | | - LOGGER.error(errorMessage, exception); |
94 | | - }) |
95 | | - .setWarningCallBack((warningMessage) -> { |
96 | | - callBackWarningResponses.add(warningMessage); |
97 | | - LOGGER.warn(warningMessage); |
98 | 88 | }) |
| 89 | + .setWarningCallBack((warningMessage) -> callBackWarningResponses.add(warningMessage)) |
99 | 90 | .build(); |
100 | 91 | categorySync = new CategorySync(categorySyncOptions); |
101 | 92 | } |
@@ -231,18 +222,8 @@ public void syncDrafts_withNewShuffledBatchOfCategories_ShouldCreateCategories() |
231 | 222 | // Simulate batches of categories where not all parent references are supplied at once. |
232 | 223 | final List<List<CategoryDraft>> batches = batchDrafts(categoryDrafts, 13); |
233 | 224 |
|
234 | | - final long startTime = System.currentTimeMillis(); |
235 | | - LOGGER.info("Starting to sync categories:"); |
236 | 225 | final CategorySyncStatistics syncStatistics = syncBatches(categorySync, batches, |
237 | 226 | CompletableFuture.completedFuture(null)).toCompletableFuture().join(); |
238 | | - LOGGER.info(syncStatistics.getReportMessage()); |
239 | | - try { |
240 | | - LOGGER.info(getStatisticsAsJSONString(syncStatistics)); |
241 | | - } catch (JsonProcessingException exception) { |
242 | | - LOGGER.error("Failed to build JSON String of summary.", exception); |
243 | | - } |
244 | | - final long syncTimeTaken = System.currentTimeMillis() - startTime; |
245 | | - LOGGER.info("Syncing categories took: " + syncTimeTaken + "ms"); |
246 | 227 |
|
247 | 228 | assertThat(syncStatistics.getReportMessage()) |
248 | 229 | .isEqualTo(format("Summary: %d categories were processed in total (%d created, %d updated, %d failed to " |
@@ -297,18 +278,8 @@ public void syncDrafts_withExistingShuffledCategoriesWithChangingCategoryHierarc |
297 | 278 |
|
298 | 279 | final List<List<CategoryDraft>> batches = batchDrafts(categoryDrafts, 13); |
299 | 280 |
|
300 | | - final long startTime = System.currentTimeMillis(); |
301 | | - LOGGER.info("Starting to sync categories:"); |
302 | 281 | final CategorySyncStatistics syncStatistics = syncBatches(categorySync, batches, |
303 | 282 | CompletableFuture.completedFuture(null)).toCompletableFuture().join(); |
304 | | - LOGGER.info(syncStatistics.getReportMessage()); |
305 | | - try { |
306 | | - LOGGER.info(getStatisticsAsJSONString(syncStatistics)); |
307 | | - } catch (JsonProcessingException exception) { |
308 | | - LOGGER.error("Failed to build JSON String of summary.", exception); |
309 | | - } |
310 | | - final long syncTimeTaken = System.currentTimeMillis() - startTime; |
311 | | - LOGGER.info("Syncing categories took: " + syncTimeTaken + "ms"); |
312 | 283 |
|
313 | 284 | assertThat(syncStatistics.getReportMessage()) |
314 | 285 | .isEqualTo(format("Summary: %d categories were processed in total (%d created, %d updated, %d failed to " |
@@ -353,18 +324,8 @@ public void syncDrafts_withExistingCategoriesThatChangeParents_ShouldUpdateCateg |
353 | 324 |
|
354 | 325 | final List<List<CategoryDraft>> batches = batchDrafts(categoryDrafts, 1); |
355 | 326 |
|
356 | | - final long startTime = System.currentTimeMillis(); |
357 | | - LOGGER.info("Starting to sync categories:"); |
358 | 327 | final CategorySyncStatistics syncStatistics = syncBatches(categorySync, batches, |
359 | 328 | CompletableFuture.completedFuture(null)).toCompletableFuture().join(); |
360 | | - LOGGER.info(syncStatistics.getReportMessage()); |
361 | | - try { |
362 | | - LOGGER.info(getStatisticsAsJSONString(syncStatistics)); |
363 | | - } catch (JsonProcessingException exception) { |
364 | | - LOGGER.error("Failed to build JSON String of summary.", exception); |
365 | | - } |
366 | | - final long syncTimeTaken = System.currentTimeMillis() - startTime; |
367 | | - LOGGER.info("Syncing categories took: " + syncTimeTaken + "ms"); |
368 | 329 |
|
369 | 330 | assertThat(syncStatistics.getReportMessage()) |
370 | 331 | .isEqualTo(format("Summary: %d categories were processed in total (%d created, %d updated, %d failed to " |
@@ -435,24 +396,13 @@ public void syncDrafts_withANonExistingNewParent_ShouldUpdateCategories() { |
435 | 396 |
|
436 | 397 | final List<List<CategoryDraft>> batches = batchDrafts(categoryDrafts, 1); |
437 | 398 |
|
438 | | - final long startTime = System.currentTimeMillis(); |
439 | | - LOGGER.info("Starting to sync categories:"); |
440 | 399 | final CategorySyncStatistics syncStatistics = syncBatches(categorySync, batches, |
441 | 400 | CompletableFuture.completedFuture(null)).toCompletableFuture().join(); |
442 | | - LOGGER.info(syncStatistics.getReportMessage()); |
443 | | - try { |
444 | | - LOGGER.info(getStatisticsAsJSONString(syncStatistics)); |
445 | | - } catch (JsonProcessingException exception) { |
446 | | - LOGGER.error("Failed to build JSON String of summary.", exception); |
447 | | - } |
448 | | - final long syncTimeTaken = System.currentTimeMillis() - startTime; |
449 | | - LOGGER.info("Syncing categories took: " + syncTimeTaken + "ms"); |
450 | 401 |
|
451 | 402 | assertThat(syncStatistics.getReportMessage()) |
452 | 403 | .isEqualTo(format("Summary: %d categories were processed in total (%d created, %d updated, %d failed to " |
453 | 404 | + "sync and %s categories with a missing parent).", 2, 1, 1, 0, 0)); |
454 | 405 |
|
455 | | - |
456 | 406 | assertThat(callBackErrorResponses).isEmpty(); |
457 | 407 | assertThat(callBackExceptions).isEmpty(); |
458 | 408 | assertThat(callBackWarningResponses).isEmpty(); |
|
0 commit comments