-
Notifications
You must be signed in to change notification settings - Fork 0
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
Aleksandr Sologub
committed
May 9, 2024
1 parent
40e62d9
commit 419cbd8
Showing
12 changed files
with
563 additions
and
106 deletions.
There are no files selected for viewing
279 changes: 279 additions & 0 deletions
279
api/src/test/java/org/cardanofoundation/rosetta/EntityGenerator.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,279 @@ | ||
package org.cardanofoundation.rosetta; | ||
|
||
import lombok.experimental.UtilityClass; | ||
import org.openapitools.client.model.AccountIdentifier; | ||
import org.openapitools.client.model.Allow; | ||
import org.openapitools.client.model.BlockIdentifier; | ||
import org.openapitools.client.model.BlockRequest; | ||
import org.openapitools.client.model.BlockResponse; | ||
import org.openapitools.client.model.BlockTransactionRequest; | ||
import org.openapitools.client.model.BlockTransactionResponse; | ||
import org.openapitools.client.model.ConstructionCombineRequest; | ||
import org.openapitools.client.model.ConstructionCombineResponse; | ||
import org.openapitools.client.model.ConstructionDeriveRequest; | ||
import org.openapitools.client.model.ConstructionDeriveResponse; | ||
import org.openapitools.client.model.ConstructionHashRequest; | ||
import org.openapitools.client.model.ConstructionMetadataRequest; | ||
import org.openapitools.client.model.ConstructionMetadataRequestOption; | ||
import org.openapitools.client.model.ConstructionMetadataResponse; | ||
import org.openapitools.client.model.ConstructionMetadataResponseMetadata; | ||
import org.openapitools.client.model.ConstructionParseRequest; | ||
import org.openapitools.client.model.ConstructionParseResponse; | ||
import org.openapitools.client.model.ConstructionPayloadsRequest; | ||
import org.openapitools.client.model.ConstructionPayloadsResponse; | ||
import org.openapitools.client.model.ConstructionPreprocessRequest; | ||
import org.openapitools.client.model.ConstructionSubmitRequest; | ||
import org.openapitools.client.model.CurveType; | ||
import org.openapitools.client.model.MetadataRequest; | ||
import org.openapitools.client.model.NetworkIdentifier; | ||
import org.openapitools.client.model.NetworkListResponse; | ||
import org.openapitools.client.model.NetworkOptionsResponse; | ||
import org.openapitools.client.model.NetworkRequest; | ||
import org.openapitools.client.model.NetworkStatusResponse; | ||
import org.openapitools.client.model.Operation; | ||
import org.openapitools.client.model.OperationStatus; | ||
import org.openapitools.client.model.PartialBlockIdentifier; | ||
import org.openapitools.client.model.PublicKey; | ||
import org.openapitools.client.model.TransactionIdentifier; | ||
import org.openapitools.client.model.TransactionIdentifierResponse; | ||
import org.openapitools.client.model.Version; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.List; | ||
|
||
@UtilityClass | ||
public class EntityGenerator { | ||
|
||
public static BlockTransactionResponse newBlockTransactionResponse() { | ||
return BlockTransactionResponse | ||
.builder() | ||
.transaction( | ||
org.openapitools.client.model.Transaction | ||
.builder() | ||
.transactionIdentifier( | ||
TransactionIdentifier | ||
.builder() | ||
.hash("hash1") | ||
.build()) | ||
.build()) | ||
.build(); | ||
} | ||
|
||
public static BlockIdentifier newBlockId() { | ||
return BlockIdentifier | ||
.builder() | ||
.index(123L) | ||
.hash("hash1") | ||
.build(); | ||
} | ||
|
||
public static BlockResponse newBlockResponse() { | ||
return BlockResponse | ||
.builder() | ||
.block( | ||
org.openapitools.client.model.Block | ||
.builder() | ||
.blockIdentifier( | ||
newBlockId()) | ||
.build()) | ||
.build(); | ||
} | ||
|
||
public static BlockTransactionRequest newBlockTransactionRequest() { | ||
return BlockTransactionRequest | ||
.builder() | ||
.blockIdentifier(newBlockId()) | ||
.networkIdentifier(newNetworkId()) | ||
.transactionIdentifier(TransactionIdentifier | ||
.builder() | ||
.hash("txHash1") | ||
.build()) | ||
.build(); | ||
} | ||
|
||
public static BlockRequest newBlockRequest() { | ||
return BlockRequest | ||
.builder() | ||
.blockIdentifier( | ||
PartialBlockIdentifier | ||
.builder() | ||
.index(123L) | ||
.hash("hash1") | ||
.build()) | ||
.networkIdentifier(newNetworkId()) | ||
.build(); | ||
} | ||
|
||
public static NetworkIdentifier newNetworkId() { | ||
return NetworkIdentifier | ||
.builder() | ||
.blockchain("cardano") | ||
.network("devkit") | ||
.build(); | ||
} | ||
public static ConstructionDeriveResponse givenConstructionDeriveResponse() { | ||
return ConstructionDeriveResponse | ||
.builder() | ||
.accountIdentifier(AccountIdentifier.builder().address("addr").build()) | ||
.build(); | ||
} | ||
|
||
public static ConstructionDeriveRequest givenConstructionDeriveRequest() { | ||
return ConstructionDeriveRequest | ||
.builder() | ||
.networkIdentifier(newNetworkId()) | ||
.publicKey(PublicKey.builder().curveType(CurveType.EDWARDS25519).hexBytes("43d39a2ac216e546").build()) | ||
.build(); | ||
} | ||
|
||
public static ConstructionCombineRequest givenConstructionCombineRequest() { | ||
return ConstructionCombineRequest | ||
.builder() | ||
.networkIdentifier(newNetworkId()) | ||
.unsignedTransaction("unsignedTransaction") | ||
.build(); | ||
} | ||
|
||
public static ConstructionCombineResponse givenConstructionCombineResponse() { | ||
return ConstructionCombineResponse | ||
.builder() | ||
.signedTransaction("signedTransaction") | ||
.build(); | ||
} | ||
public static ConstructionSubmitRequest givenConstructionSubmitRequest() { | ||
return ConstructionSubmitRequest | ||
.builder() | ||
.signedTransaction("signedTransaction") | ||
.networkIdentifier(newNetworkId()) | ||
.build(); | ||
} | ||
|
||
|
||
public static ConstructionPreprocessRequest givenConstructionPreprocessRequest() { | ||
return ConstructionPreprocessRequest | ||
.builder() | ||
.networkIdentifier(newNetworkId()) | ||
.build(); | ||
} | ||
|
||
public static ConstructionPayloadsResponse givenConstructionPayloadsResponse() { | ||
return ConstructionPayloadsResponse | ||
.builder() | ||
.unsignedTransaction("unsignedTransaction") | ||
.build(); | ||
} | ||
|
||
public static ConstructionPayloadsRequest givenConstructionPayloadsRequest() { | ||
return ConstructionPayloadsRequest | ||
.builder() | ||
.networkIdentifier(newNetworkId()) | ||
.build(); | ||
} | ||
|
||
public static ConstructionParseResponse givenConstructionMetadataResponse() { | ||
return ConstructionParseResponse | ||
.builder() | ||
.operations(List.of(Operation | ||
.builder() | ||
.type("input") | ||
.status("success") | ||
.build())) | ||
.build(); | ||
} | ||
|
||
public static ConstructionParseRequest givenConstructionParseRequest() { | ||
return ConstructionParseRequest | ||
.builder() | ||
.transaction("transaction") | ||
.signed(false) | ||
.networkIdentifier(newNetworkId()) | ||
.build(); | ||
} | ||
|
||
public static ConstructionMetadataResponse givenTransactionMetadataResponse() { | ||
return ConstructionMetadataResponse | ||
.builder() | ||
.metadata(ConstructionMetadataResponseMetadata | ||
.builder() | ||
.ttl(BigDecimal.valueOf(600)) | ||
.build()) | ||
.build(); | ||
} | ||
|
||
public static ConstructionMetadataRequest givenConstructionMetadataRequest() { | ||
return ConstructionMetadataRequest | ||
.builder() | ||
.networkIdentifier(newNetworkId()) | ||
.options(ConstructionMetadataRequestOption | ||
.builder() | ||
.relativeTtl(BigDecimal.valueOf(10)) | ||
.transactionSize(BigDecimal.valueOf(40)) | ||
.build()) | ||
.build(); | ||
} | ||
|
||
public static ConstructionHashRequest givenConstructionHashRequest() { | ||
return ConstructionHashRequest | ||
.builder() | ||
.networkIdentifier(newNetworkId()) | ||
.signedTransaction("signedTransaction") | ||
.build(); | ||
} | ||
|
||
public static TransactionIdentifierResponse givenTransactionIdentifierResponse() { | ||
return TransactionIdentifierResponse | ||
.builder() | ||
.transactionIdentifier(TransactionIdentifier | ||
.builder() | ||
.hash("hash") | ||
.build()) | ||
.build(); | ||
} | ||
|
||
public static NetworkOptionsResponse givenNetworkOptionsResponse() { | ||
return NetworkOptionsResponse | ||
.builder() | ||
.version(Version.builder().rosettaVersion("1.14.13").nodeVersion("8.9.0").build()) | ||
.allow(Allow.builder() | ||
.operationStatuses(List.of(OperationStatus | ||
.builder() | ||
.status("success") | ||
.successful(true) | ||
.build())) | ||
.build()) | ||
.build(); | ||
} | ||
|
||
public static NetworkListResponse givenNetworkListResponse() { | ||
return NetworkListResponse | ||
.builder() | ||
.networkIdentifiers(List.of(newNetworkId())) | ||
.build(); | ||
} | ||
|
||
public static MetadataRequest givenMetadataRequest() { | ||
return MetadataRequest | ||
.builder() | ||
.metadata(new Object()) | ||
.build(); | ||
} | ||
|
||
public static NetworkRequest givenNetworkRequest() { | ||
return NetworkRequest | ||
.builder() | ||
.networkIdentifier(newNetworkId()) | ||
.build(); | ||
} | ||
|
||
public static NetworkStatusResponse givenNetworkStatusResponse() { | ||
return NetworkStatusResponse | ||
.builder() | ||
.currentBlockIdentifier(BlockIdentifier | ||
.builder() | ||
.hash("123") | ||
.index(123L) | ||
.build()) | ||
.currentBlockTimestamp(123123123L) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.