Skip to content

Commit

Permalink
Merge branch 'podcastindex2' of https://github.com/mpgirro/stalla int…
Browse files Browse the repository at this point in the history
…o podcastindex2

# Conflicts:
#	src/main/kotlin/dev/stalla/parser/OpenStreetMapElementParser.kt
#	src/test/kotlin/dev/stalla/model/podcastindex/GeographicLocationTest.kt
  • Loading branch information
mpgirro committed May 3, 2021
2 parents c8d64c7 + fad1811 commit 2f5b39c
Show file tree
Hide file tree
Showing 20 changed files with 64 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,8 @@ internal class ValidatingGeographicLocationBuilder : GeographicLocationBuilder {
return@apply
}
if (UNCERTAINTY_PARAM.equals(key, ignoreCase = true)) {
try {
uncertainty(value.toDouble())
return@apply
} catch (e: NumberFormatException) {
// if it can't be parsed, then treat it as an ordinary parameter
}
val uncertaintyValue = value.toDoubleOrNull() ?: return@apply
uncertainty(uncertaintyValue)
}
parameters[key] = value
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ public class GeographicLocation public constructor(
uncertainty == other.uncertainty &&
match(parameters, other.parameters)

override fun toString(): String = StringBuilder().apply {
override fun toString(): String = buildString {
append("geo:$latitude,$longitude")
if (altitude != null) append(",$altitude")
if (crs != null) append(";$CRS_PARAM=$crs")
if (uncertainty != null) append(";$UNCERTAINTY_PARAM=$uncertainty")
for ((key, value) in parameters) append(";$key=$value")
}.toString()
}

override fun equals(other: Any?): Boolean {
if (this === other) return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import dev.stalla.model.BuilderFactory

/**
* The location information of editorial focus for a podcast's or episode's content
* (i.e. "what place is this podcast/episode about?").
* (i.e., "what place is this podcast/episode about?").
*
* Direct instantiation in Java is discouraged. Use the [builder][PodcastindexLocation.Factory.builder]
* method to obtain a [PodcastindexLocation] instance for expressive construction instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import dev.stalla.model.BuilderFactory
/**
* The information for a person of interest to the podcast or episode. Intended to identify
* people like hosts, co-hosts and guests. It is recommented to use [role] and [group] values
* based on the [Podcast Taxonomy Project](https://podcasttaxonomy.com)
* based on the [Podcast Taxonomy Project](https://podcasttaxonomy.com).
*
* Direct instantiation in Java is discouraged. Use the [builder][PodcastindexPerson.Factory.builder]
* method to obtain a [PodcastindexPerson] instance for expressive construction instead.
*
* @property name The full name or alias of the person.
* @property role The role the person serves on the show or episode - this should be a reference to an
* @property role The role the person serves on the show or episode this should be a reference to an
* official role within the [Podcast Taxonomy Project](https://podcasttaxonomy.com) list.
* @property group Should be an official group within the [Podcast Taxonomy Project](https://podcasttaxonomy.com) list.
* @property img The url of a picture or avatar of the person.
Expand Down
10 changes: 5 additions & 5 deletions src/test/kotlin/dev/stalla/Assertions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ internal fun Assert<MediaType>.doesNotMatchSymmetrically(expected: MediaType?) =
internal fun Assert<GeographicLocation>.matchPattern(expected: GeographicLocation) = given { geoLocation ->
if (geoLocation.match(expected)) return@given
expected(
"to be: '$expected' but was: '$geoLocation'",
"to be: '$expected', but was: '$geoLocation'",
expected = expected,
actual = geoLocation
)
Expand All @@ -239,13 +239,13 @@ internal fun Assert<MediaType>.hasParameterWithValue(expectedKey: String, expect
if (actualValue != null && actualValue == expectedValue) return@given
if (actualValue == null) {
expected(
"to be have a value for key: '$expectedKey'",
"to have a value for key: '$expectedKey'",
expected = expectedValue,
actual = actualValue
)
} else {
expected(
"to be: $expectedKey=$expectedValue but was: $expectedKey=$actualValue",
"to have a key '$expectedKey' with value '$expectedValue', but was: '$actualValue'",
expected = expectedValue,
actual = actualValue
)
Expand All @@ -259,13 +259,13 @@ internal fun Assert<GeographicLocation>.hasParameterWithValue(expectedKey: Strin
if (actualValue != null && actualValue == expectedValue) return@given
if (actualValue == null) {
expected(
"to be have a value for key: '$expectedKey'",
"to have a value for key: '$expectedKey'",
expected = expectedValue,
actual = actualValue
)
} else {
expected(
"to be: $expectedKey=$expectedValue but was: $expectedKey=$actualValue",
"to have a key '$expectedKey' with value '$expectedValue', but was: '$actualValue'",
expected = expectedValue,
actual = actualValue
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ internal class FakePodcastindexLocationBuilder : FakeBuilder<PodcastindexLocatio
override fun geo(geo: GeographicLocation?): PodcastindexLocationBuilder = apply { this.geo = geo }

override fun osm(osm: OpenStreetMapElement?): PodcastindexLocationBuilder = apply { this.osm = osm }

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
Expand All @@ -36,7 +37,5 @@ internal class FakePodcastindexLocationBuilder : FakeBuilder<PodcastindexLocatio
return result
}

override fun toString(): String {
return "FakePodcastindexLocationBuilder(name=$name, geo=$geo, osm=$osm)"
}
override fun toString(): String = "FakePodcastindexLocationBuilder(name=$name, geo=$geo, osm=$osm)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ internal class FakePodcastindexPersonBuilder : FakeBuilder<PodcastindexPerson>()
return result
}

override fun toString(): String {
return "FakePodcastindexPersonBuilder(name=$name, role=$role, group=$group, img=$img, href=$href)"
}
override fun toString(): String =
"FakePodcastindexPersonBuilder(name=$name, role=$role, group=$group, img=$img, href=$href)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,5 @@ internal class FakeEpisodePodcastindexEpisodeBuilder : FakeBuilder<PodcastindexE
return result
}

override fun toString(): String {
return "FakeEpisodePodcastindexEpisodeBuilder(number=$number, display=$display)"
}
override fun toString(): String = "FakeEpisodePodcastindexEpisodeBuilder(number=$number, display=$display)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,5 @@ internal class FakeEpisodePodcastindexSeasonBuilder : FakeBuilder<PodcastindexSe
return result
}

override fun toString(): String {
return "FakeEpisodePodcastindexSeasonBuilder(number=$number, name=$name)"
}
override fun toString(): String = "FakeEpisodePodcastindexSeasonBuilder(number=$number, name=$name)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ internal class FakePodcastPodcastindexBuilder : FakeBuilder<PodcastPodcastindex>
return result
}

override fun toString(): String {
return "FakePodcastPodcastindexBuilder(lockedBuilderValue=$lockedBuilderValue, locationBuilderValue=$locationBuilderValue, " +
override fun toString(): String =
"FakePodcastPodcastindexBuilder(lockedBuilderValue=$lockedBuilderValue, locationBuilderValue=$locationBuilderValue, " +
"fundingBuilders=$fundingBuilders, personBuilders=$personBuilders)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal class ValidatingGeographicLocationBuilderTest {
}

@Test
internal fun `should build a GeographicLocation with all the mandatory href field`() {
internal fun `should build a GeographicLocation with all the mandatory fields`() {
val geoBuilder = ValidatingGeographicLocationBuilder()
.latitude(1.0)
.longitude(2.0)
Expand Down Expand Up @@ -104,7 +104,7 @@ internal class ValidatingGeographicLocationBuilderTest {
}

@Test
internal fun `should populate a GeographicLocation builder with all properties from an GeographicLocation model`() {
internal fun `should populate a GeographicLocation builder with all properties from a GeographicLocation model`() {
val geo = aPodcastindexGeographicLocation()
val geoBuilder = GeographicLocation.builder().applyFrom(geo)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal class ValidatingOpenStreetMapElementBuilderTest {
}

@Test
internal fun `should build a OpenStreetMap element with all the mandatory href field`() {
internal fun `should build an OpenStreetMap element with all the mandatory fields`() {
val osmBuilder = ValidatingOpenStreetMapElementBuilder()
.type(OpenStreetMapElementType.Relation)
.id(1L)
Expand All @@ -45,7 +45,7 @@ internal class ValidatingOpenStreetMapElementBuilderTest {
}

@Test
internal fun `should populate a OpenStreetMap element builder with all properties from an GeographicLocation model`() {
internal fun `should populate an OpenStreetMap element builder with all properties from an OpenStreetMap element model`() {
val osm = aPodcastindexOpenStreetMapElement()
val osmBuilder = OpenStreetMapElement.builder().applyFrom(osm)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test
internal class ValidatingPodcastindexLocationBuilderTest {

@Test
internal fun `should not build an Podcastindex Location with when all the fields are missing`() {
internal fun `should not build a Podcastindex Location when all the fields are missing`() {
val locationBuilder = ValidatingPodcastindexLocationBuilder()

assertAll {
Expand All @@ -30,7 +30,7 @@ internal class ValidatingPodcastindexLocationBuilderTest {
}

@Test
internal fun `should not build an Podcastindex Location with when the name field is missing`() {
internal fun `should not build a Podcastindex Location when the mandatory name field is missing`() {
val locationBuilder = ValidatingPodcastindexLocationBuilder()
.geo(aPodcastindexGeographicLocation())

Expand All @@ -42,7 +42,7 @@ internal class ValidatingPodcastindexLocationBuilderTest {
}

@Test
internal fun `should build an Podcastindex Location with all the mandatory fields`() {
internal fun `should build a Podcastindex Location with only the mandatory name field`() {
val locationBuilder = ValidatingPodcastindexLocationBuilder()
.name("name")

Expand All @@ -58,7 +58,7 @@ internal class ValidatingPodcastindexLocationBuilderTest {
}

@Test
internal fun `should build an Podcastindex Location with all the added entries to its fields`() {
internal fun `should build a Podcastindex Location with all fields filled in correctly`() {
val locationBuilder = ValidatingPodcastindexLocationBuilder()
.name("name")
.geo(aPodcastindexGeographicLocation())
Expand All @@ -76,7 +76,7 @@ internal class ValidatingPodcastindexLocationBuilderTest {
}

@Test
internal fun `should populate an Podcastindex Location builder with all properties from an Podcastindex Location model`() {
internal fun `should populate a Podcastindex Location builder with all properties from a Podcastindex Location model`() {
val location = anEpisodePodcastindexLocation()
val locationBuilder = PodcastindexLocation.builder().applyFrom(location)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import org.junit.jupiter.api.Test
internal class ValidatingPodcastindexPersonBuilderTest {

@Test
internal fun `should not build an Podcastindex Person with when all the fields are missing`() {
internal fun `should not build a Podcastindex Person when all the fields are missing`() {
val personBuilder = ValidatingPodcastindexPersonBuilder()

assertAll {
Expand All @@ -28,7 +28,7 @@ internal class ValidatingPodcastindexPersonBuilderTest {
}

@Test
internal fun `should not build an Podcastindex Person with when the name field is missing`() {
internal fun `should not build a Podcastindex Person when the mandatory name field is missing`() {
val personBuilder = ValidatingPodcastindexPersonBuilder()
.role("role")

Expand All @@ -40,7 +40,7 @@ internal class ValidatingPodcastindexPersonBuilderTest {
}

@Test
internal fun `should build an Podcastindex Person with all the mandatory fields`() {
internal fun `should build a Podcastindex Person with only the mandatory name field`() {
val personBuilder = ValidatingPodcastindexPersonBuilder()
.name("name")

Expand All @@ -58,7 +58,7 @@ internal class ValidatingPodcastindexPersonBuilderTest {
}

@Test
internal fun `should build an Podcastindex Person with all the added entries to its fields`() {
internal fun `should build a Podcastindex Person with all fields filled in correctly`() {
val personBuilder = ValidatingPodcastindexPersonBuilder()
.name("name")
.role("role")
Expand All @@ -80,7 +80,7 @@ internal class ValidatingPodcastindexPersonBuilderTest {
}

@Test
internal fun `should populate an Podcastindex Person builder with all properties from an Podcastindex Person model`() {
internal fun `should populate a Podcastindex Person builder with all properties from a Podcastindex Person model`() {
val person = anEpisodePodcastindexPerson()
val personBuilder = PodcastindexPerson.builder().applyFrom(person)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ internal class ValidatingEpisodePodcastindexBuilderTest {
}

@Test
internal fun `should build an Episode Podcastindex with at least a person builder`() {
internal fun `should build an Episode Podcastindex with at least one valid person builder`() {
val episodePodcastindexBuilder = ValidatingEpisodePodcastindexBuilder()
.addPersonBuilder(firstExpectedPersonBuilder)

Expand All @@ -176,7 +176,7 @@ internal class ValidatingEpisodePodcastindexBuilderTest {
}

@Test
internal fun `should not build an Episode Podcastindex when there is only a person builder that doesn't build`() {
internal fun `should not build an Episode Podcastindex with only a person builder that doesn't build`() {
val episodePodcastindexBuilder = ValidatingEpisodePodcastindexBuilder()
.addPersonBuilder(ValidatingPodcastindexPersonBuilder())

Expand All @@ -188,7 +188,7 @@ internal class ValidatingEpisodePodcastindexBuilderTest {
}

@Test
internal fun `should build an Episode Podcastindex with at least a location builder`() {
internal fun `should build an Episode Podcastindex with only a valid location builder`() {
val episodePodcastindexBuilder = ValidatingEpisodePodcastindexBuilder()
.locationBuilder(expectedLocationBuilder)

Expand All @@ -201,7 +201,7 @@ internal class ValidatingEpisodePodcastindexBuilderTest {
}

@Test
internal fun `should not build an Episode Podcastindex when there is only a location builder that doesn't build`() {
internal fun `should not build an Episode Podcastindex with only a location builder that doesn't build`() {
val episodePodcastindexBuilder = ValidatingEpisodePodcastindexBuilder()
.locationBuilder(ValidatingPodcastindexLocationBuilder())

Expand All @@ -213,7 +213,7 @@ internal class ValidatingEpisodePodcastindexBuilderTest {
}

@Test
internal fun `should build an Episode Podcastindex with at least a season builder`() {
internal fun `should build an Episode Podcastindex with only a valid season builder`() {
val episodePodcastindexBuilder = ValidatingEpisodePodcastindexBuilder()
.seasonBuilder(expectedSeasonBuilder)

Expand All @@ -226,7 +226,7 @@ internal class ValidatingEpisodePodcastindexBuilderTest {
}

@Test
internal fun `should not build an Episode Podcastindex when there is only a season builder that doesn't build`() {
internal fun `should not build an Episode Podcastindex with only a season builder that doesn't build`() {
val episodePodcastindexBuilder = ValidatingEpisodePodcastindexBuilder()
.seasonBuilder(ValidatingEpisodePodcastindexSeasonBuilder())

Expand All @@ -238,7 +238,7 @@ internal class ValidatingEpisodePodcastindexBuilderTest {
}

@Test
internal fun `should build an Episode Podcastindex with at least a episode builder`() {
internal fun `should build an Episode Podcastindex with only a valid episode builder`() {
val episodePodcastindexBuilder = ValidatingEpisodePodcastindexBuilder()
.episodeBuilder(expectedEpisodeBuilder)

Expand All @@ -251,7 +251,7 @@ internal class ValidatingEpisodePodcastindexBuilderTest {
}

@Test
internal fun `should not build an Episode Podcastindex when there is only a episode builder that doesn't build`() {
internal fun `should not build an Episode Podcastindex with only an episode builder that doesn't build`() {
val episodePodcastindexBuilder = ValidatingEpisodePodcastindexBuilder()
.episodeBuilder(ValidatingEpisodePodcastindexEpisodeBuilder())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import org.junit.jupiter.api.Test
internal class ValidatingEpisodePodcastindexEpisodeBuilderTest {

@Test
internal fun `should not build an Episode Podcastindex Episode with when all the fields are missing`() {
internal fun `should not build an Episode Podcastindex Episode when all the mandatory fields are missing`() {
val episodeBuilder = ValidatingEpisodePodcastindexEpisodeBuilder()

assertAll {
Expand All @@ -28,7 +28,7 @@ internal class ValidatingEpisodePodcastindexEpisodeBuilderTest {
}

@Test
internal fun `should not build an Episode Podcastindex Episode with when the number field is missing`() {
internal fun `should not build an Episode Podcastindex Episode when the mandatory number field is missing`() {
val episodeBuilder = ValidatingEpisodePodcastindexEpisodeBuilder()
.display("display")

Expand All @@ -40,7 +40,7 @@ internal class ValidatingEpisodePodcastindexEpisodeBuilderTest {
}

@Test
internal fun `should build an Episode Podcastindex Episode with all the mandatory fields`() {
internal fun `should build an Episode Podcastindex Episode with only the mandatory number field`() {
val episodeBuilder = ValidatingEpisodePodcastindexEpisodeBuilder()
.number(1.0)

Expand All @@ -55,7 +55,7 @@ internal class ValidatingEpisodePodcastindexEpisodeBuilderTest {
}

@Test
internal fun `should build an Episode Podcastindex Episode with all the added entries to its fields`() {
internal fun `should build an Episode Podcastindex Episode with all fields filled in correctly`() {
val episodeBuilder = ValidatingEpisodePodcastindexEpisodeBuilder()
.number(1.0)
.display("display")
Expand Down
Loading

0 comments on commit 2f5b39c

Please sign in to comment.