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; ...@@ -5,7 +5,9 @@ import static org.gitlab4j.api.JsonUtils.compareJson;
import static org.gitlab4j.api.JsonUtils.readTreeFromResource; import static org.gitlab4j.api.JsonUtils.readTreeFromResource;
import static org.gitlab4j.api.JsonUtils.unmarshalResource; import static org.gitlab4j.api.JsonUtils.unmarshalResource;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
...@@ -23,7 +25,7 @@ import org.gitlab4j.api.systemhooks.SystemHookListener; ...@@ -23,7 +25,7 @@ import org.gitlab4j.api.systemhooks.SystemHookListener;
import org.gitlab4j.api.systemhooks.SystemHookManager; import org.gitlab4j.api.systemhooks.SystemHookManager;
import org.gitlab4j.api.systemhooks.TeamMemberSystemHookEvent; import org.gitlab4j.api.systemhooks.TeamMemberSystemHookEvent;
import org.gitlab4j.api.utils.JacksonJson; 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.Event;
import org.gitlab4j.api.webhook.IssueEvent; import org.gitlab4j.api.webhook.IssueEvent;
import org.gitlab4j.api.webhook.JobEvent; import org.gitlab4j.api.webhook.JobEvent;
...@@ -65,17 +67,56 @@ public class TestGitLabApiEvents { ...@@ -65,17 +67,56 @@ public class TestGitLabApiEvents {
@Test @Test
public void testIssueEvent() throws Exception { 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")); 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 @Test
public void testMergeRequestEvent() throws Exception { 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")); 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 @Test
public void testPipelineEvent() throws Exception { public void testPipelineEvent() throws Exception {
Event event = unmarshalResource(PipelineEvent.class, "pipeline-event.json"); Event event = unmarshalResource(PipelineEvent.class, "pipeline-event.json");
......
...@@ -57,6 +57,10 @@ ...@@ -57,6 +57,10 @@
"previous": "2020-06-01T08:00:00Z", "previous": "2020-06-01T08:00:00Z",
"current": "2020-02-04T08:00:00Z" "current": "2020-02-04T08:00:00Z"
}, },
"confidential": {
"previous": false,
"current": true
},
"updated_at": { "updated_at": {
"previous":"2019-04-12T01:10:28Z", "previous":"2019-04-12T01:10:28Z",
"current":"2019-04-12T01:11:33Z" "current":"2019-04-12T01:11:33Z"
...@@ -65,13 +69,21 @@ ...@@ -65,13 +69,21 @@
"previous": 2, "previous": 2,
"current": 6 "current": 6
}, },
"id":{
"previous":123,
"current":456
},
"iid":{
"previous":12,
"current":34
},
"milestone_id": { "milestone_id": {
"previous":0, "previous":0,
"current":1 "current":1
}, },
"confidential": { "confidential": {
"previous":true, "previous":false,
"current":false "current":true
}, },
"labels": { "labels": {
"previous": [{ "previous": [{
......
...@@ -104,14 +104,31 @@ ...@@ -104,14 +104,31 @@
"group_id": 41 "group_id": 41
}], }],
"changes": { "changes": {
"author_id": {
"current":2
},
"updated_at": { "updated_at": {
"previous":"2019-04-12T01:10:28Z", "current": "2013-12-03T17:23:34Z"
"current":"2019-04-12T01:11:33Z"
}, },
"updated_by_id": { "updated_by_id": {
"previous": 2, "previous": 2,
"current": 6 "current": 6
}, },
"id":{
"previous":123,
"current":456
},
"iid":{
"previous":12,
"current":34
},
"merge_status": {
"current": "unchecked"
},
"milestone_id": {
"previous":0,
"current":1
},
"labels": { "labels": {
"previous": [{ "previous": [{
"id": 206, "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