Skip to content

Commit

Permalink
#813 - explicitly ignore unknown properties in glific
Browse files Browse the repository at this point in the history
  • Loading branch information
petmongrels committed Nov 6, 2024
1 parent 7740a98 commit 794426c
Show file tree
Hide file tree
Showing 24 changed files with 76 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
Expand All @@ -11,20 +12,21 @@
@JsonPropertyOrder({
"messages"
})
@JsonIgnoreProperties(ignoreUnknown = true)
public class GetAllMessagesData {

@JsonProperty("messages")
private List<Message> messages = new ArrayList<Message>();

/**
* No args constructor for use in serialization
*
*
*/
public GetAllMessagesData() {
}

/**
*
*
* @param messages
*/
public GetAllMessagesData(List<Message> messages) {
Expand All @@ -42,4 +44,4 @@ public void setMessages(List<Message> messages) {
this.messages = messages;
}

}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GlificAuth {
@JsonProperty("access_token")
private String accessToken;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GlificAuthRequest {
private final GlificUser user;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GlificContactGroupContactCountResponse {
private int countContacts;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GlificContactGroupContactsResponse {
private List<GlificContactGroupContacts> contacts;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GlificContactGroupCountResponse {
private int countGroups;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.io.Serializable;
import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GlificContactGroupsResponse {
private List<ContactGroup> groups;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GlificContactResponse {
private String id;
private String name;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GlificCreateContactGroupResponse {
private CreateGroupErrors createGroup;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GlificError {
private List<GlificErrorLocation> locations;
private String message;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GlificErrorLocation {
private int column;
private int row;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GlificGetContactsResponse {
private List<GlificContactResponse> contacts;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GlificGetGroupResponse {
private GlificGroupGroup group;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GlificMessageResponse {
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.io.Serializable;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GlificMessageTemplate implements Serializable {
private String body;
private String id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GlificMessageTemplateResponse {
private List<GlificMessageTemplate> sessionTemplates;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GlificOptinContactResponse {
private GlificOptinContactWithErrorsResponse optinContact;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GlificOptinContactWithErrorsResponse {

private GlificContactResponse contact;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GlificResponse<T> {
private T data;
private List<GlificError> errors;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
Expand All @@ -11,20 +12,21 @@
@JsonPropertyOrder({
"search"
})
@JsonIgnoreProperties(ignoreUnknown = true)
public class GlificSearchDataResponse {

@JsonProperty("search")
private List<Search> search = new ArrayList<Search>();

/**
* No args constructor for use in serialization
*
*
*/
public GlificSearchDataResponse() {
}

/**
*
*
* @param search
*/
public GlificSearchDataResponse(List<Search> search) {
Expand All @@ -42,4 +44,4 @@ public void setSearch(List<Search> search) {
this.search = search;
}

}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.avni.messaging.domain.GlificSystemConfig;
import org.springframework.util.Assert;

import java.io.Serializable;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GlificUser implements Serializable {
private final String phone;
private final String password;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
Expand All @@ -14,6 +15,7 @@
"receiver",
"type"
})
@JsonIgnoreProperties(ignoreUnknown = true)
public class Message {

@JsonProperty("body")
Expand All @@ -33,13 +35,13 @@ public class Message {

/**
* No args constructor for use in serialization
*
*
*/
public Message() {
}

/**
*
*
* @param receiver
* @param insertedAt
* @param sender
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.avni.messaging.contract.glific;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
Expand All @@ -12,6 +13,7 @@
"contact",
"messages"
})
@JsonIgnoreProperties(ignoreUnknown = true)
public class Search {

@JsonProperty("contact")
Expand All @@ -21,13 +23,13 @@ public class Search {

/**
* No args constructor for use in serialization
*
*
*/
public Search() {
}

/**
*
*
* @param contact
* @param messages
*/
Expand Down Expand Up @@ -57,4 +59,4 @@ public void setMessages(List<Message> messages) {
this.messages = messages;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static org.assertj.core.api.Assertions.assertThat;

@Sql(value = {"/tear-down.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = {"/test-data.sql"})
@Sql(value = {"/tear-down.sql"}, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public class GlificRestClientTest extends AbstractControllerIntegrationTest {
private String SAMPLE_AUTH_RESPONSE = "{\"data\":{\"access_token\":\"SFMyNTY.YjQ2M2MzMmMtNGZlOC00OTEyLWIzYTEtZmRhZTRkOGQ1ZTIx.3TjKqpElrD5N2ffGHEAFX91cyp7zwoTztYR8p1jwwgA\",\"renewal_token\":\"SFMyNTY.MjYxODllMTgtNDM1OC00YjJjLTlmN2MtOTA5MzMwYzM3ZjA2.dDigSwftcGFGHu4o9MwkASp2KqH6eitp1aRmeYSgi5M\",\"token_expiry_time\":\"2022-10-13T21:42:33.342529Z\"}}";

Expand Down

0 comments on commit 794426c

Please sign in to comment.