Skip to content

Commit

Permalink
Ensure to use full XML responses when testing serializers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bram-- committed Mar 23, 2024
1 parent 57fd1cc commit 62b710a
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/org/audux/bgg/response/Collection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ data class Status(
/** Whether item is currently owned. */
@JacksonXmlProperty(isAttribute = true)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Serializable(with = LocalDateSerializer::class)
@Serializable(with = LocalDateTimeSerializer::class)
val lastModified: LocalDateTime? = null,
)

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/audux/bgg/response/ForumList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ data class ForumSummary(
/** The date and time a post was last made. */
@JsonFormat(pattern = "E, dd MMM yyyy HH:mm:ss Z")
@JacksonXmlProperty(isAttribute = true)
@Serializable(with = LocalDateSerializer::class)
@Serializable(with = LocalDateTimeSerializer::class)
val lastPostDate: LocalDateTime?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ class CollectionResponseTest {
@Test
fun `is (K)Serializable`() {
val collection =
mapper.readValue(TestUtils.xml("collection?username=empty"), Collection::class.java)
mapper.readValue(
TestUtils.xml(
"collection?username=novaeux&stats=1&subtype=boardgame&excludesubtype=boardgameexpansion"
),
Collection::class.java
)
val encodedCollection = Json.encodeToString(collection)

assertThat(Json.decodeFromString<Collection>(encodedCollection)).isEqualTo(collection)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class FamilyResponseTest {

@Test
fun `is (K)Serializable`() {
val family = mapper.readValue(TestUtils.xml("family?id=-1"), Family::class.java)
val family = mapper.readValue(TestUtils.xml("family"), Family::class.java)
val encodedFamily = Json.encodeToString(family)

assertThat(Json.decodeFromString<Family>(encodedFamily)).isEqualTo(family)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ForumListResponseTest {

@Test
fun `is (K)Serializable`() {
val forumList = mapper.readValue(TestUtils.xml("forumlist?id=-1"), ForumList::class.java)
val forumList = mapper.readValue(TestUtils.xml("forumlist"), ForumList::class.java)
val encodedForumList = Json.encodeToString(forumList)

assertThat(Json.decodeFromString<ForumList>(encodedForumList)).isEqualTo(forumList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class GeekListResponseTest {

@Test
fun `is (K)Serializable`() {
val geekList = mapper.readValue(TestUtils.xml("geeklist?id=331520"), GeekList::class.java)
val geekList =
mapper.readValue(TestUtils.xml("geeklist?id=331520&comments=1"), GeekList::class.java)
val encodedGeekList = Json.encodeToString(geekList)

assertThat(Json.decodeFromString<GeekList>(encodedGeekList)).isEqualTo(geekList)
Expand Down
3 changes: 2 additions & 1 deletion src/test/kotlin/org/audux/bgg/response/GuildResponseTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class GuildResponseTest {

@Test
fun `is (K)Serializable`() {
val guild = mapper.readValue(TestUtils.xml("guilds?id=2310"), Guild::class.java)
val guild =
mapper.readValue(TestUtils.xml("guilds?id=2310&members=1&page=1"), Guild::class.java)
val encodedGuild = Json.encodeToString(guild)

assertThat(Json.decodeFromString<Guild>(encodedGuild)).isEqualTo(guild)
Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/org/audux/bgg/response/HotResponseTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class HotResponseTest {

@Test
fun `is (K)Serializable`() {
val hotList = mapper.readValue(TestUtils.xml("hot?type=rpgperson"), HotList::class.java)
val hotList = mapper.readValue(TestUtils.xml("hot"), HotList::class.java)
val encodedHotList = Json.encodeToString(hotList)

assertThat(Json.decodeFromString<HotList>(encodedHotList)).isEqualTo(hotList)
Expand Down
6 changes: 5 additions & 1 deletion src/test/kotlin/org/audux/bgg/response/UserResponseTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ class UserResponseTest {

@Test
fun `is (K)Serializable`() {
val user = mapper.readValue(xml("user?name=Novaeux"), User::class.java)
val user =
mapper.readValue(
xml("user?name=Novaeux&buddies=1&hot=1&top=1&guilds=1&page=1&domain=boardgame"),
User::class.java
)
val encodedUser = Json.encodeToString(user)

assertThat(Json.decodeFromString<User>(encodedUser)).isEqualTo(user)
Expand Down

0 comments on commit 62b710a

Please sign in to comment.