Skip to content

Commit

Permalink
add profile payments test
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanCheshire committed Sep 11, 2024
1 parent 3d07d1f commit e5ac586
Showing 1 changed file with 112 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package com.github.natche.gravatarjavaclient.profile.serialization

import com.google.common.collect.ImmutableList
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertDoesNotThrow

/**
* Tests for [GravatarProfilePayments].
*/
class GravatarProfilePaymentsTest {
/**
* Tests for construction.
*/
@Test
fun testConstruction() {
assertThrows(NullPointerException::class.java) {
GravatarProfilePayments(null, null)
}
assertThrows(NullPointerException::class.java) {
GravatarProfilePayments(ImmutableList.of(), null)
}

assertDoesNotThrow {
GravatarProfilePayments(ImmutableList.of(), ImmutableList.of())
}

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

/**
* Tests for the accessor methods.
*/
@Test
fun testAccessors() {
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")))
}

/**
* 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")
))

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() {

}

/**
* 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")
))

assertEquals(1977252293, payments.hashCode())
assertEquals(185752232, otherPayment.hashCode())
assertEquals(payments.hashCode(), equalToPayments.hashCode())
assertNotEquals(payments.hashCode(), otherPayment.hashCode())
}
}

0 comments on commit e5ac586

Please sign in to comment.