Commit 78c3a0c4 authored by Greg Messner's avatar Greg Messner
Browse files

Added tests for other changes and issue and merge request specific changes (#362).

parent 36b888b2
......@@ -5,7 +5,9 @@ import static org.gitlab4j.api.JsonUtils.compareJson;
import static org.gitlab4j.api.JsonUtils.readTreeFromResource;
import static org.gitlab4j.api.JsonUtils.unmarshalResource;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
......@@ -23,7 +25,7 @@ import org.gitlab4j.api.systemhooks.SystemHookListener;
import org.gitlab4j.api.systemhooks.SystemHookManager;
import org.gitlab4j.api.systemhooks.TeamMemberSystemHookEvent;
import org.gitlab4j.api.utils.JacksonJson;
import org.gitlab4j.api.webhook.BuildEvent;
import org.gitlab4j.api.webhook.*;
import org.gitlab4j.api.webhook.Event;
import org.gitlab4j.api.webhook.IssueEvent;
import org.gitlab4j.api.webhook.JobEvent;
......@@ -65,17 +67,56 @@ public class TestGitLabApiEvents {
@Test
public void testIssueEvent() throws Exception {
Event issueEvent = unmarshalResource(IssueEvent.class, "issue-event.json");
IssueEvent issueEvent = unmarshalResource(IssueEvent.class, "issue-event.json");
assertTrue(compareJson(issueEvent, "issue-event.json"));
ChangeContainer<Integer> idChange = issueEvent.getChanges().get("id");
assertNotNull(idChange);
assertEquals(123, (int)idChange.getPrevious());
assertEquals(456, (int)idChange.getCurrent());
}
@Test
public void testIssueChanges() throws Exception {
IssueEvent issueEvent = unmarshalResource(IssueEvent.class, "issue-event.json");
assertNotNull(issueEvent);
ChangeContainer<Integer> idChange = issueEvent.getChanges().get("id");
assertNotNull(idChange);
assertEquals(123, (int)idChange.getPrevious());
assertEquals(456, (int)idChange.getCurrent());
ChangeContainer<Boolean> confidentialChange = issueEvent.getChanges().getConfidential();
assertNotNull(confidentialChange);
assertFalse(confidentialChange.getPrevious());
assertTrue(confidentialChange.getCurrent());
}
@Test
public void testMergeRequestEvent() throws Exception {
Event mergeRequestEvent = unmarshalResource(MergeRequestEvent.class, "merge-request-event.json");
MergeRequestEvent mergeRequestEvent = unmarshalResource(MergeRequestEvent.class, "merge-request-event.json");
assertTrue(compareJson(mergeRequestEvent, "merge-request-event.json"));
}
@Test
public void testMergeRequestEventChanges() throws Exception {
MergeRequestEvent mergeRequestEvent = unmarshalResource(MergeRequestEvent.class, "merge-request-event.json");
assertNotNull(mergeRequestEvent);
ChangeContainer<Integer> iidChange = mergeRequestEvent.getChanges().get("iid");
assertNotNull(iidChange);
assertEquals(12, (int)iidChange.getPrevious());
assertEquals(34, (int)iidChange.getCurrent());
ChangeContainer<String> mergeStatusChangeChange = mergeRequestEvent.getChanges().getMergeStatus();
assertNotNull(mergeStatusChangeChange);
assertNull(mergeStatusChangeChange.getPrevious());
assertEquals("unchecked", mergeStatusChangeChange.getCurrent());
}
@Test
public void testPipelineEvent() throws Exception {
Event event = unmarshalResource(PipelineEvent.class, "pipeline-event.json");
......
......@@ -57,6 +57,10 @@
"previous": "2020-06-01T08:00:00Z",
"current": "2020-02-04T08:00:00Z"
},
"confidential": {
"previous": false,
"current": true
},
"updated_at": {
"previous":"2019-04-12T01:10:28Z",
"current":"2019-04-12T01:11:33Z"
......@@ -65,13 +69,21 @@
"previous": 2,
"current": 6
},
"id":{
"previous":123,
"current":456
},
"iid":{
"previous":12,
"current":34
},
"milestone_id": {
"previous":0,
"current":1
},
"confidential": {
"previous":true,
"current":false
"previous":false,
"current":true
},
"labels": {
"previous": [{
......
......@@ -104,14 +104,31 @@
"group_id": 41
}],
"changes": {
"author_id": {
"current":2
},
"updated_at": {
"previous":"2019-04-12T01:10:28Z",
"current":"2019-04-12T01:11:33Z"
"current": "2013-12-03T17:23:34Z"
},
"updated_by_id": {
"previous": 2,
"current": 6
},
"id":{
"previous":123,
"current":456
},
"iid":{
"previous":12,
"current":34
},
"merge_status": {
"current": "unchecked"
},
"milestone_id": {
"previous":0,
"current":1
},
"labels": {
"previous": [{
"id": 206,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment