Refactor EndUser to serialize locale

This commit is contained in:
davioooh 2018-04-30 15:39:32 +02:00
parent 9f1aa6664f
commit 16fa704a17
2 changed files with 7 additions and 7 deletions

View File

@ -1,7 +1,6 @@
package org.telegram.abilitybots.api.objects;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
@ -30,7 +29,7 @@ public final class EndUser implements Serializable {
private final String lastName;
@JsonProperty("username")
private final String username;
@JsonIgnore
@JsonProperty("locale")
private Locale locale;
private EndUser(Integer id, String firstName, String lastName, String username, Locale locale) {
@ -45,8 +44,9 @@ public final class EndUser implements Serializable {
public static EndUser endUser(@JsonProperty("id") Integer id,
@JsonProperty("firstName") String firstName,
@JsonProperty("lastName") String lastName,
@JsonProperty("username") String username) {
return new EndUser(id, firstName, lastName, username, null);
@JsonProperty("username") String username,
@JsonProperty("locale") Locale locale) {
return new EndUser(id, firstName, lastName, username, locale);
}
/**

View File

@ -53,8 +53,8 @@ public class AbilityBotTest {
private static final long GROUP_ID = 10L;
private static final String TEST = "test";
private static final String[] TEXT = {TEST};
public static final EndUser MUSER = endUser(1, "first", "last", "username");
public static final EndUser CREATOR = endUser(1337, "creatorFirst", "creatorLast", "creatorUsername");
public static final EndUser MUSER = endUser(1, "first", "last", "username", null);
public static final EndUser CREATOR = endUser(1337, "creatorFirst", "creatorLast", "creatorUsername", null);
private DefaultBot bot;
private DBContext db;
@ -293,7 +293,7 @@ public class AbilityBotTest {
String newFirstName = MUSER.firstName() + "-test";
String newLastName = MUSER.lastName() + "-test";
int sameId = MUSER.id();
EndUser changedUser = endUser(sameId, newFirstName, newLastName, newUsername);
EndUser changedUser = endUser(sameId, newFirstName, newLastName, newUsername, null);
mockAlternateUser(update, message, user, changedUser);