Skip to content

Commit 06fd922

Browse files
monikakusterivicac
authored andcommitted
568 update tests
1 parent a55508b commit 06fd922

File tree

12 files changed

+5115
-7201
lines changed

12 files changed

+5115
-7201
lines changed

server/libs/modules/components/shopify/src/test/java/com/bytechef/component/shopify/action/AbstractShopifyActionTest.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import com.bytechef.component.definition.ActionContext;
2424
import com.bytechef.component.shopify.util.ShopifyOptionsUtils;
2525
import com.bytechef.component.shopify.util.ShopifyUtils;
26+
import java.util.List;
27+
import java.util.Map;
2628
import org.junit.jupiter.api.AfterEach;
2729
import org.junit.jupiter.api.BeforeEach;
2830
import org.mockito.ArgumentCaptor;
@@ -31,23 +33,26 @@
3133
/**
3234
* @author Nikolina Spehar
3335
*/
34-
public abstract class AbstractShopifyActionTest {
36+
abstract class AbstractShopifyActionTest {
3537

3638
protected final ArgumentCaptor<ActionContext> actionContextArgumentCaptor = forClass(ActionContext.class);
3739
protected final ActionContext mockedActionContext = mock(ActionContext.class);
38-
protected final ArgumentCaptor<Object> objectArgumentCaptor = forClass(Object.class);
40+
@SuppressWarnings("unchecked")
41+
protected final ArgumentCaptor<Map<String, Object>> mapArgumentCaptor = forClass(Map.class);
42+
@SuppressWarnings("unchecked")
43+
protected final ArgumentCaptor<List<Object>> listArgumentCaptor = forClass(List.class);
3944
protected MockedStatic<ShopifyUtils> shopifyUtilsMockedStatic;
4045
protected MockedStatic<ShopifyOptionsUtils> shopifyOptionsUtilsMockedStatic;
4146
protected final ArgumentCaptor<String> stringArgumentCaptor = forClass(String.class);
4247

4348
@BeforeEach
44-
public void beforeEach() {
49+
void beforeEach() {
4550
shopifyUtilsMockedStatic = mockStatic(ShopifyUtils.class);
4651
shopifyOptionsUtilsMockedStatic = mockStatic(ShopifyOptionsUtils.class);
4752
}
4853

4954
@AfterEach
50-
public void afterEach() {
55+
void afterEach() {
5156
shopifyUtilsMockedStatic.close();
5257
shopifyOptionsUtilsMockedStatic.close();
5358
}

server/libs/modules/components/shopify/src/test/java/com/bytechef/component/shopify/action/ShopifyCancelOrderActionTest.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@
2626
import static org.junit.jupiter.api.Assertions.assertEquals;
2727
import static org.junit.jupiter.api.Assertions.assertTrue;
2828

29+
import com.bytechef.component.definition.ActionDefinition.BasePerformFunction;
2930
import com.bytechef.component.definition.ActionDefinition.PerformFunction;
30-
import com.bytechef.component.definition.ActionDefinition.SingleConnectionPerformFunction;
3131
import com.bytechef.component.definition.Parameters;
3232
import com.bytechef.component.shopify.util.ShopifyUtils;
3333
import com.bytechef.component.test.definition.MockParametersFactory;
34+
import java.util.List;
3435
import java.util.Map;
3536
import java.util.Optional;
3637
import org.junit.jupiter.api.Test;
@@ -40,7 +41,6 @@
4041
*/
4142
class ShopifyCancelOrderActionTest extends AbstractShopifyActionTest {
4243

43-
private final Object mockedObject = Map.of("orderCancel", Map.of());
4444
private final Parameters mockedParameters = MockParametersFactory.create(
4545
Map.of(
4646
NOTIFY_CUSTOMER, false,
@@ -53,18 +53,19 @@ class ShopifyCancelOrderActionTest extends AbstractShopifyActionTest {
5353
@Test
5454
void testPerform() throws Exception {
5555
shopifyUtilsMockedStatic
56-
.when(() -> ShopifyUtils.sendGraphQlQuery(
56+
.when(() -> ShopifyUtils.executeGraphQlOperation(
5757
stringArgumentCaptor.capture(),
5858
actionContextArgumentCaptor.capture(),
59-
(Map<String, Object>) objectArgumentCaptor.capture()))
60-
.thenReturn(mockedObject);
59+
mapArgumentCaptor.capture(),
60+
stringArgumentCaptor.capture()))
61+
.thenReturn(Map.of());
6162

62-
Optional<PerformFunction> performFunction = ShopifyCancelOrderAction.ACTION_DEFINITION.getPerform();
63+
Optional<? extends BasePerformFunction> basePerformFunction =
64+
ShopifyCancelOrderAction.ACTION_DEFINITION.getPerform();
6365

64-
assertTrue(performFunction.isPresent());
66+
assertTrue(basePerformFunction.isPresent());
6567

66-
SingleConnectionPerformFunction singleConnectionPerformFunction =
67-
(SingleConnectionPerformFunction) performFunction.get();
68+
PerformFunction singleConnectionPerformFunction = (PerformFunction) basePerformFunction.get();
6869

6970
Object result = singleConnectionPerformFunction.apply(
7071
mockedParameters, null, mockedActionContext);
@@ -112,8 +113,8 @@ mutation OrderCancel(
112113
RESTOCK, false,
113114
STAFF_NOTE, "staff note");
114115

115-
assertEquals(expectedQuery, stringArgumentCaptor.getValue());
116-
assertEquals(expectedVariables, objectArgumentCaptor.getValue());
116+
assertEquals(List.of(expectedQuery, "orderCancel"), stringArgumentCaptor.getAllValues());
117+
assertEquals(expectedVariables, mapArgumentCaptor.getValue());
117118
assertEquals(mockedActionContext, actionContextArgumentCaptor.getValue());
118119
}
119120
}

server/libs/modules/components/shopify/src/test/java/com/bytechef/component/shopify/action/ShopifyCloseOrderActionTest.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
import static org.junit.jupiter.api.Assertions.assertEquals;
2323
import static org.junit.jupiter.api.Assertions.assertTrue;
2424

25+
import com.bytechef.component.definition.ActionDefinition;
2526
import com.bytechef.component.definition.ActionDefinition.PerformFunction;
26-
import com.bytechef.component.definition.ActionDefinition.SingleConnectionPerformFunction;
2727
import com.bytechef.component.definition.Parameters;
2828
import com.bytechef.component.shopify.util.ShopifyUtils;
2929
import com.bytechef.component.test.definition.MockParametersFactory;
30+
import java.util.List;
3031
import java.util.Map;
3132
import java.util.Optional;
3233
import org.junit.jupiter.api.Test;
@@ -36,24 +37,24 @@
3637
*/
3738
class ShopifyCloseOrderActionTest extends AbstractShopifyActionTest {
3839

39-
private final Object mockedObject = Map.of("orderClose", Map.of());
4040
private final Parameters mockedParameters = MockParametersFactory.create(Map.of(ORDER_ID, "testOrderId"));
4141

4242
@Test
4343
void testPerform() throws Exception {
4444
shopifyUtilsMockedStatic
45-
.when(() -> ShopifyUtils.sendGraphQlQuery(
45+
.when(() -> ShopifyUtils.executeGraphQlOperation(
4646
stringArgumentCaptor.capture(),
4747
actionContextArgumentCaptor.capture(),
48-
(Map<String, Object>) objectArgumentCaptor.capture()))
49-
.thenReturn(mockedObject);
48+
mapArgumentCaptor.capture(),
49+
stringArgumentCaptor.capture()))
50+
.thenReturn(Map.of());
5051

51-
Optional<PerformFunction> performFunction = ShopifyCloseOrderAction.ACTION_DEFINITION.getPerform();
52+
Optional<? extends ActionDefinition.BasePerformFunction> performFunction =
53+
ShopifyCloseOrderAction.ACTION_DEFINITION.getPerform();
5254

5355
assertTrue(performFunction.isPresent());
5456

55-
SingleConnectionPerformFunction singleConnectionPerformFunction =
56-
(SingleConnectionPerformFunction) performFunction.get();
57+
PerformFunction singleConnectionPerformFunction = (PerformFunction) performFunction.get();
5758

5859
Object result = singleConnectionPerformFunction.apply(
5960
mockedParameters, null, mockedActionContext);
@@ -84,8 +85,8 @@ mutation OrderClose($input: OrderCloseInput!) {
8485

8586
Map<String, Object> expectedVariables = Map.of(INPUT, Map.of(ID, "testOrderId"));
8687

87-
assertEquals(expectedQuery, stringArgumentCaptor.getValue());
88-
assertEquals(expectedVariables, objectArgumentCaptor.getValue());
88+
assertEquals(List.of(expectedQuery, "orderClose"), stringArgumentCaptor.getAllValues());
89+
assertEquals(expectedVariables, mapArgumentCaptor.getValue());
8990
assertEquals(mockedActionContext, actionContextArgumentCaptor.getValue());
9091
}
9192
}

server/libs/modules/components/shopify/src/test/java/com/bytechef/component/shopify/action/ShopifyCreateOrderActionTest.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
import static org.mockito.Mockito.mock;
2828

2929
import com.bytechef.component.definition.ActionContext;
30+
import com.bytechef.component.definition.ActionDefinition.BasePerformFunction;
3031
import com.bytechef.component.definition.ActionDefinition.PerformFunction;
31-
import com.bytechef.component.definition.ActionDefinition.SingleConnectionPerformFunction;
3232
import com.bytechef.component.definition.Parameters;
3333
import com.bytechef.component.shopify.util.ShopifyOptionsUtils;
3434
import com.bytechef.component.shopify.util.ShopifyUtils;
@@ -44,32 +44,32 @@
4444
class ShopifyCreateOrderActionTest extends AbstractShopifyActionTest {
4545

4646
private final ActionContext mockedActionContext = mock(ActionContext.class);
47-
private final Object mockedObject = Map.of("orderCreate", Map.of());
4847
private final Parameters mockedParameters = MockParametersFactory.create(
4948
Map.of(PRODUCTS, List.of(Map.of(PRODUCT_ID, "productId", QUANTITY, 2))));
5049

5150
@Test
5251
void testPerform() throws Exception {
5352
shopifyUtilsMockedStatic
54-
.when(() -> ShopifyUtils.sendGraphQlQuery(
53+
.when(() -> ShopifyUtils.executeGraphQlOperation(
5554
stringArgumentCaptor.capture(),
5655
actionContextArgumentCaptor.capture(),
57-
(Map<String, Object>) objectArgumentCaptor.capture()))
58-
.thenReturn(mockedObject);
56+
mapArgumentCaptor.capture(),
57+
stringArgumentCaptor.capture()))
58+
.thenReturn(Map.of());
5959

6060
shopifyOptionsUtilsMockedStatic.when(
6161
() -> ShopifyOptionsUtils.getLineItemsList(
62-
actionContextArgumentCaptor.capture(), (List<Object>) objectArgumentCaptor.capture()))
62+
actionContextArgumentCaptor.capture(), listArgumentCaptor.capture()))
6363
.thenReturn(List.of(Map.of(VARIANT_ID, "variantId", QUANTITY, 2)));
6464

65-
Optional<PerformFunction> performFunction = ShopifyCreateOrderAction.ACTION_DEFINITION.getPerform();
65+
Optional<? extends BasePerformFunction> basePerformFunction =
66+
ShopifyCreateOrderAction.ACTION_DEFINITION.getPerform();
6667

67-
assertTrue(performFunction.isPresent());
68+
assertTrue(basePerformFunction.isPresent());
6869

69-
SingleConnectionPerformFunction singleConnectionPerformFunction =
70-
(SingleConnectionPerformFunction) performFunction.get();
70+
PerformFunction performFunction = (PerformFunction) basePerformFunction.get();
7171

72-
Object result = singleConnectionPerformFunction.apply(
72+
Object result = performFunction.apply(
7373
mockedParameters, null, mockedActionContext);
7474

7575
assertEquals(Map.of(), result);
@@ -102,8 +102,9 @@ mutation orderCreate($order: OrderCreateOrderInput!, $options: OrderCreateOption
102102
Map<String, Object> expectedVariables = Map.of(
103103
ORDER, Map.of(LINE_ITEMS, List.of(Map.of(VARIANT_ID, "variantId", QUANTITY, 2))));
104104

105-
assertEquals(expectedQuery, stringArgumentCaptor.getValue());
106-
assertEquals(List.of(expectedList, expectedVariables), objectArgumentCaptor.getAllValues());
105+
assertEquals(List.of(expectedQuery, "orderCreate"), stringArgumentCaptor.getAllValues());
106+
assertEquals(expectedVariables, mapArgumentCaptor.getValue());
107+
assertEquals(expectedList, listArgumentCaptor.getValue());
107108
assertEquals(List.of(mockedActionContext, mockedActionContext), actionContextArgumentCaptor.getAllValues());
108109
}
109110
}

server/libs/modules/components/shopify/src/test/java/com/bytechef/component/shopify/action/ShopifyDeleteOrderActionTest.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
import static org.junit.jupiter.api.Assertions.assertEquals;
2121
import static org.junit.jupiter.api.Assertions.assertTrue;
2222

23+
import com.bytechef.component.definition.ActionDefinition.BasePerformFunction;
2324
import com.bytechef.component.definition.ActionDefinition.PerformFunction;
24-
import com.bytechef.component.definition.ActionDefinition.SingleConnectionPerformFunction;
2525
import com.bytechef.component.definition.Parameters;
2626
import com.bytechef.component.shopify.util.ShopifyUtils;
2727
import com.bytechef.component.test.definition.MockParametersFactory;
28+
import java.util.List;
2829
import java.util.Map;
2930
import java.util.Optional;
3031
import org.junit.jupiter.api.Test;
@@ -34,24 +35,24 @@
3435
*/
3536
class ShopifyDeleteOrderActionTest extends AbstractShopifyActionTest {
3637

37-
private final Object mockedObject = Map.of("orderDelete", Map.of());
3838
private final Parameters mockedParameters = MockParametersFactory.create(Map.of(ORDER_ID, "testOrderId"));
3939

4040
@Test
4141
void testPerform() throws Exception {
4242
shopifyUtilsMockedStatic
43-
.when(() -> ShopifyUtils.sendGraphQlQuery(
43+
.when(() -> ShopifyUtils.executeGraphQlOperation(
4444
stringArgumentCaptor.capture(),
4545
actionContextArgumentCaptor.capture(),
46-
(Map<String, Object>) objectArgumentCaptor.capture()))
47-
.thenReturn(mockedObject);
46+
mapArgumentCaptor.capture(),
47+
stringArgumentCaptor.capture()))
48+
.thenReturn(Map.of());
4849

49-
Optional<PerformFunction> performFunction = ShopifyDeleteOrderAction.ACTION_DEFINITION.getPerform();
50+
Optional<? extends BasePerformFunction> performFunction =
51+
ShopifyDeleteOrderAction.ACTION_DEFINITION.getPerform();
5052

5153
assertTrue(performFunction.isPresent());
5254

53-
SingleConnectionPerformFunction singleConnectionPerformFunction =
54-
(SingleConnectionPerformFunction) performFunction.get();
55+
PerformFunction singleConnectionPerformFunction = (PerformFunction) performFunction.get();
5556

5657
Object result = singleConnectionPerformFunction.apply(
5758
mockedParameters, null, mockedActionContext);
@@ -72,8 +73,8 @@ mutation OrderDelete($orderId: ID!) {
7273

7374
Map<String, Object> expectedVariables = Map.of(ORDER_ID, "testOrderId");
7475

75-
assertEquals(expectedQuery, stringArgumentCaptor.getValue());
76-
assertEquals(expectedVariables, objectArgumentCaptor.getValue());
76+
assertEquals(List.of(expectedQuery, "orderDelete"), stringArgumentCaptor.getAllValues());
77+
assertEquals(expectedVariables, mapArgumentCaptor.getValue());
7778
assertEquals(mockedActionContext, actionContextArgumentCaptor.getValue());
7879
}
7980
}

server/libs/modules/components/shopify/src/test/java/com/bytechef/component/shopify/action/ShopifyGetOrderActionTest.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
import static org.junit.jupiter.api.Assertions.assertEquals;
2222
import static org.junit.jupiter.api.Assertions.assertTrue;
2323

24+
import com.bytechef.component.definition.ActionDefinition;
2425
import com.bytechef.component.definition.ActionDefinition.PerformFunction;
25-
import com.bytechef.component.definition.ActionDefinition.SingleConnectionPerformFunction;
2626
import com.bytechef.component.definition.Parameters;
2727
import com.bytechef.component.shopify.util.ShopifyUtils;
2828
import com.bytechef.component.test.definition.MockParametersFactory;
29+
import java.util.List;
2930
import java.util.Map;
3031
import java.util.Optional;
3132
import org.junit.jupiter.api.Test;
@@ -35,24 +36,24 @@
3536
*/
3637
class ShopifyGetOrderActionTest extends AbstractShopifyActionTest {
3738

38-
private final Object mockedObject = Map.of("order", Map.of());
3939
private final Parameters mockedParameters = MockParametersFactory.create(Map.of(ORDER_ID, "testOrderId"));
4040

4141
@Test
4242
void testPerform() throws Exception {
4343
shopifyUtilsMockedStatic
44-
.when(() -> ShopifyUtils.sendGraphQlQuery(
44+
.when(() -> ShopifyUtils.executeGraphQlOperation(
4545
stringArgumentCaptor.capture(),
4646
actionContextArgumentCaptor.capture(),
47-
(Map<String, Object>) objectArgumentCaptor.capture()))
48-
.thenReturn(mockedObject);
47+
mapArgumentCaptor.capture(),
48+
stringArgumentCaptor.capture()))
49+
.thenReturn(Map.of());
4950

50-
Optional<PerformFunction> performFunction = ShopifyGetOrderAction.ACTION_DEFINITION.getPerform();
51+
Optional<? extends ActionDefinition.BasePerformFunction> performFunction =
52+
ShopifyGetOrderAction.ACTION_DEFINITION.getPerform();
5153

5254
assertTrue(performFunction.isPresent());
5355

54-
SingleConnectionPerformFunction singleConnectionPerformFunction =
55-
(SingleConnectionPerformFunction) performFunction.get();
56+
PerformFunction singleConnectionPerformFunction = (PerformFunction) performFunction.get();
5657

5758
Object result = singleConnectionPerformFunction.apply(
5859
mockedParameters, null, mockedActionContext);
@@ -86,8 +87,8 @@ query GetOrder($id: ID!) {
8687

8788
Map<String, Object> expectedVariables = Map.of(ID, "testOrderId");
8889

89-
assertEquals(expectedQuery, stringArgumentCaptor.getValue());
90-
assertEquals(expectedVariables, objectArgumentCaptor.getValue());
90+
assertEquals(List.of(expectedQuery, "order"), stringArgumentCaptor.getAllValues());
91+
assertEquals(expectedVariables, mapArgumentCaptor.getValue());
9192
assertEquals(mockedActionContext, actionContextArgumentCaptor.getValue());
9293
}
9394
}

server/libs/modules/components/shopify/src/test/java/com/bytechef/component/shopify/action/ShopifyUpdateOrderActionTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
import static org.junit.jupiter.api.Assertions.assertEquals;
2626
import static org.junit.jupiter.api.Assertions.assertTrue;
2727

28+
import com.bytechef.component.definition.ActionDefinition.BasePerformFunction;
2829
import com.bytechef.component.definition.ActionDefinition.PerformFunction;
29-
import com.bytechef.component.definition.ActionDefinition.SingleConnectionPerformFunction;
3030
import com.bytechef.component.definition.Parameters;
3131
import com.bytechef.component.shopify.util.ShopifyUtils;
3232
import com.bytechef.component.test.definition.MockParametersFactory;
@@ -40,7 +40,6 @@
4040
*/
4141
class ShopifyUpdateOrderActionTest extends AbstractShopifyActionTest {
4242

43-
private final Object mockedObject = Map.of("orderUpdate", Map.of());
4443
private final Parameters mockedParameters = MockParametersFactory.create(
4544
Map.of(
4645
ORDER_ID, "orderId",
@@ -51,18 +50,19 @@ class ShopifyUpdateOrderActionTest extends AbstractShopifyActionTest {
5150
@Test
5251
void testPerform() throws Exception {
5352
shopifyUtilsMockedStatic
54-
.when(() -> ShopifyUtils.sendGraphQlQuery(
53+
.when(() -> ShopifyUtils.executeGraphQlOperation(
5554
stringArgumentCaptor.capture(),
5655
actionContextArgumentCaptor.capture(),
57-
(Map<String, Object>) objectArgumentCaptor.capture()))
58-
.thenReturn(mockedObject);
56+
mapArgumentCaptor.capture(),
57+
stringArgumentCaptor.capture()))
58+
.thenReturn(Map.of());
5959

60-
Optional<PerformFunction> performFunction = ShopifyUpdateOrderAction.ACTION_DEFINITION.getPerform();
60+
Optional<? extends BasePerformFunction> performFunction =
61+
ShopifyUpdateOrderAction.ACTION_DEFINITION.getPerform();
6162

6263
assertTrue(performFunction.isPresent());
6364

64-
SingleConnectionPerformFunction singleConnectionPerformFunction =
65-
(SingleConnectionPerformFunction) performFunction.get();
65+
PerformFunction singleConnectionPerformFunction = (PerformFunction) performFunction.get();
6666

6767
Object result = singleConnectionPerformFunction.apply(
6868
mockedParameters, null, mockedActionContext);
@@ -92,8 +92,8 @@ mutation OrderUpdate($input: OrderInput!) {
9292
EMAIL, "email",
9393
TAGS, List.of("tag1", "tag2")));
9494

95-
assertEquals(expectedQuery, stringArgumentCaptor.getValue());
96-
assertEquals(expectedVariables, objectArgumentCaptor.getValue());
95+
assertEquals(List.of(expectedQuery, "orderUpdate"), stringArgumentCaptor.getAllValues());
96+
assertEquals(expectedVariables, mapArgumentCaptor.getValue());
9797
assertEquals(mockedActionContext, actionContextArgumentCaptor.getValue());
9898
}
9999
}

0 commit comments

Comments
 (0)