mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-02 10:23:51 +00:00
Merge branch 'master' into bug2589
This commit is contained in:
commit
e847162312
10 files changed
+20
-203
No files matched your search
-32
@@ -42,38 +42,6 @@ public interface EventBase extends Named, WithDescription, Renamable, WithID, Wi
|
||||
|
||||
void setPublic(boolean isPublic);
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Returns a non-<code>null</code> live but unmodifiable collection of URLs pointing to image resources that can be
|
||||
* used to represent the event, e.g., on a web page.
|
||||
*
|
||||
* @return a non-<code>null</code> value which may be empty
|
||||
*/
|
||||
Iterable<URL> getImageURLs();
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* An event may have zero or more sponsors, each of which usually want to see their logo on the web page.
|
||||
*
|
||||
* @return the sponsors' logos; always non-<code>null</code> but possibly empty
|
||||
*/
|
||||
Iterable<URL> getSponsorImageURLs();
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* An optional logo image; may return <code>null</code>.
|
||||
*/
|
||||
URL getLogoImageURL();
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Returns a non-<code>null</code> live but unmodifiable collection of URLs pointing to video resources that can be
|
||||
* used to represent the event, e.g., on a web page.
|
||||
*
|
||||
* @return a non-<code>null</code> value which may be empty
|
||||
*/
|
||||
Iterable<URL> getVideoURLs();
|
||||
|
||||
/**
|
||||
* @return the URL of the event's official web site, or <code>null</code> if such a site does not exist or its URL
|
||||
* is not known
|
||||
|
||||
-39
@@ -140,45 +140,6 @@ public abstract class EventBaseImpl implements EventBase {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<URL> getImageURLs() {
|
||||
List<URL> result = new ArrayList<URL>();
|
||||
for (ImageDescriptor image : images) {
|
||||
if (!image.hasTag(MediaTagConstants.SPONSOR) && !image.hasTag(MediaTagConstants.LOGO)) {
|
||||
result.add(image.getURL());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<URL> getVideoURLs() {
|
||||
List<URL> result = new ArrayList<URL>();
|
||||
for(VideoDescriptor video: videos) {
|
||||
result.add(video.getURL());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<URL> getSponsorImageURLs() {
|
||||
List<URL> result = new ArrayList<URL>();
|
||||
for(MediaDescriptor media : findMediaWithTag(images, MediaTagConstants.SPONSOR)) {
|
||||
result.add(media.getURL());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getLogoImageURL() {
|
||||
URL result = null;
|
||||
ImageDescriptor media = findImageWithTag(MediaTagConstants.LOGO);
|
||||
if(media != null) {
|
||||
result = media.getURL();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getOfficialWebsiteURL() {
|
||||
return officialWebsiteURL;
|
||||
|
||||
+3
-4
@@ -328,7 +328,6 @@ public class TestStoringAndLoadingEventsAndRegattas extends AbstractMongoDBTest
|
||||
assertEquals(3, Util.size(loadedVideo1.getTags()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
/**
|
||||
* We expected that the migration code creates also an image URL for each image we create.
|
||||
@@ -365,9 +364,9 @@ public class TestStoringAndLoadingEventsAndRegattas extends AbstractMongoDBTest
|
||||
final Event loadedEvent = dof.loadEvent(eventName);
|
||||
assertEquals(2, Util.size(loadedEvent.getImages()));
|
||||
assertEquals(1, Util.size(loadedEvent.getVideos()));
|
||||
assertEquals(1, Util.size(loadedEvent.getImageURLs()));
|
||||
assertEquals(1, Util.size(loadedEvent.getSponsorImageURLs()));
|
||||
assertEquals(1, Util.size(loadedEvent.getVideoURLs()));
|
||||
assertEquals(1, Util.size(loadedEvent.findImagesWithTag(MediaTagConstants.GALLERY)));
|
||||
assertEquals(1, Util.size(loadedEvent.findImagesWithTag(MediaTagConstants.SPONSOR)));
|
||||
assertEquals(1, Util.size(loadedEvent.getVideos()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
-78
@@ -3,10 +3,8 @@ package com.sap.sailing.server.gateway.deserialization.impl;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
@@ -16,14 +14,11 @@ import com.sap.sailing.domain.base.EventBase;
|
||||
import com.sap.sailing.domain.base.LeaderboardGroupBase;
|
||||
import com.sap.sailing.domain.base.Venue;
|
||||
import com.sap.sailing.domain.base.impl.StrippedEventImpl;
|
||||
import com.sap.sailing.domain.common.impl.ImageSizeImpl;
|
||||
import com.sap.sailing.server.gateway.deserialization.JsonDeserializationException;
|
||||
import com.sap.sailing.server.gateway.deserialization.JsonDeserializer;
|
||||
import com.sap.sailing.server.gateway.serialization.impl.EventBaseJsonSerializer;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.Util;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
import com.sap.sse.common.media.ImageSize;
|
||||
import com.sap.sse.common.media.MimeType;
|
||||
import com.sap.sse.shared.media.ImageDescriptor;
|
||||
import com.sap.sse.shared.media.VideoDescriptor;
|
||||
@@ -88,10 +83,6 @@ public class EventBaseJsonDeserializer implements JsonDeserializer<EventBase> {
|
||||
}
|
||||
}
|
||||
}
|
||||
// if we read an event with data in the old image/video format we need migrate them
|
||||
if(Util.size(result.getImages()) == 0 && Util.size(result.getVideos()) == 0) {
|
||||
readImageAndVideoURLsFromLegacyServer(eventJson, result);
|
||||
}
|
||||
JSONArray sailorsInfoWebsiteURLsJson = (JSONArray) eventJson.get(EventBaseJsonSerializer.FIELD_SAILORS_INFO_WEBSITE_URLS);
|
||||
if (sailorsInfoWebsiteURLsJson != null) {
|
||||
for (Object sailorsInfoWebsiteURLJson : sailorsInfoWebsiteURLsJson) {
|
||||
@@ -101,67 +92,8 @@ public class EventBaseJsonDeserializer implements JsonDeserializer<EventBase> {
|
||||
result.setSailorsInfoWebsiteURL(localeString == null ? null : new Locale(localeString), Helpers.getURLField(sailorsInfoWebsiteURLJsonObject, EventBaseJsonSerializer.FIELD_URL));
|
||||
}
|
||||
}
|
||||
URL sailorsInfoWebsiteURL = Helpers.getURLField(eventJson, EventBaseJsonSerializer.FIELD_SAILORS_INFO_WEBSITE_URL);
|
||||
if (sailorsInfoWebsiteURL != null && !result.hasSailorsInfoWebsiteURL(null)) {
|
||||
result.setSailorsInfoWebsiteURL(null, sailorsInfoWebsiteURL);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void readImageAndVideoURLsFromLegacyServer(JSONObject eventJson, StrippedEventImpl event) throws JsonDeserializationException {
|
||||
URL logoImageURL = null;
|
||||
List<URL> imageURLs = new ArrayList<URL>();
|
||||
List<URL> sponsorImageURLs = new ArrayList<URL>();
|
||||
List<URL> videoURLs = new ArrayList<URL>();
|
||||
|
||||
String logoImageURLAsString = (String) eventJson.get(EventBaseJsonSerializer.FIELD_LOGO_IMAGE_URL);
|
||||
if (logoImageURLAsString != null) {
|
||||
try {
|
||||
logoImageURL = new URL(logoImageURLAsString);
|
||||
} catch (MalformedURLException e) {
|
||||
throw new JsonDeserializationException("Error deserializing logo image URL for event "+event.getName(), e);
|
||||
}
|
||||
}
|
||||
if (eventJson.get(EventBaseJsonSerializer.FIELD_IMAGE_URLS) != null) {
|
||||
try {
|
||||
imageURLs = getURLsFromStrings(Helpers.getNestedArraySafe(eventJson, EventBaseJsonSerializer.FIELD_IMAGE_URLS));
|
||||
} catch (MalformedURLException e) {
|
||||
throw new JsonDeserializationException("Error deserializing image URLs for event "+event.getName(), e);
|
||||
}
|
||||
}
|
||||
if (eventJson.get(EventBaseJsonSerializer.FIELD_VIDEO_URLS) != null) {
|
||||
try {
|
||||
videoURLs = getURLsFromStrings(Helpers.getNestedArraySafe(eventJson, EventBaseJsonSerializer.FIELD_VIDEO_URLS));
|
||||
} catch (MalformedURLException e) {
|
||||
throw new JsonDeserializationException("Error deserializing video URLs for event "+event.getName(), e);
|
||||
}
|
||||
}
|
||||
if (eventJson.get(EventBaseJsonSerializer.FIELD_SPONSOR_IMAGE_URLS) != null) {
|
||||
try {
|
||||
sponsorImageURLs = getURLsFromStrings(Helpers.getNestedArraySafe(eventJson, EventBaseJsonSerializer.FIELD_SPONSOR_IMAGE_URLS));
|
||||
} catch (MalformedURLException e) {
|
||||
throw new JsonDeserializationException("Error deserializing sponsor image URLs for event "+event.getName(), e);
|
||||
}
|
||||
}
|
||||
// handle images sizes coming from an old server instance not having images and videos in the rich format
|
||||
Map<URL, ImageSize> imageSizes = new HashMap<URL, ImageSize>();;
|
||||
JSONArray imageSizesJson = (JSONArray) eventJson.get(EventBaseJsonSerializer.FIELD_IMAGE_SIZES);
|
||||
if (imageSizesJson != null) {
|
||||
for (Object imageURLAndSizeObject : imageSizesJson) {
|
||||
JSONObject imageURLAndSizeJson = (JSONObject) imageURLAndSizeObject;
|
||||
try {
|
||||
imageSizes.put(
|
||||
new URL((String) imageURLAndSizeJson.get(EventBaseJsonSerializer.FIELD_IMAGE_URL)),
|
||||
new ImageSizeImpl(
|
||||
((Number) imageURLAndSizeJson.get(EventBaseJsonSerializer.FIELD_IMAGE_WIDTH)).intValue(),
|
||||
((Number) imageURLAndSizeJson.get(EventBaseJsonSerializer.FIELD_IMAGE_HEIGHT)).intValue()));
|
||||
} catch (MalformedURLException e) {
|
||||
throw new JsonDeserializationException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
event.setMediaURLs(imageURLs, sponsorImageURLs, videoURLs, logoImageURL, imageSizes);
|
||||
}
|
||||
|
||||
private ImageDescriptor loadImage(JSONObject imageJson) {
|
||||
ImageDescriptor image = null;
|
||||
@@ -231,14 +163,4 @@ public class EventBaseJsonDeserializer implements JsonDeserializer<EventBase> {
|
||||
}
|
||||
return video;
|
||||
}
|
||||
|
||||
private List<URL> getURLsFromStrings(JSONArray strings) throws MalformedURLException {
|
||||
List<URL> result = new ArrayList<URL>();
|
||||
if (strings != null) {
|
||||
for (Object string : strings) {
|
||||
result.add(new URL(string.toString()));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
-18
@@ -21,17 +21,12 @@ public class EventBaseJsonSerializer implements JsonSerializer<EventBase> {
|
||||
public static final String FIELD_START_DATE = "startDate";
|
||||
public static final String FIELD_END_DATE = "endDate";
|
||||
public static final String FIELD_VENUE = "venue";
|
||||
public static final String FIELD_IMAGE_URLS = "imageURLs";
|
||||
public static final String FIELD_VIDEO_URLS = "videoURLs";
|
||||
public static final String FIELD_SPONSOR_IMAGE_URLS = "sponsorImageURLs";
|
||||
public static final String FIELD_LOGO_IMAGE_URL = "logoImageURL";
|
||||
public static final String FIELD_IMAGE_SIZES = "imageSizes";
|
||||
public static final String FIELD_IMAGE_URL = "imageURL";
|
||||
public static final String FIELD_IMAGE_WIDTH = "imageWidth";
|
||||
public static final String FIELD_IMAGE_HEIGHT = "imageHeight";
|
||||
public static final String FIELD_VIDEO_URL = "videoURL";
|
||||
public static final String FIELD_OFFICIAL_WEBSITE_URL = "officialWebsiteURL";
|
||||
public static final String FIELD_SAILORS_INFO_WEBSITE_URL = "sailorsInfoWebsiteURL";
|
||||
public static final String FIELD_SAILORS_INFO_WEBSITE_URLS = "sailorsInfoWebsiteURLs";
|
||||
public static final String FIELDS_LEADERBOARD_GROUPS = "leaderboardGroups";
|
||||
|
||||
@@ -62,7 +57,6 @@ public class EventBaseJsonSerializer implements JsonSerializer<EventBase> {
|
||||
this.venueSerializer = venueSerializer;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public JSONObject serialize(EventBase event) {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put(FIELD_ID, event.getId().toString());
|
||||
@@ -72,10 +66,6 @@ public class EventBaseJsonSerializer implements JsonSerializer<EventBase> {
|
||||
result.put(FIELD_START_DATE, event.getStartDate() != null ? event.getStartDate().asMillis() : null);
|
||||
result.put(FIELD_END_DATE, event.getStartDate() != null ? event.getEndDate().asMillis() : null);
|
||||
result.put(FIELD_VENUE, venueSerializer.serialize(event.getVenue()));
|
||||
result.put(FIELD_LOGO_IMAGE_URL, event.getLogoImageURL() != null ? event.getLogoImageURL().toString() : null);
|
||||
result.put(FIELD_IMAGE_URLS, getURLsAsStringArray(event.getImageURLs()));
|
||||
result.put(FIELD_VIDEO_URLS, getURLsAsStringArray(event.getVideoURLs()));
|
||||
result.put(FIELD_SPONSOR_IMAGE_URLS, getURLsAsStringArray(event.getSponsorImageURLs()));
|
||||
JSONArray leaderboardGroups = new JSONArray();
|
||||
result.put(FIELDS_LEADERBOARD_GROUPS, leaderboardGroups);
|
||||
for (LeaderboardGroupBase lg : event.getLeaderboardGroups()) {
|
||||
@@ -158,14 +148,6 @@ public class EventBaseJsonSerializer implements JsonSerializer<EventBase> {
|
||||
}
|
||||
}
|
||||
|
||||
private JSONArray getURLsAsStringArray(Iterable<URL> urls) {
|
||||
JSONArray jsonImageURLs = new JSONArray();
|
||||
for (URL url : urls) {
|
||||
jsonImageURLs.add(url.toString());
|
||||
}
|
||||
return jsonImageURLs;
|
||||
}
|
||||
|
||||
private void addSailorsInfoWebsiteURL(Locale locale, URL url, JSONArray jsonSailorsInfoWebsiteURLs) {
|
||||
JSONObject jsonSailorsInfoWebsiteURL = new JSONObject();
|
||||
// TODO use toLanguageTag() when deserializer can use Locale.forLanguageTag()
|
||||
|
||||
+8
-9
@@ -34,9 +34,11 @@ import com.sap.sailing.server.gateway.serialization.impl.EventBaseJsonSerializer
|
||||
import com.sap.sailing.server.gateway.serialization.impl.LeaderboardGroupBaseJsonSerializer;
|
||||
import com.sap.sailing.server.gateway.serialization.impl.VenueJsonSerializer;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.Util;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
import com.sap.sse.shared.media.ImageDescriptor;
|
||||
import com.sap.sse.shared.media.VideoDescriptor;
|
||||
import com.sap.sse.shared.media.impl.ImageDescriptorImpl;
|
||||
|
||||
public class EventDataJsonSerializerTest {
|
||||
protected final UUID expectedId = UUID.randomUUID();
|
||||
@@ -48,6 +50,7 @@ public class EventDataJsonSerializerTest {
|
||||
protected final URL expectedOfficialWebsiteURL;
|
||||
protected final Map<Locale, URL> expectedSailorsInfoWebsiteURLs;
|
||||
protected final URL expectedLogoImageURL;
|
||||
protected final ImageDescriptor expectedLogoImageDescriptor;
|
||||
protected final LeaderboardGroup expectedLeaderboardGroup = mock(LeaderboardGroup.class);
|
||||
|
||||
protected JsonSerializer<Venue> venueSerializer;
|
||||
@@ -58,13 +61,13 @@ public class EventDataJsonSerializerTest {
|
||||
public EventDataJsonSerializerTest() throws MalformedURLException {
|
||||
expectedOfficialWebsiteURL = new URL("http://official.website.com");
|
||||
expectedLogoImageURL = new URL("http://official.logo.com/logo.png");
|
||||
expectedLogoImageDescriptor = new ImageDescriptorImpl(expectedLogoImageURL, MillisecondsTimePoint.now());
|
||||
expectedSailorsInfoWebsiteURLs = new HashMap<>();
|
||||
expectedSailorsInfoWebsiteURLs.put(null, new URL("http://sailorinfo.some-sailing-event.com"));
|
||||
expectedSailorsInfoWebsiteURLs.put(Locale.GERMAN, new URL("http://sailorinfo-de.some-sailing-event.com"));
|
||||
}
|
||||
|
||||
// see https://groups.google.com/forum/?fromgroups=#!topic/mockito/iMumB0_bpdo
|
||||
@SuppressWarnings("deprecation")
|
||||
@Before
|
||||
public void setUp() {
|
||||
// Event and its basic attributes ...
|
||||
@@ -75,14 +78,11 @@ public class EventDataJsonSerializerTest {
|
||||
when(event.getOfficialWebsiteURL()).thenReturn(expectedOfficialWebsiteURL);
|
||||
when(event.getSailorsInfoWebsiteURLs()).thenReturn(expectedSailorsInfoWebsiteURLs);
|
||||
when(event.getSailorsInfoWebsiteURL(null)).thenReturn(expectedSailorsInfoWebsiteURLs.get(null));
|
||||
when(event.getLogoImageURL()).thenReturn(expectedLogoImageURL);
|
||||
when(event.getStartDate()).thenReturn(expectedStartDate);
|
||||
when(event.getEndDate()).thenReturn(expectedEndDate);
|
||||
when(event.getVenue()).thenReturn(expectedVenue);
|
||||
when(event.getImageURLs()).thenReturn(Collections.<URL>emptySet());
|
||||
when(event.getVideoURLs()).thenReturn(Collections.<URL>emptySet());
|
||||
when(event.getSponsorImageURLs()).thenReturn(Collections.<URL>emptySet());
|
||||
when(event.getImages()).thenReturn(Collections.<ImageDescriptor>emptySet());
|
||||
when(event.getVideos()).thenReturn(Collections.<VideoDescriptor>emptySet());
|
||||
when(event.getImages()).thenReturn(Collections.<ImageDescriptor>singleton(expectedLogoImageDescriptor));
|
||||
when(event.getVideos()).thenReturn(Collections.<VideoDescriptor>emptySet());
|
||||
// ... and the serializer itself.
|
||||
serializer = new EventBaseJsonSerializer(new VenueJsonSerializer(new CourseAreaJsonSerializer()), new LeaderboardGroupBaseJsonSerializer());
|
||||
@@ -111,9 +111,6 @@ public class EventDataJsonSerializerTest {
|
||||
assertEquals(
|
||||
expectedOfficialWebsiteURL,
|
||||
new URL((String) result.get(EventBaseJsonSerializer.FIELD_OFFICIAL_WEBSITE_URL)));
|
||||
assertEquals(
|
||||
expectedLogoImageURL,
|
||||
new URL((String) result.get(EventBaseJsonSerializer.FIELD_LOGO_IMAGE_URL)));
|
||||
assertEquals(
|
||||
expectedDescription,
|
||||
result.get(EventBaseJsonSerializer.FIELD_DESCRIPTION));
|
||||
@@ -139,6 +136,8 @@ public class EventDataJsonSerializerTest {
|
||||
assertEquals(expectedLeaderboardGroup.getId(), deserializedEvent.getLeaderboardGroups().iterator().next().getId());
|
||||
assertEquals(expectedLeaderboardGroup.hasOverallLeaderboard(), deserializedEvent.getLeaderboardGroups().iterator().next().hasOverallLeaderboard());
|
||||
assertEquals(expectedSailorsInfoWebsiteURLs, new HashMap<Locale, URL>(deserializedEvent.getSailorsInfoWebsiteURLs()));
|
||||
assertEquals(1, Util.size(deserializedEvent.getImages()));
|
||||
assertEquals(expectedLogoImageURL, deserializedEvent.getImages().iterator().next().getURL());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
-4
@@ -105,7 +105,6 @@ public class EventDataJsonSerializerWithImagesAndVideosTest {
|
||||
videos.add(video1);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Before
|
||||
public void setUp() {
|
||||
// Event and its basic attributes ...
|
||||
@@ -115,9 +114,6 @@ public class EventDataJsonSerializerWithImagesAndVideosTest {
|
||||
when(event.getStartDate()).thenReturn(expectedStartDate);
|
||||
when(event.getEndDate()).thenReturn(expectedEndDate);
|
||||
when(event.getVenue()).thenReturn(expectedVenue);
|
||||
when(event.getImageURLs()).thenReturn(Collections.<URL>emptySet());
|
||||
when(event.getVideoURLs()).thenReturn(Collections.<URL>emptySet());
|
||||
when(event.getSponsorImageURLs()).thenReturn(Collections.<URL>emptySet());
|
||||
when(event.getImages()).thenReturn(images);
|
||||
when(event.getVideos()).thenReturn(videos);
|
||||
// ... and the serializer itself.
|
||||
|
||||
-9
@@ -43,7 +43,6 @@ public class EventDataJsonSerializerWithNullValuesTest {
|
||||
protected final TimePoint expectedEndDate = new MillisecondsTimePoint(new Date());
|
||||
protected final Venue expectedVenue = new VenueImpl("Expected Venue");
|
||||
protected final URL expectedOfficialWebsiteURL = null;
|
||||
protected final URL expectedLogoImageURL = null;
|
||||
protected final LeaderboardGroup expectedLeaderbaordGroup = mock(LeaderboardGroup.class);
|
||||
|
||||
protected JsonSerializer<Venue> venueSerializer;
|
||||
@@ -52,7 +51,6 @@ public class EventDataJsonSerializerWithNullValuesTest {
|
||||
protected EventBase event;
|
||||
|
||||
// see https://groups.google.com/forum/?fromgroups=#!topic/mockito/iMumB0_bpdo
|
||||
@SuppressWarnings("deprecation")
|
||||
@Before
|
||||
public void setUp() {
|
||||
// Event and its basic attributes ...
|
||||
@@ -61,13 +59,9 @@ public class EventDataJsonSerializerWithNullValuesTest {
|
||||
when(event.getName()).thenReturn(expectedName);
|
||||
when(event.getDescription()).thenReturn(expectedDescription);
|
||||
when(event.getOfficialWebsiteURL()).thenReturn(expectedOfficialWebsiteURL);
|
||||
when(event.getLogoImageURL()).thenReturn(expectedLogoImageURL);
|
||||
when(event.getStartDate()).thenReturn(expectedStartDate);
|
||||
when(event.getEndDate()).thenReturn(expectedEndDate);
|
||||
when(event.getVenue()).thenReturn(expectedVenue);
|
||||
when(event.getImageURLs()).thenReturn(Collections.<URL>emptySet());
|
||||
when(event.getVideoURLs()).thenReturn(Collections.<URL>emptySet());
|
||||
when(event.getSponsorImageURLs()).thenReturn(Collections.<URL>emptySet());
|
||||
when(event.getImages()).thenReturn(Collections.<ImageDescriptor>emptySet());
|
||||
when(event.getVideos()).thenReturn(Collections.<VideoDescriptor>emptySet());
|
||||
// ... and the serializer itself.
|
||||
@@ -93,9 +87,6 @@ public class EventDataJsonSerializerWithNullValuesTest {
|
||||
assertEquals(expectedOfficialWebsiteURL,
|
||||
result.get(EventBaseJsonSerializer.FIELD_OFFICIAL_WEBSITE_URL) == null ? null :
|
||||
new URL((String) result.get(EventBaseJsonSerializer.FIELD_OFFICIAL_WEBSITE_URL)));
|
||||
assertEquals(expectedLogoImageURL,
|
||||
result.get(EventBaseJsonSerializer.FIELD_LOGO_IMAGE_URL) == null ? null :
|
||||
new URL((String) result.get(EventBaseJsonSerializer.FIELD_LOGO_IMAGE_URL)));
|
||||
assertEquals(expectedDescription,
|
||||
result.get(EventBaseJsonSerializer.FIELD_DESCRIPTION));
|
||||
assertEquals(expectedStartDate,
|
||||
|
||||
+8
-8
@@ -31,8 +31,11 @@ import com.sap.sailing.server.gateway.serialization.impl.EventBaseJsonSerializer
|
||||
import com.sap.sailing.server.gateway.serialization.impl.LeaderboardGroupBaseJsonSerializer;
|
||||
import com.sap.sailing.server.gateway.serialization.impl.VenueJsonSerializer;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.Util;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
import com.sap.sse.shared.media.ImageDescriptor;
|
||||
import com.sap.sse.shared.media.VideoDescriptor;
|
||||
import com.sap.sse.shared.media.impl.ImageDescriptorImpl;
|
||||
|
||||
public class EventWithNullStartAndEndDataJsonSerializerTest {
|
||||
|
||||
@@ -44,6 +47,7 @@ public class EventWithNullStartAndEndDataJsonSerializerTest {
|
||||
protected final Venue expectedVenue = new VenueImpl("Expected Venue");
|
||||
protected final URL expectedOfficialWebsiteURL;
|
||||
protected final URL expectedLogoImageURL;
|
||||
protected final ImageDescriptor expectedLogoImageDescriptor;
|
||||
protected final LeaderboardGroupBase expectedLeaderboardGroup = mock(LeaderboardGroupBase.class);
|
||||
protected final Iterable<LeaderboardGroupBase> expectedLeaderboardGroups = Collections.singleton(expectedLeaderboardGroup);
|
||||
|
||||
@@ -55,9 +59,9 @@ public class EventWithNullStartAndEndDataJsonSerializerTest {
|
||||
public EventWithNullStartAndEndDataJsonSerializerTest() throws MalformedURLException {
|
||||
expectedOfficialWebsiteURL = new URL("http://official.website.com");
|
||||
expectedLogoImageURL = new URL("http://official.logo.com/logo.png");
|
||||
expectedLogoImageDescriptor = new ImageDescriptorImpl(expectedLogoImageURL, MillisecondsTimePoint.now());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Before
|
||||
public void setUp() {
|
||||
// Event and its basic attributes ...
|
||||
@@ -70,14 +74,10 @@ public class EventWithNullStartAndEndDataJsonSerializerTest {
|
||||
when(event.getName()).thenReturn(expectedName);
|
||||
when(event.getDescription()).thenReturn(expectedDescription);
|
||||
when(event.getOfficialWebsiteURL()).thenReturn(expectedOfficialWebsiteURL);
|
||||
when(event.getLogoImageURL()).thenReturn(expectedLogoImageURL);
|
||||
when(event.getStartDate()).thenReturn(expectedStartDate);
|
||||
when(event.getEndDate()).thenReturn(expectedEndDate);
|
||||
when(event.getVenue()).thenReturn(expectedVenue);
|
||||
when(event.getImageURLs()).thenReturn(Collections.<URL>emptySet());
|
||||
when(event.getVideoURLs()).thenReturn(Collections.<URL>emptySet());
|
||||
when(event.getSponsorImageURLs()).thenReturn(Collections.<URL>emptySet());
|
||||
when(event.getImages()).thenReturn(Collections.<ImageDescriptor>emptySet());
|
||||
when(event.getImages()).thenReturn(Collections.<ImageDescriptor>singleton(expectedLogoImageDescriptor));
|
||||
when(event.getVideos()).thenReturn(Collections.<VideoDescriptor>emptySet());
|
||||
doReturn(expectedLeaderboardGroups).when(event).getLeaderboardGroups();
|
||||
|
||||
@@ -96,7 +96,6 @@ public class EventWithNullStartAndEndDataJsonSerializerTest {
|
||||
assertNull(result.get(EventBaseJsonSerializer.FIELD_END_DATE));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testBasicAttributesAfterDeserialization() throws JsonDeserializationException {
|
||||
final JSONObject result = serializer.serialize(event);
|
||||
@@ -105,7 +104,8 @@ public class EventWithNullStartAndEndDataJsonSerializerTest {
|
||||
assertEquals(expectedName, deserializedEvent.getName());
|
||||
assertEquals(expectedDescription, deserializedEvent.getDescription());
|
||||
assertEquals(expectedOfficialWebsiteURL, deserializedEvent.getOfficialWebsiteURL());
|
||||
assertEquals(expectedLogoImageURL, deserializedEvent.getLogoImageURL());
|
||||
assertEquals(1, Util.size(deserializedEvent.getImages()));
|
||||
assertEquals(expectedLogoImageURL, deserializedEvent.getImages().iterator().next().getURL());
|
||||
LeaderboardGroupBase deserializedLg = deserializedEvent.getLeaderboardGroups().iterator().next();
|
||||
assertEquals(expectedLeaderboardGroup.getName(), deserializedLg.getName());
|
||||
assertEquals(expectedLeaderboardGroup.getDescription(), deserializedLg.getDescription());
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
package com.sap.sse.gwt.client.controls.busyindicator;
|
||||
|
||||
import com.google.gwt.dom.client.Style.Visibility;
|
||||
import com.google.gwt.resources.client.ImageResource;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
|
||||
@@ -51,6 +50,6 @@ public class SimpleBusyIndicator extends BusyIndicator {
|
||||
@Override
|
||||
public void setBusy(boolean busy) {
|
||||
super.setBusy(busy);
|
||||
busyIndicator.getElement().getStyle().setVisibility(busy ? Visibility.VISIBLE : Visibility.HIDDEN);
|
||||
busyIndicator.setVisible(busy);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user