Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activate FAIL_ON_UNKNOWN_PROPERTIES for tests in JsonUtils #1089

Merged
merged 4 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}

Loading