-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
149 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
account/src/main/java/bisq/account/accounts/FasterPaymentsAccount.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package bisq.account.accounts; | ||
|
||
import bisq.account.payment_method.FiatPaymentMethod; | ||
import bisq.account.payment_method.FiatPaymentRail; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Getter | ||
@Slf4j | ||
@ToString | ||
@EqualsAndHashCode(callSuper = true) | ||
public final class FasterPaymentsAccount extends Account<FasterPaymentsAccountPayload, FiatPaymentMethod> { | ||
|
||
private static final FiatPaymentMethod PAYMENT_METHOD = FiatPaymentMethod.fromPaymentRail(FiatPaymentRail.FASTER_PAYMENTS); | ||
|
||
|
||
public FasterPaymentsAccount(long creationDate, String accountName, FasterPaymentsAccountPayload accountPayload) { | ||
super(creationDate, accountName, PAYMENT_METHOD, accountPayload); | ||
} | ||
|
||
@Override | ||
public bisq.account.protobuf.Account toProto() { | ||
return getAccountBuilder() | ||
.setFasterPaymentsAccount(bisq.account.protobuf.FasterPaymentsAccount.newBuilder()) | ||
.build(); | ||
} | ||
|
||
public static FasterPaymentsAccount fromProto(bisq.account.protobuf.Account proto) { | ||
return new FasterPaymentsAccount( | ||
proto.getCreationDate(), | ||
proto.getAccountName(), | ||
FasterPaymentsAccountPayload.fromProto(proto.getAccountPayload())); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
account/src/main/java/bisq/account/accounts/FasterPaymentsAccountPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package bisq.account.accounts; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Getter | ||
@Slf4j | ||
@ToString | ||
@EqualsAndHashCode(callSuper = true) | ||
public final class FasterPaymentsAccountPayload extends AccountPayload { | ||
|
||
private final String sortCode; | ||
private final String accountNr; | ||
|
||
public FasterPaymentsAccountPayload(String id, String paymentMethodName, String sortCode, String accountNr) { | ||
super(id, paymentMethodName); | ||
this.sortCode = sortCode; | ||
this.accountNr = accountNr; | ||
} | ||
|
||
@Override | ||
public bisq.account.protobuf.AccountPayload toProto() { | ||
return getAccountPayloadBuilder() | ||
.setFasterPaymentsAccountPayload(bisq.account.protobuf.FasterPaymentsAccountPayload.newBuilder() | ||
.setSortCode(sortCode) | ||
.setAccountNr(accountNr)) | ||
.build(); | ||
} | ||
|
||
public static FasterPaymentsAccountPayload fromProto(bisq.account.protobuf.AccountPayload account) { | ||
var fasterPaymentsPayload = account.getFasterPaymentsAccountPayload(); | ||
return new FasterPaymentsAccountPayload( | ||
account.getId(), | ||
account.getPaymentMethodName(), | ||
fasterPaymentsPayload.getSortCode(), | ||
fasterPaymentsPayload.getAccountNr()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
account/src/test/java/bisq/account/accounts/FasterPaymentsAccountTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package bisq.account.accounts; | ||
|
||
import bisq.account.protobuf.Account; | ||
import bisq.account.protobuf.AccountPayload; | ||
import bisq.account.protobuf.FasterPaymentsAccount; | ||
import bisq.account.protobuf.FasterPaymentsAccountPayload; | ||
import bisq.account.protobuf.FiatPaymentMethod; | ||
import bisq.account.protobuf.PaymentMethod; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class FasterPaymentsAccountTest { | ||
|
||
private static final bisq.account.protobuf.Account PROTO = Account.newBuilder() | ||
.setAccountName("accountName") | ||
.setCreationDate(123) | ||
.setPaymentMethod( | ||
PaymentMethod.newBuilder() | ||
.setName("FASTER_PAYMENTS") | ||
.setFiatPaymentMethod( | ||
FiatPaymentMethod.newBuilder())) | ||
.setAccountPayload(AccountPayload.newBuilder() | ||
.setId("id") | ||
.setPaymentMethodName("FASTER_PAYMENTS") | ||
.setFasterPaymentsAccountPayload(FasterPaymentsAccountPayload.newBuilder() | ||
.setSortCode("sortCode") | ||
.setAccountNr("accountNr"))) | ||
.setFasterPaymentsAccount(FasterPaymentsAccount.newBuilder()) | ||
.build(); | ||
|
||
private static final bisq.account.accounts.FasterPaymentsAccount ACCOUNT = new bisq.account.accounts.FasterPaymentsAccount( | ||
123, | ||
"accountName", | ||
new bisq.account.accounts.FasterPaymentsAccountPayload("id", "FASTER_PAYMENTS", "sortCode", "accountNr") | ||
); | ||
|
||
@Test | ||
void toProto() { | ||
var result = ACCOUNT.toProto(); | ||
assertThat(result) | ||
.usingRecursiveComparison() | ||
.isEqualTo(PROTO); | ||
} | ||
|
||
@Test | ||
void fromProto() { | ||
var result = bisq.account.accounts.FasterPaymentsAccount.fromProto(PROTO); | ||
assertThat(result) | ||
.usingRecursiveComparison() | ||
.isEqualTo(ACCOUNT); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.