Search in sources :

Example 91 with Response

use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.

the class GetTokenNftInfoAnswerTest method getsCostAnswerResponse.

@Test
void getsCostAnswerResponse() throws Throwable {
    // setup:
    Query query = validQuery(COST_ANSWER, fee, nftId);
    // when:
    Response response = subject.responseGiven(query, view, OK, fee);
    // then:
    assertTrue(response.hasTokenGetNftInfo());
    assertEquals(OK, response.getTokenGetNftInfo().getHeader().getNodeTransactionPrecheckCode());
    assertEquals(COST_ANSWER, response.getTokenGetNftInfo().getHeader().getResponseType());
    assertEquals(fee, response.getTokenGetNftInfo().getHeader().getCost());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TokenGetNftInfoResponse(com.hederahashgraph.api.proto.java.TokenGetNftInfoResponse) TokenGetNftInfoQuery(com.hederahashgraph.api.proto.java.TokenGetNftInfoQuery) Query(com.hederahashgraph.api.proto.java.Query) Test(org.junit.jupiter.api.Test)

Example 92 with Response

use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.

the class GetTokenNftInfoAnswerTest method doesNotGetInfoWithInvalidValidity.

@Test
void doesNotGetInfoWithInvalidValidity() throws Throwable {
    // setup:
    Query sensibleQuery = validQuery(ANSWER_ONLY, 5L, nftId);
    Map<String, Object> ctx = new HashMap<>();
    // given:
    ctx.put(GetTokenNftInfoAnswer.NFT_INFO_CTX_KEY, info);
    // when:
    Response response = subject.responseGiven(sensibleQuery, view, INVALID_NFT_ID, 0L, ctx);
    // then:
    var opResponse = response.getTokenGetNftInfo();
    assertTrue(opResponse.hasHeader(), "Missing response header!");
    assertEquals(INVALID_NFT_ID, opResponse.getHeader().getNodeTransactionPrecheckCode());
    // and:
    verify(view, never()).infoForNft(any());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TokenGetNftInfoResponse(com.hederahashgraph.api.proto.java.TokenGetNftInfoResponse) TokenGetNftInfoQuery(com.hederahashgraph.api.proto.java.TokenGetNftInfoQuery) Query(com.hederahashgraph.api.proto.java.Query) HashMap(java.util.HashMap) ByteString(com.google.protobuf.ByteString) Test(org.junit.jupiter.api.Test)

Example 93 with Response

use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.

the class GetTokenNftInfoAnswerTest method getsValidity.

@Test
void getsValidity() {
    // given:
    Response response = Response.newBuilder().setTokenGetNftInfo(TokenGetNftInfoResponse.newBuilder().setHeader(subject.answerOnlyHeader(RESULT_SIZE_LIMIT_EXCEEDED))).build();
    // expect:
    assertEquals(RESULT_SIZE_LIMIT_EXCEEDED, subject.extractValidityFrom(response));
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TokenGetNftInfoResponse(com.hederahashgraph.api.proto.java.TokenGetNftInfoResponse) Test(org.junit.jupiter.api.Test)

Example 94 with Response

use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.

the class GetTokenNftInfoAnswerTest method doesNotGetInfoWithEmptyContext.

@Test
void doesNotGetInfoWithEmptyContext() throws Throwable {
    // setup:
    Query sensibleQuery = validQuery(ANSWER_ONLY, 5L, nftId);
    // when:
    Response response = subject.responseGiven(sensibleQuery, view, INVALID_NFT_ID, 0L);
    // then:
    var opResponse = response.getTokenGetNftInfo();
    assertTrue(opResponse.hasHeader(), "Missing response header!");
    assertEquals(INVALID_NFT_ID, opResponse.getHeader().getNodeTransactionPrecheckCode());
    // and:
    verify(view, never()).infoForNft(any());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TokenGetNftInfoResponse(com.hederahashgraph.api.proto.java.TokenGetNftInfoResponse) TokenGetNftInfoQuery(com.hederahashgraph.api.proto.java.TokenGetNftInfoQuery) Query(com.hederahashgraph.api.proto.java.Query) Test(org.junit.jupiter.api.Test)

Example 95 with Response

use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.

the class GetTokenNftInfoAnswerTest method getsTheInfo.

@Test
void getsTheInfo() throws Throwable {
    // setup:
    Query query = validQuery(ANSWER_ONLY, fee, nftId);
    given(view.infoForNft(nftId)).willReturn(Optional.of(info));
    // when:
    Response response = subject.responseGiven(query, view, OK, fee);
    // then:
    assertTrue(response.hasTokenGetNftInfo());
    assertTrue(response.getTokenGetNftInfo().hasHeader(), "Missing response header!");
    assertEquals(OK, response.getTokenGetNftInfo().getHeader().getNodeTransactionPrecheckCode());
    assertEquals(ANSWER_ONLY, response.getTokenGetNftInfo().getHeader().getResponseType());
    assertEquals(fee, response.getTokenGetNftInfo().getHeader().getCost());
    // and:
    var actual = response.getTokenGetNftInfo().getNft();
    assertEquals(info, actual);
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TokenGetNftInfoResponse(com.hederahashgraph.api.proto.java.TokenGetNftInfoResponse) TokenGetNftInfoQuery(com.hederahashgraph.api.proto.java.TokenGetNftInfoQuery) Query(com.hederahashgraph.api.proto.java.Query) Test(org.junit.jupiter.api.Test)

Aggregations

Response (com.hederahashgraph.api.proto.java.Response)114 Query (com.hederahashgraph.api.proto.java.Query)96 Test (org.junit.jupiter.api.Test)87 FileGetInfoResponse (com.hederahashgraph.api.proto.java.FileGetInfoResponse)9 ByteString (com.google.protobuf.ByteString)8 ContractCallLocalQuery (com.hederahashgraph.api.proto.java.ContractCallLocalQuery)8 TokenGetNftInfoQuery (com.hederahashgraph.api.proto.java.TokenGetNftInfoQuery)8 TokenGetNftInfoResponse (com.hederahashgraph.api.proto.java.TokenGetNftInfoResponse)8 TransactionGetReceiptResponse (com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse)8 ContractCallLocalResponse (com.hederahashgraph.api.proto.java.ContractCallLocalResponse)7 ContractGetInfoQuery (com.hederahashgraph.api.proto.java.ContractGetInfoQuery)7 ContractGetInfoResponse (com.hederahashgraph.api.proto.java.ContractGetInfoResponse)7 NetworkGetExecutionTimeQuery (com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeQuery)7 NetworkGetExecutionTimeResponse (com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeResponse)7 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)7 ScheduleGetInfoQuery (com.hederahashgraph.api.proto.java.ScheduleGetInfoQuery)7 ScheduleGetInfoResponse (com.hederahashgraph.api.proto.java.ScheduleGetInfoResponse)7 TokenGetInfoQuery (com.hederahashgraph.api.proto.java.TokenGetInfoQuery)7 TokenGetInfoResponse (com.hederahashgraph.api.proto.java.TokenGetInfoResponse)7 HashMap (java.util.HashMap)7