use of com.commercetools.sync.products.helpers.ProductSyncStatistics in project commercetools-project-sync by commercetools.
the class LastSyncCustomObjectTest method equals_WithUnequalDurations_ShouldReturnFalse.
@Test
void equals_WithUnequalDurations_ShouldReturnFalse() {
// preparation
final ZonedDateTime lastSyncTimestamp = ZonedDateTime.now();
final int lastSyncDurationInSeconds = 100;
final ProductSyncStatistics lastSyncStatistics = new ProductSyncStatistics();
final LastSyncCustomObject<ProductSyncStatistics> lastSyncCustomObject = LastSyncCustomObject.of(lastSyncTimestamp, lastSyncStatistics, lastSyncDurationInSeconds);
final LastSyncCustomObject<ProductSyncStatistics> otherLastSyncCustomObject = LastSyncCustomObject.of(lastSyncTimestamp, lastSyncStatistics, 90);
// test
final boolean result = lastSyncCustomObject.equals(otherLastSyncCustomObject);
// assertions
assertThat(result).isFalse();
}
use of com.commercetools.sync.products.helpers.ProductSyncStatistics in project commercetools-project-sync by commercetools.
the class CustomObjectServiceImplTest method createLastSyncCustomObject_WithValidTestRunnerName_ShouldCreateCorrectCustomObjectDraft.
@Test
@SuppressWarnings("unchecked")
void createLastSyncCustomObject_WithValidTestRunnerName_ShouldCreateCorrectCustomObjectDraft() {
// preparation
final SphereClient client = mock(SphereClient.class);
final ArgumentCaptor<CustomObjectUpsertCommand> arg = ArgumentCaptor.forClass(CustomObjectUpsertCommand.class);
when(client.execute(arg.capture())).thenReturn(null);
final CustomObjectService customObjectService = new CustomObjectServiceImpl(client);
final LastSyncCustomObject<ProductSyncStatistics> lastSyncCustomObject = LastSyncCustomObject.of(ZonedDateTime.now(), new ProductSyncStatistics(), 100);
// test
customObjectService.createLastSyncCustomObject("foo", "bar", "testRunnerName", lastSyncCustomObject);
// assertions
final CustomObjectDraft createdDraft = (CustomObjectDraft) arg.getValue().getDraft();
assertThat(createdDraft.getContainer()).isEqualTo("commercetools-project-sync.testRunnerName.bar");
assertThat(createdDraft.getKey()).isEqualTo("foo");
}
use of com.commercetools.sync.products.helpers.ProductSyncStatistics in project commercetools-project-sync by commercetools.
the class CustomObjectServiceImplTest method createLastSyncCustomObject_WithNullRunnerName_ShouldCreateCorrectCustomObjectDraft.
@Test
@SuppressWarnings("unchecked")
void createLastSyncCustomObject_WithNullRunnerName_ShouldCreateCorrectCustomObjectDraft() {
// preparation
final SphereClient client = mock(SphereClient.class);
final ArgumentCaptor<CustomObjectUpsertCommand> arg = ArgumentCaptor.forClass(CustomObjectUpsertCommand.class);
when(client.execute(arg.capture())).thenReturn(null);
final CustomObjectService customObjectService = new CustomObjectServiceImpl(client);
final LastSyncCustomObject<ProductSyncStatistics> lastSyncCustomObject = LastSyncCustomObject.of(ZonedDateTime.now(), new ProductSyncStatistics(), 100);
// test
customObjectService.createLastSyncCustomObject("foo", "bar", null, lastSyncCustomObject);
// assertions
final CustomObjectDraft createdDraft = (CustomObjectDraft) arg.getValue().getDraft();
assertThat(createdDraft.getContainer()).isEqualTo("commercetools-project-sync.runnerName.bar");
assertThat(createdDraft.getKey()).isEqualTo("foo");
}
use of com.commercetools.sync.products.helpers.ProductSyncStatistics in project commercetools-project-sync by commercetools.
the class CustomObjectServiceImplTest method createLastSyncCustomObject_OnSuccessfulCreation_ShouldCompleteWithLastSyncCustomObject.
@Test
@SuppressWarnings("unchecked")
void createLastSyncCustomObject_OnSuccessfulCreation_ShouldCompleteWithLastSyncCustomObject() {
// preparation
when(CLIENT.execute(any(CustomObjectUpsertCommand.class))).thenReturn(CompletableFuture.completedFuture(LAST_SYNC_CUSTOM_OBJECT));
final CustomObjectService customObjectService = new CustomObjectServiceImpl(CLIENT);
// test
final LastSyncCustomObject<ProductSyncStatistics> lastSyncCustomObject = LastSyncCustomObject.of(ZonedDateTime.now(), new ProductSyncStatistics(), 100);
final CustomObject<LastSyncCustomObject> createdCustomObject = customObjectService.createLastSyncCustomObject("foo", "bar", DEFAULT_RUNNER_NAME, lastSyncCustomObject).toCompletableFuture().join();
// assertions
assertThat(createdCustomObject).isEqualTo(LAST_SYNC_CUSTOM_OBJECT);
}
use of com.commercetools.sync.products.helpers.ProductSyncStatistics in project commercetools-project-sync by commercetools.
the class CustomObjectServiceImplTest method createLastSyncCustomObject_WithEmptyRunnerName_ShouldCreateCorrectCustomObjectDraft.
@Test
@SuppressWarnings("unchecked")
void createLastSyncCustomObject_WithEmptyRunnerName_ShouldCreateCorrectCustomObjectDraft() {
// preparation
final SphereClient client = mock(SphereClient.class);
final ArgumentCaptor<CustomObjectUpsertCommand> arg = ArgumentCaptor.forClass(CustomObjectUpsertCommand.class);
when(client.execute(arg.capture())).thenReturn(null);
final CustomObjectService customObjectService = new CustomObjectServiceImpl(client);
final LastSyncCustomObject<ProductSyncStatistics> lastSyncCustomObject = LastSyncCustomObject.of(ZonedDateTime.now(), new ProductSyncStatistics(), 100);
// test
customObjectService.createLastSyncCustomObject("foo", "bar", "", lastSyncCustomObject);
// assertions
final CustomObjectDraft createdDraft = (CustomObjectDraft) arg.getValue().getDraft();
assertThat(createdDraft.getContainer()).isEqualTo("commercetools-project-sync.runnerName.bar");
assertThat(createdDraft.getKey()).isEqualTo("foo");
}
Aggregations