1+
12package 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+
38import com .commercetools .api .models .category .Category ;
49import com .commercetools .api .models .category .CategoryImpl ;
10+
511import io .vrap .rmf .base .client .utils .json .JsonUtils ;
12+
613import org .junit .jupiter .api .Test ;
14+
715import tools .jackson .databind .ObjectMapper ;
816import 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-
1418public 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}
0 commit comments