Skip to content

Commit

Permalink
2.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
aklevanets committed Oct 17, 2024
1 parent 3309690 commit f9f02a0
Show file tree
Hide file tree
Showing 17 changed files with 426 additions and 221 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
Livedata SDK is a client library that enables easier integration with the Livescout XML feed. SDK exposes XML feed service interface in a more user-friendly way and isolates the client from having to do XML feed parsing, proper connection handling, error recovery, event queuing and dispatching.
It also makes a client solution more stable and robust when it comes to feed handling, especially with the release of new and updated XML feed version.* ScoutFeedType extended with new type - PARTIAL

**2.0.11 (2024-10-18)**
* MatchUpdateEntity fields became nullable:
- subteams
- score
- scores
- events
* MatchUpdateEntity extended with new properties:
- tryCounts
- fouls
* ScoutEventEntity extended with finalConfidence property
* PlayerEntity extended with specificContracts property

**2.0.10 (2024-08-29)**
* New entity - TrackEntity under ScoutEventEntity that stores x,y,z coordinates
* unsubscribe method sends batch request now
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Running "_package_" will run unit tests, generate javadoc and all needed jar fil

### INSTALLATION
Project builds three different jars:
* sdk-2.0.10.jar - only sdk classes, need to upload dependencies from maven.
* sdk-2.0.10-fatjar.jar - stores all needed libraries inside jar.
* sdk-2.0.10-fatjar-shaded.jar - stores all needed libraries inside jar. Libraries are shaded to avoid overwriting by newer versions.
* sdk-2.0.11.jar - only sdk classes, need to upload dependencies from maven.
* sdk-2.0.11-fatjar.jar - stores all needed libraries inside jar.
* sdk-2.0.11-fatjar-shaded.jar - stores all needed libraries inside jar. Libraries are shaded to avoid overwriting by newer versions.
> **_NOTE:_** Despite the availability of original jar, we recommend to use fatjar-shaded to avoid libraries versions incompatibility.
Livedata sdk can be imported from [Maven Central Repository](https://mvnrepository.com/artifact/com.sportradar.livedata.sdk/sdk).
Expand All @@ -25,7 +25,7 @@ Just add the fatjar-shaded dependency to your pom.xml file:
<dependency>
<groupId>com.sportradar.livedata.sdk</groupId>
<artifactId>sdk</artifactId>
<version>2.0.10</version>
<version>2.0.11</version>
<classifier>fatjar-shaded</classifier>
<exclusions>
<exclusion>
Expand All @@ -40,7 +40,7 @@ If you want to manage sdk libraries original jar be used:
<dependency>
<groupId>com.sportradar.livedata.sdk</groupId>
<artifactId>sdk</artifactId>
<version>2.0.10</version>
<version>2.0.11</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
</profiles>

<properties>
<revision>2.0.10</revision>
<revision>2.0.11</revision>

<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>

Expand Down
2 changes: 1 addition & 1 deletion sdk-jar-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>

<sdk.version>2.0.6-2</sdk.version>
<sdk.version>2.0.11</sdk.version>
</properties>

<build>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package com.sportradar.livedata.sdk.common.classes;

import com.sportradar.livedata.sdk.feed.common.exceptions.InvalidEntityException;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.Duration;
import org.joda.time.format.ISODateTimeFormat;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class CommonUtilsTest {

@Test
void testFromTimestampWithDefaultZone() {
long unixTimestamp = 1609459200000L; // 2021-01-01T00:00:00Z
DateTime dateTime = CommonUtils.fromTimestamp(unixTimestamp);
assertNotNull(dateTime);
assertEquals(DateTimeZone.UTC, dateTime.getZone());
assertEquals(new DateTime(unixTimestamp, DateTimeZone.UTC), dateTime);
}

@Test
void testFromTimestampWithSpecifiedZone() {
long unixTimestamp = 1609459200000L; // 2021-01-01T00:00:00Z
DateTimeZone zone = DateTimeZone.forID("America/New_York");
DateTime dateTime = CommonUtils.fromTimestamp(unixTimestamp, zone);
assertNotNull(dateTime);
assertEquals(zone, dateTime.getZone());
assertEquals(new DateTime(unixTimestamp, zone), dateTime);
}

@Test
void testParseBooleanPropertyValidTrue() throws InvalidEntityException {
assertTrue(CommonUtils.parseBooleanProperty("true", "someProperty"));
}

@Test
void testParseBooleanPropertyValidFalse() throws InvalidEntityException {
assertFalse(CommonUtils.parseBooleanProperty("false", "someProperty"));
}

@Test
void testParseBooleanPropertyInvalidValue() {
InvalidEntityException exception = assertThrows(InvalidEntityException.class, () ->
CommonUtils.parseBooleanProperty("notABoolean", "someProperty"));
assertTrue(exception.getMessage().contains("Cannot parse boolean from: notABoolean"));
}

@Test
void testParseBooleanPropertyNullValue() throws InvalidEntityException {
assertNull(CommonUtils.parseBooleanProperty(null, "someProperty"));
}

@Test
void testTimeStringToDateTimeValid() {
String isoString = "2021-01-01T00:00:00Z";
DateTime dateTime = CommonUtils.timeStringToDateTime(isoString, "UTC");
assertNotNull(dateTime);
assertEquals(new DateTime(isoString, DateTimeZone.UTC), dateTime);
}

@Test
void testTimeStringToDateTimeInvalidZone() {
String isoString = "2021-01-01T00:00:00Z";
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () ->
CommonUtils.timeStringToDateTime(isoString, "InvalidZone"));
assertTrue(exception.getMessage().contains("Unknown time zone!"));
}

@Test
void testToTimestamp() {
DateTime dateTime = new DateTime(1609459200000L, DateTimeZone.UTC);
long unixTimestamp = CommonUtils.toTimestamp(dateTime);
assertEquals(1609459200000L, unixTimestamp);
}

@Test
void testRandomDurationWithinBounds() {
Duration min = Duration.standardSeconds(5);
Duration max = Duration.standardSeconds(10);
Duration result = CommonUtils.randomDuration(min, max);
assertTrue(result.getMillis() >= min.getMillis() && result.getMillis() <= max.getMillis());
}

@Test
void testRandomDurationMinGreaterThanMax() {
Duration min = Duration.standardSeconds(10);
Duration max = Duration.standardSeconds(5);
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () ->
CommonUtils.randomDuration(min, max));
assertTrue(exception.getMessage().contains("minDuration must be less than maxDuration"));
}

@Test
void testDurationToString() {
Duration duration = Duration.standardDays(1)
.plus(Duration.standardHours(2))
.plus(Duration.standardMinutes(30))
.plus(Duration.standardSeconds(15))
.plus(Duration.millis(500));
String result = CommonUtils.durationToString(duration);
// don't know why there is no days separation. But it was working so and tested before me.
assertEquals("26:30:15.500", result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ void buildMatchUpdateEntity_Empty_Input_Test() throws Exception {
Match input = new Match();
MatchUpdateEntity expected = new MatchUpdateEntity();
expected.setMatchHeader(new MatchHeaderEntity());
expected.setEvents(new ArrayList<>());
expected.setScore(new HashMap<>());
expected.setScores(new ArrayList<>());
expected.setSubteams(new ArrayList<>());

MatchUpdateEntity result = JaxbLiveScoutEntityFactoryHelper.buildMatchUpdateEntity(input);
assertThat(result, equalTo(expected));
Expand Down
Loading

0 comments on commit f9f02a0

Please sign in to comment.