Skip to content

Commit b2d5a66

Browse files
monikakusterivicac
authored andcommitted
3196 fix tests
1 parent e8a99f6 commit b2d5a66

File tree

2 files changed

+14092
-9679
lines changed

2 files changed

+14092
-9679
lines changed

server/libs/modules/components/github/src/test/java/com/bytechef/component/github/action/GitHubCreatePullRequestActionTest.java

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,50 @@
1616

1717
package com.bytechef.component.github.action;
1818

19-
import com.bytechef.component.definition.Context;
19+
import static com.bytechef.component.github.constant.GithubConstants.BASE;
20+
import static com.bytechef.component.github.constant.GithubConstants.BODY;
21+
import static com.bytechef.component.github.constant.GithubConstants.HEAD;
22+
import static com.bytechef.component.github.constant.GithubConstants.HEAD_REPO;
23+
import static com.bytechef.component.github.constant.GithubConstants.OWNER;
24+
import static com.bytechef.component.github.constant.GithubConstants.REPOSITORY;
25+
import static com.bytechef.component.github.constant.GithubConstants.TITLE;
26+
import static org.junit.jupiter.api.Assertions.assertEquals;
27+
import static org.mockito.ArgumentMatchers.any;
28+
import static org.mockito.Mockito.when;
29+
30+
import com.bytechef.component.definition.Context.Http;
2031
import com.bytechef.component.definition.Parameters;
2132
import com.bytechef.component.definition.TypeReference;
2233
import com.bytechef.component.test.definition.MockParametersFactory;
23-
import org.junit.jupiter.api.Test;
24-
2534
import java.util.Map;
26-
27-
import static com.bytechef.component.github.constant.GithubConstants.*;
28-
import static org.junit.jupiter.api.Assertions.assertEquals;
29-
import static org.mockito.ArgumentMatchers.any;
30-
import static org.mockito.Mockito.when;
35+
import org.junit.jupiter.api.Test;
3136

3237
/**
3338
* @author Anas Elgarhy (@0x61nas)
39+
* @author Monika Kušter
3440
*/
3541
class GitHubCreatePullRequestActionTest extends AbstractGithubActionTest {
36-
private final Map<String, Object> parameterMap = Map.of(TITLE, "name", HEAD, "feat/make-it-awesome",
37-
HEAD_REPO, "happy-repo", BASE, "master", BODY, "description");
38-
private final Parameters mockedParameters = MockParametersFactory.create(parameterMap);
42+
43+
private final Parameters mockedParameters = MockParametersFactory.create(
44+
Map.of(
45+
OWNER, "testOwner", REPOSITORY, "testRepo", TITLE, "name", HEAD, "feat/123",
46+
HEAD_REPO, "head-repo", BASE, "master", BODY, "description"));
3947

4048
@Test
41-
void testPerform() {
49+
void testPerform() throws Exception {
50+
when(mockedHttp.post(stringArgumentCaptor.capture()))
51+
.thenReturn(mockedExecutor);
4252
when(mockedResponse.getBody(any(TypeReference.class)))
43-
.thenReturn(responseMap);
44-
45-
Map<String, Object> result = GitHubCreatePullRequestAction
46-
.perform(mockedParameters, mockedParameters, mockedContext);
47-
48-
assertEquals(responseMap, result);
53+
.thenReturn(Map.of());
4954

50-
Context.Http.Body body = bodyArgumentCaptor.getValue();
55+
Object result = executePerformFunction(GitHubCreatePullRequestAction.ACTION_DEFINITION, mockedParameters);
5156

52-
assertEquals(parameterMap, body.getContent());
57+
assertEquals(Map.of(), result);
58+
assertEquals("/repos/testOwner/testRepo/pulls", stringArgumentCaptor.getValue());
59+
assertEquals(
60+
Http.Body.of(
61+
Map.of(TITLE, "name", HEAD, "feat/123", HEAD_REPO, "head-repo", BASE, "master", BODY, "description"),
62+
Http.BodyContentType.JSON),
63+
bodyArgumentCaptor.getValue());
5364
}
5465
}

0 commit comments

Comments
 (0)