mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-24 04:53:54 +00:00
Ported all event related tests to use the new media model
This commit is contained in:
1 parent
83c7e4a197
commit
fdb59c3ca5
5 files changed
+19
-34
No files matched your search
+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()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
+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());
|
||||
|
||||
Reference in new issue
Block a user