Skip to content

Commit

Permalink
Activate FAIL_ON_UNKNOWN_PROPERTIES for tests in JsonUtils (gitlab4j#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jmini authored Feb 10, 2024
1 parent b60c045 commit 80abfca
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

import org.gitlab4j.api.webhook.MergeRequestEvent;

import com.fasterxml.jackson.annotation.JsonIgnore;

public class MergeRequestSystemHookEvent extends MergeRequestEvent implements SystemHookEvent {
private static final long serialVersionUID = 1L;

public static final String X_GITLAB_EVENT = "System Hook";
public static final String MERGE_REQUEST_EVENT = "merge_request";

private String eventType;
private String eventName;

@Override
public String getObjectKind() {
Expand All @@ -17,14 +20,28 @@ public String getObjectKind() {

@Override
public String getEventName() {
return (MERGE_REQUEST_EVENT);
return eventName;
}

public void setEventName(String eventName) {
this.eventName = eventName;
}

public String getEventType() {
return eventType;
}

public void setEventType(String eventType) {
this.eventType = eventType;
}

/**
* @deprecated use {@link #setEventType(String)} instead
* @param eventType
*/
@Deprecated
@JsonIgnore
public void setEvent_type(String eventType) {
this.eventType = eventType;
setEventType(eventType);
}
}
2 changes: 2 additions & 0 deletions src/test/java/org/gitlab4j/api/JsonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.MapperFeature;
Expand All @@ -34,6 +35,7 @@ public class JsonUtils {
jacksonJson = new JacksonJson();
jacksonJson.getObjectMapper().configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
jacksonJson.getObjectMapper().configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
jacksonJson.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
}

static JsonNode readTreeFromMap(Map<String, Object> map) throws JsonParseException, JsonMappingException, IOException {
Expand Down
36 changes: 17 additions & 19 deletions src/test/resources/org/gitlab4j/api/bad-branch.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
{
"commit": {
"id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c",
"parents": [{ "id": "4ad91d3c1144c406e50c7b33bae684bd6837faf8" }],
"tree": "46e82de44b1061621357f24c05515327f2795a95",
"message": "add projects API",
"author": {
"name": "John Smith",
"email": "[email protected]"
},
"committer": {
"name": "John Smith",
"email": "[email protected]"
},
"authored_date": "2012-06-27T12:51:39Z",
"committed_date": "2012-06-28T10:44:20Z"
},
"protected": true
{
"commit": {
"author_email": "[email protected]",
"author_name": "John Smith",
"authored_date": "2012-06-27T05:51:39Z",
"committed_date": "2012-06-28T03:44:20Z",
"committer_email": "[email protected]",
"committer_name": "John Smith",
"id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c",
"short_id": "7b5c3cc",
"title": "add projects API",
"message": "add projects API",
"parent_ids": [
"4ad91d3c1144c406e50c7b33bae684bd6837faf8"
]
},
"protected": true
}

0 comments on commit 80abfca

Please sign in to comment.