Skip to content

Commit 4700565

Browse files
committed
Merge remote-tracking branch 'origin/DEVX-640-helper-method-from-Coco-product-to-import-API-product' into DEVX-640-helper-method-from-Coco-product-to-import-API-product
2 parents 5d7b45f + d508c1c commit 4700565

4 files changed

Lines changed: 31 additions & 18 deletions

File tree

.git-blame-ignore-revs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ cd4bb52247f964cdb924e28f32a6cd888d25ccea
3838
6f16c4a0cc66ed69ab5769595332d984c4abff9f
3939
8453de765b5576178f2e5d5ea6b6c1a5c6668027
4040
1f7b152196e439257d3307b749bbe9546b05fc66
41+
5b7970b78743956139530f1476937c7de792a06c

commercetools/commercetools-importapi-utils/src/main/java/com/commercetools/sdk/CustomerUtil.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.commercetools.importapi.models.customers.AuthenticationMode;
1313
import com.commercetools.importapi.models.customers.CustomerAddress;
1414
import com.commercetools.importapi.models.customers.CustomerImport;
15+
1516
import jakarta.validation.constraints.NotNull;
1617

1718
public class CustomerUtil {
Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
1+
12
package com.commercetools.sdk;
23

4+
import static com.commercetools.sdk.TestUtils.stringFromResource;
5+
import static org.junit.jupiter.api.Assertions.*;
6+
import static org.junit.jupiter.api.Assertions.assertEquals;
7+
38
import com.commercetools.api.models.category.Category;
49
import com.commercetools.api.models.category.CategoryImpl;
10+
511
import io.vrap.rmf.base.client.utils.json.JsonUtils;
12+
613
import org.junit.jupiter.api.Test;
14+
715
import tools.jackson.databind.ObjectMapper;
816
import tools.jackson.databind.json.JsonMapper;
917

10-
import static com.commercetools.sdk.TestUtils.stringFromResource;
11-
import static org.junit.jupiter.api.Assertions.*;
12-
import static org.junit.jupiter.api.Assertions.assertEquals;
13-
1418
public class CategoryUtilTest {
1519
String categoryProjectionExample = "src/test/resources/category.example.json";
1620
private final ObjectMapper objectMapper = new JsonMapper();
1721
CategoryUtil util = new CategoryUtil();
1822

1923
@Test
2024
void shouldDeserializeCategoryCorrectly() throws Exception {
21-
var testCategory = JsonUtils.fromJsonString(stringFromResource(categoryProjectionExample),
22-
Category.class);
25+
var testCategory = JsonUtils.fromJsonString(stringFromResource(categoryProjectionExample), Category.class);
2326

2427
assertNotNull(testCategory, "The category object should not be null.");
2528
assertInstanceOf(CategoryImpl.class, testCategory,
26-
"The category should be an instance of Category based on the annotation.");
29+
"The category should be an instance of Category based on the annotation.");
2730
}
31+
2832
@Test
2933
void shouldMapRequiredFields() {
3034
var category = JsonUtils.fromJsonString(stringFromResource(categoryProjectionExample), Category.class);
@@ -41,27 +45,28 @@ void shouldMapParentKeyFromExpandedObj() {
4145
var result = util.toCategoryImport(category);
4246

4347
assertNotNull(result.getParent());
44-
assertEquals("parent-key", result.getParent().getKey()); // key, not UUID
48+
assertEquals("parent-key", result.getParent().getKey()); // key, not UUID
4549
}
4650

4751
@Test
4852
void shouldMapExternalId() {
4953
var category = JsonUtils.fromJsonString(stringFromResource(categoryProjectionExample), Category.class);
5054
var result = util.toCategoryImport(category);
51-
assertEquals("ext-001", result.getExternalId()); // catches the getId() bug
55+
assertEquals("ext-001", result.getExternalId()); // catches the getId() bug
5256
}
5357

5458
@Test
5559
void shouldHandleNullParent() {
5660
// fixture without parent field
57-
var category = JsonUtils.fromJsonString(stringFromResource("src/test/resources/category.no-parent.json"), Category.class);
61+
var category = JsonUtils.fromJsonString(stringFromResource("src/test/resources/category.no-parent.json"),
62+
Category.class);
5863
var result = util.toCategoryImport(category);
5964
assertNull(result.getParent());
6065
}
6166

6267
@Test
6368
void shouldHandleNullCustom() {
6469
var category = JsonUtils.fromJsonString(stringFromResource(categoryProjectionExample), Category.class);
65-
assertDoesNotThrow(() -> util.toCategoryImport(category)); // no NPE when custom is absent
70+
assertDoesNotThrow(() -> util.toCategoryImport(category)); // no NPE when custom is absent
6671
}
6772
}

commercetools/commercetools-importapi-utils/src/test/java/com/commercetools/sdk/InventoryUtilTest.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1+
12
package com.commercetools.sdk;
23

4+
import static com.commercetools.sdk.TestUtils.stringFromResource;
5+
import static org.junit.jupiter.api.Assertions.*;
6+
37
import com.commercetools.api.models.inventory.InventoryEntry;
8+
49
import io.vrap.rmf.base.client.utils.json.JsonUtils;
5-
import org.junit.jupiter.api.Test;
610

7-
import static com.commercetools.sdk.TestUtils.stringFromResource;
8-
import static org.junit.jupiter.api.Assertions.*;
11+
import org.junit.jupiter.api.Test;
912

1013
public class InventoryUtilTest {
1114
private final InventoryUtil util = new InventoryUtil();
1215

1316
@Test
1417
void shouldMapRequiredFields() {
15-
var entry = JsonUtils.fromJsonString(stringFromResource("src/test/resources/inventory.example.json"), InventoryEntry.class);
18+
var entry = JsonUtils.fromJsonString(stringFromResource("src/test/resources/inventory.example.json"),
19+
InventoryEntry.class);
1620
var result = util.toInventoryImport(entry);
1721

1822
assertEquals("inventory-key", result.getKey());
@@ -22,16 +26,18 @@ void shouldMapRequiredFields() {
2226

2327
@Test
2428
void shouldMapSupplyChannelKeyFromExpandedObj() {
25-
var entry = JsonUtils.fromJsonString(stringFromResource("src/test/resources/inventory.example.json"), InventoryEntry.class);
29+
var entry = JsonUtils.fromJsonString(stringFromResource("src/test/resources/inventory.example.json"),
30+
InventoryEntry.class);
2631
var result = util.toInventoryImport(entry);
2732

2833
assertNotNull(result.getSupplyChannel());
29-
assertEquals("channel-key", result.getSupplyChannel().getKey()); // catches getId() bug
34+
assertEquals("channel-key", result.getSupplyChannel().getKey()); // catches getId() bug
3035
}
3136

3237
@Test
3338
void shouldHandleNullSupplyChannel() {
34-
var entry = JsonUtils.fromJsonString(stringFromResource("src/test/resources/inventory.no-channel.json"), InventoryEntry.class);
39+
var entry = JsonUtils.fromJsonString(stringFromResource("src/test/resources/inventory.no-channel.json"),
40+
InventoryEntry.class);
3541
var result = util.toInventoryImport(entry);
3642
assertNull(result.getSupplyChannel());
3743
}

0 commit comments

Comments
 (0)