mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-10 06:10:56 +00:00
added LeaderboardGroup.displayName to JSON serialization process
This commit is contained in:
1 parent
0c87e7bca3
commit
2dd99d09ac
8 files changed
+23
-20
No files matched your search
+2
-1
@@ -14,10 +14,11 @@ public abstract class LeaderboardGroupBaseImpl implements LeaderboardGroupBase {
|
||||
private String displayName;
|
||||
private String description;
|
||||
|
||||
public LeaderboardGroupBaseImpl(UUID id, String name, String description) {
|
||||
public LeaderboardGroupBaseImpl(UUID id, String name, String description, String displayName) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@ public class StrippedLeaderboardGroupImpl extends LeaderboardGroupBaseImpl {
|
||||
private static final long serialVersionUID = 7263952130620919924L;
|
||||
private final boolean hasOverallLeaderboard;
|
||||
|
||||
public StrippedLeaderboardGroupImpl(UUID id, String name, String description, boolean hasOverallLeaderboard) {
|
||||
super(id, name, description);
|
||||
public StrippedLeaderboardGroupImpl(UUID id, String name, String description, String displayName, boolean hasOverallLeaderboard) {
|
||||
super(id, name, description, displayName);
|
||||
this.hasOverallLeaderboard = hasOverallLeaderboard;
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -45,8 +45,7 @@ public class LeaderboardGroupImpl extends LeaderboardGroupBaseImpl implements Le
|
||||
*/
|
||||
public LeaderboardGroupImpl(UUID id, String name, String description, String displayName,
|
||||
boolean displayGroupsInReverseOrder, List<? extends Leaderboard> leaderboards) {
|
||||
super(id, name, description);
|
||||
setDisplayName(displayName);
|
||||
super(id, name, description, displayName);
|
||||
this.displayGroupsInReverseOrder = displayGroupsInReverseOrder;
|
||||
this.leaderboards = new ArrayList<Leaderboard>(leaderboards);
|
||||
this.listeners = new HashSet<LeaderboardGroupListener>();
|
||||
|
||||
+12
-10
@@ -42,7 +42,7 @@ public class EventDataJsonSerializerTest {
|
||||
protected final Venue expectedVenue = new VenueImpl("Expected Venue");
|
||||
protected final URL expectedOfficialWebsiteURL;
|
||||
protected final URL expectedLogoImageURL;
|
||||
protected final LeaderboardGroup expectedLeaderbaordGroup = mock(LeaderboardGroup.class);
|
||||
protected final LeaderboardGroup expectedLeaderboardGroup = mock(LeaderboardGroup.class);
|
||||
|
||||
protected JsonSerializer<Venue> venueSerializer;
|
||||
protected EventBaseJsonSerializer serializer;
|
||||
@@ -74,11 +74,12 @@ public class EventDataJsonSerializerTest {
|
||||
serializer = new EventBaseJsonSerializer(new VenueJsonSerializer(new CourseAreaJsonSerializer()), new LeaderboardGroupBaseJsonSerializer());
|
||||
deserializer = new EventBaseJsonDeserializer(new VenueJsonDeserializer(new CourseAreaJsonDeserializer(DomainFactory.INSTANCE)), new LeaderboardGroupBaseJsonDeserializer());
|
||||
|
||||
when(expectedLeaderbaordGroup.getId()).thenReturn(UUID.randomUUID());
|
||||
when(expectedLeaderbaordGroup.getName()).thenReturn("LG");
|
||||
when(expectedLeaderbaordGroup.getDescription()).thenReturn("LG Description");
|
||||
when(expectedLeaderbaordGroup.hasOverallLeaderboard()).thenReturn(false);
|
||||
doReturn(Collections.<LeaderboardGroup>singleton(expectedLeaderbaordGroup)).when(event).getLeaderboardGroups();
|
||||
when(expectedLeaderboardGroup.getId()).thenReturn(UUID.randomUUID());
|
||||
when(expectedLeaderboardGroup.getName()).thenReturn("LG");
|
||||
when(expectedLeaderboardGroup.getDescription()).thenReturn("LG Description");
|
||||
when(expectedLeaderboardGroup.getDisplayName()).thenReturn("LG Display Name");
|
||||
when(expectedLeaderboardGroup.hasOverallLeaderboard()).thenReturn(false);
|
||||
doReturn(Collections.<LeaderboardGroup>singleton(expectedLeaderboardGroup)).when(event).getLeaderboardGroups();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -118,10 +119,11 @@ public class EventDataJsonSerializerTest {
|
||||
assertEquals(expectedName, deserializedEvent.getName());
|
||||
assertEquals(expectedStartDate, deserializedEvent.getStartDate());
|
||||
assertEquals(expectedEndDate, deserializedEvent.getEndDate());
|
||||
assertEquals(expectedLeaderbaordGroup.getName(), deserializedEvent.getLeaderboardGroups().iterator().next().getName());
|
||||
assertEquals(expectedLeaderbaordGroup.getDescription(), deserializedEvent.getLeaderboardGroups().iterator().next().getDescription());
|
||||
assertEquals(expectedLeaderbaordGroup.getId(), deserializedEvent.getLeaderboardGroups().iterator().next().getId());
|
||||
assertEquals(expectedLeaderbaordGroup.hasOverallLeaderboard(), deserializedEvent.getLeaderboardGroups().iterator().next().hasOverallLeaderboard());
|
||||
assertEquals(expectedLeaderboardGroup.getName(), deserializedEvent.getLeaderboardGroups().iterator().next().getName());
|
||||
assertEquals(expectedLeaderboardGroup.getDescription(), deserializedEvent.getLeaderboardGroups().iterator().next().getDescription());
|
||||
assertEquals(expectedLeaderboardGroup.getDisplayName(), deserializedEvent.getLeaderboardGroups().iterator().next().getDisplayName());
|
||||
assertEquals(expectedLeaderboardGroup.getId(), deserializedEvent.getLeaderboardGroups().iterator().next().getId());
|
||||
assertEquals(expectedLeaderboardGroup.hasOverallLeaderboard(), deserializedEvent.getLeaderboardGroups().iterator().next().hasOverallLeaderboard());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+3
-1
@@ -20,8 +20,10 @@ public class LeaderboardGroupBaseJsonDeserializer implements JsonDeserializer<Le
|
||||
UUID id = UUID.fromString((String) object.get(EventBaseJsonSerializer.FIELD_ID));
|
||||
String name = object.get(LeaderboardGroupBaseJsonSerializer.FIELD_NAME).toString();
|
||||
String description = object.get(LeaderboardGroupBaseJsonSerializer.FIELD_DESCRIPTION).toString();
|
||||
String displayName = object.get(LeaderboardGroupBaseJsonSerializer.FIELD_DISPLAY_NAME).toString();
|
||||
String hasOverallLeaderboard = object.get(LeaderboardGroupBaseJsonSerializer.FIELD_HAS_OVERALL_LEADERBOARD).toString();
|
||||
LeaderboardGroupBase result = new StrippedLeaderboardGroupImpl(id, name, description, hasOverallLeaderboard == null ? false : Boolean.valueOf(hasOverallLeaderboard));
|
||||
LeaderboardGroupBase result = new StrippedLeaderboardGroupImpl(id, name, description, displayName,
|
||||
hasOverallLeaderboard == null ? false : Boolean.valueOf(hasOverallLeaderboard));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+2
@@ -9,6 +9,7 @@ public class LeaderboardGroupBaseJsonSerializer implements JsonSerializer<Leader
|
||||
public static final String FIELD_ID = "id";
|
||||
public static final String FIELD_NAME = "name";
|
||||
public static final String FIELD_DESCRIPTION = "description";
|
||||
public static final String FIELD_DISPLAY_NAME = "displayName";
|
||||
public static final String FIELD_HAS_OVERALL_LEADERBOARD = "hasOverallLeaderboard";
|
||||
|
||||
public LeaderboardGroupBaseJsonSerializer() {
|
||||
@@ -19,6 +20,7 @@ public class LeaderboardGroupBaseJsonSerializer implements JsonSerializer<Leader
|
||||
result.put(FIELD_ID, leaderboardGroup.getId().toString());
|
||||
result.put(FIELD_NAME, leaderboardGroup.getName());
|
||||
result.put(FIELD_DESCRIPTION, leaderboardGroup.getDescription());
|
||||
result.put(FIELD_DISPLAY_NAME, leaderboardGroup.getDisplayName());
|
||||
result.put(FIELD_HAS_OVERALL_LEADERBOARD, leaderboardGroup.hasOverallLeaderboard());
|
||||
return result;
|
||||
}
|
||||
|
||||
-4
@@ -74,14 +74,10 @@ public class LeaderboardGroupJsonExportTest extends AbstractJsonExportTest {
|
||||
@Test
|
||||
public void testExportLeaderboardGroupsAsJson() throws Exception {
|
||||
String jsonString = callJsonHttpServlet(new LeaderboardGroupsJsonGetServlet(), "GET", null);
|
||||
|
||||
Object obj = JSONValue.parse(jsonString);
|
||||
JSONArray array = (JSONArray) obj;
|
||||
|
||||
assertTrue(array.size() == 1);
|
||||
|
||||
String jsonFirstLeaderboardGroup = (String) array.get(0);
|
||||
|
||||
assertTrue(leaderboardGroup.getName().equals(jsonFirstLeaderboardGroup));
|
||||
}
|
||||
}
|
||||
+1
@@ -42,6 +42,7 @@ public class LeaderboardGroupJsonGetServlet extends AbstractJsonHttpServlet {
|
||||
JSONObject jsonLeaderboardGroup = new JSONObject();
|
||||
jsonLeaderboardGroup.put("name", leaderboardGroup.getName());
|
||||
jsonLeaderboardGroup.put("description", leaderboardGroup.getDescription());
|
||||
jsonLeaderboardGroup.put("displayName", leaderboardGroup.getDisplayName());
|
||||
jsonLeaderboardGroup.put("timepoint", timePoint.toString());
|
||||
JSONArray jsonLeaderboardEntries = new JSONArray();
|
||||
jsonLeaderboardGroup.put("leaderboards", jsonLeaderboardEntries);
|
||||
|
||||
Reference in new issue
Block a user