Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PaymentAccount object removal from ObservableSet issue #3572

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion core/src/main/java/bisq/core/payment/PaymentAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@

import static com.google.common.base.Preconditions.checkNotNull;

@EqualsAndHashCode
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@ToString
@Getter
@Slf4j
public abstract class PaymentAccount implements PersistablePayload {
protected final PaymentMethod paymentMethod;
@Setter
@EqualsAndHashCode.Include
protected String id;
@Setter
@EqualsAndHashCode.Include
protected long creationDate;
@Setter
public PaymentAccountPayload paymentAccountPayload;
Expand Down
22 changes: 22 additions & 0 deletions core/src/test/java/bisq/core/payment/PaymentAccountsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@
import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.offer.Offer;
import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.user.UserPayload;

import javafx.collections.FXCollections;
import javafx.collections.ObservableSet;

import java.util.Collections;

import org.junit.Test;

import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -71,4 +76,21 @@ private static PaymentAccount createAccountWithAge(AccountAgeWitnessService serv

return account;
}

@Test
public void testRemoveAccount() {
PaymentAccount account = new RevolutAccount();
account.setAccountName("account name");

ObservableSet<PaymentAccount> paymentAccountsAsObservable;
paymentAccountsAsObservable = FXCollections.observableSet(new UserPayload().getPaymentAccounts());

//add element
paymentAccountsAsObservable.add(account);

//remove element with some state change
account.setAccountName("new account name for new hash code");

assertTrue(paymentAccountsAsObservable.remove(account));
}
}