Skip to content

Commit

Permalink
fixing code cov
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanCheshire committed Sep 11, 2024
1 parent d4faeeb commit f20b0ed
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.github.natche.gravatarjavaclient.profile

import com.github.natche.gravatarjavaclient.profile.serialization.GravatarProfile
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test

/**
* Tests for [GravatarProfile]s.
*/
class GravatarProfileTest {
/**
* Tests for creation.
*/
@Test
fun testCreation() {
assertThrows(NullPointerException::class.java) {
GravatarProfile()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class GravatarProfileLanguageTest {
{ GravatarProfileLanguage("", "", false, 0) }
assertThrows(IllegalArgumentException::class.java)
{ GravatarProfileLanguage("en", "", false, 0) }
assertThrows(IllegalArgumentException::class.java)
{ GravatarProfileLanguage("", "name", false, 0) }

assertDoesNotThrow { GravatarProfileLanguage("en", "English", false, 0) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ class GravatarProfilePaymentsTest {
}

assertDoesNotThrow {
GravatarProfilePayments(ImmutableList.of(
GravatarProfileUrl("label", "url")
), ImmutableList.of(
GravatarCryptoWalletAddress("label", "address")
))
GravatarProfilePayments(
ImmutableList.of(
GravatarProfileUrl("label", "url")
), ImmutableList.of(
GravatarCryptoWalletAddress("label", "address")
)
)
}
}

Expand All @@ -39,70 +41,123 @@ class GravatarProfilePaymentsTest {
*/
@Test
fun testAccessors() {
val payments = GravatarProfilePayments(ImmutableList.of(
GravatarProfileUrl("label", "url")
), ImmutableList.of(
GravatarCryptoWalletAddress("label", "address")
))
val payments = GravatarProfilePayments(
ImmutableList.of(
GravatarProfileUrl("label", "url")
), ImmutableList.of(
GravatarCryptoWalletAddress("label", "address")
)
)

assertEquals(payments.links,
ImmutableList.of(GravatarProfileUrl("label", "url")))
assertEquals(payments.cryptoWallets,
ImmutableList.of(GravatarCryptoWalletAddress("label", "address")))
assertEquals(
payments.links,
ImmutableList.of(GravatarProfileUrl("label", "url"))
)
assertEquals(
payments.cryptoWallets,
ImmutableList.of(GravatarCryptoWalletAddress("label", "address"))
)
}

/**
* Tests for the to string method.
*/
@Test
fun testToString() {
val payments = GravatarProfilePayments(ImmutableList.of(
GravatarProfileUrl("label", "url")
), ImmutableList.of(
GravatarCryptoWalletAddress("label", "address")
))
val otherPayment = GravatarProfilePayments(ImmutableList.of(
GravatarProfileUrl("label", "url")
), ImmutableList.of(
GravatarCryptoWalletAddress("label", "address")
))
val payments = GravatarProfilePayments(
ImmutableList.of(
GravatarProfileUrl("label", "url")
), ImmutableList.of(
GravatarCryptoWalletAddress("label", "address")
)
)
val otherPayment = GravatarProfilePayments(
ImmutableList.of(
GravatarProfileUrl("label", "url")
), ImmutableList.of(
GravatarCryptoWalletAddress("label", "address")
)
)

assertEquals("GravatarProfilePayments{links=[GravatarProfileUrl{label=\"label\", url=\"url\"}],"
+ " cryptoWallets=[CryptoWalletAddress{label=\"label\", address=\"address\"}]}",
payments.toString())
assertEquals("GravatarProfilePayments{links=[GravatarProfileUrl{label=\"label\", url=\"url\"}],"
+ " cryptoWallets=[CryptoWalletAddress{label=\"label\", address=\"address\"}]}",
otherPayment.toString())
assertEquals(
"GravatarProfilePayments{links=[GravatarProfileUrl{label=\"label\", url=\"url\"}],"
+ " cryptoWallets=[CryptoWalletAddress{label=\"label\", address=\"address\"}]}",
payments.toString()
)
assertEquals(
"GravatarProfilePayments{links=[GravatarProfileUrl{label=\"label\", url=\"url\"}],"
+ " cryptoWallets=[CryptoWalletAddress{label=\"label\", address=\"address\"}]}",
otherPayment.toString()
)
}

/**
* Tests for the equals method.
*/
@Test
fun testEquals() {
val payments = GravatarProfilePayments(
ImmutableList.of(
GravatarProfileUrl("label", "url")
), ImmutableList.of(
GravatarCryptoWalletAddress("label", "address")
)
)
val equal = GravatarProfilePayments(
ImmutableList.of(
GravatarProfileUrl("label", "url")
), ImmutableList.of(
GravatarCryptoWalletAddress("label", "address")
)
)
val differentLink = GravatarProfilePayments(
ImmutableList.of(
GravatarProfileUrl("labeler", "urls")
), ImmutableList.of(
GravatarCryptoWalletAddress("label", "address")
)
)
val differentCrypto = GravatarProfilePayments(
ImmutableList.of(
GravatarProfileUrl("label", "url")
), ImmutableList.of(
GravatarCryptoWalletAddress("labeler", "other address")
)
)

assertEquals(payments, payments)
assertEquals(payments, equal)
assertNotEquals(payments, differentLink)
assertNotEquals(payments, differentCrypto)
assertNotEquals(payments, Object())
}

/**
* Tests for the hash code.
*/
@Test
fun testHashCode() {
val payments = GravatarProfilePayments(ImmutableList.of(
GravatarProfileUrl("label", "url")
), ImmutableList.of(
GravatarCryptoWalletAddress("label", "address")
))
val equalToPayments = GravatarProfilePayments(ImmutableList.of(
GravatarProfileUrl("label", "url")
), ImmutableList.of(
GravatarCryptoWalletAddress("label", "address")
))
val otherPayment = GravatarProfilePayments(ImmutableList.of(
GravatarProfileUrl("label", "url")
), ImmutableList.of(
GravatarCryptoWalletAddress("labeler", "other address")
))
val payments = GravatarProfilePayments(
ImmutableList.of(
GravatarProfileUrl("label", "url")
), ImmutableList.of(
GravatarCryptoWalletAddress("label", "address")
)
)
val equalToPayments = GravatarProfilePayments(
ImmutableList.of(
GravatarProfileUrl("label", "url")
), ImmutableList.of(
GravatarCryptoWalletAddress("label", "address")
)
)
val otherPayment = GravatarProfilePayments(
ImmutableList.of(
GravatarProfileUrl("label", "url")
), ImmutableList.of(
GravatarCryptoWalletAddress("labeler", "other address")
)
)

assertEquals(1977252293, payments.hashCode())
assertEquals(185752232, otherPayment.hashCode())
Expand Down

0 comments on commit f20b0ed

Please sign in to comment.