Refactor EndUser to serialize locale
This commit is contained in:
parent
9f1aa6664f
commit
16fa704a17
@ -1,7 +1,6 @@
|
|||||||
package org.telegram.abilitybots.api.objects;
|
package org.telegram.abilitybots.api.objects;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
@ -30,7 +29,7 @@ public final class EndUser implements Serializable {
|
|||||||
private final String lastName;
|
private final String lastName;
|
||||||
@JsonProperty("username")
|
@JsonProperty("username")
|
||||||
private final String username;
|
private final String username;
|
||||||
@JsonIgnore
|
@JsonProperty("locale")
|
||||||
private Locale locale;
|
private Locale locale;
|
||||||
|
|
||||||
private EndUser(Integer id, String firstName, String lastName, String username, 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,
|
public static EndUser endUser(@JsonProperty("id") Integer id,
|
||||||
@JsonProperty("firstName") String firstName,
|
@JsonProperty("firstName") String firstName,
|
||||||
@JsonProperty("lastName") String lastName,
|
@JsonProperty("lastName") String lastName,
|
||||||
@JsonProperty("username") String username) {
|
@JsonProperty("username") String username,
|
||||||
return new EndUser(id, firstName, lastName, username, null);
|
@JsonProperty("locale") Locale locale) {
|
||||||
|
return new EndUser(id, firstName, lastName, username, locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,8 +53,8 @@ public class AbilityBotTest {
|
|||||||
private static final long GROUP_ID = 10L;
|
private static final long GROUP_ID = 10L;
|
||||||
private static final String TEST = "test";
|
private static final String TEST = "test";
|
||||||
private static final String[] TEXT = {TEST};
|
private static final String[] TEXT = {TEST};
|
||||||
public static final EndUser MUSER = endUser(1, "first", "last", "username");
|
public static final EndUser MUSER = endUser(1, "first", "last", "username", null);
|
||||||
public static final EndUser CREATOR = endUser(1337, "creatorFirst", "creatorLast", "creatorUsername");
|
public static final EndUser CREATOR = endUser(1337, "creatorFirst", "creatorLast", "creatorUsername", null);
|
||||||
|
|
||||||
private DefaultBot bot;
|
private DefaultBot bot;
|
||||||
private DBContext db;
|
private DBContext db;
|
||||||
@ -293,7 +293,7 @@ public class AbilityBotTest {
|
|||||||
String newFirstName = MUSER.firstName() + "-test";
|
String newFirstName = MUSER.firstName() + "-test";
|
||||||
String newLastName = MUSER.lastName() + "-test";
|
String newLastName = MUSER.lastName() + "-test";
|
||||||
int sameId = MUSER.id();
|
int sameId = MUSER.id();
|
||||||
EndUser changedUser = endUser(sameId, newFirstName, newLastName, newUsername);
|
EndUser changedUser = endUser(sameId, newFirstName, newLastName, newUsername, null);
|
||||||
|
|
||||||
mockAlternateUser(update, message, user, changedUser);
|
mockAlternateUser(update, message, user, changedUser);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user