Search in sources :

Example 21 with Response

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

the class GetScheduleInfoAnswerTest method recognizesMissingInfoWhenNoCtxGiven.

@Test
void recognizesMissingInfoWhenNoCtxGiven() throws Throwable {
    // setup:
    Query sensibleQuery = validQuery(ANSWER_ONLY, 5L, scheduleID);
    given(view.infoForSchedule(scheduleID)).willReturn(Optional.empty());
    // when:
    Response response = subject.responseGiven(sensibleQuery, view, OK, 0L);
    // then:
    ScheduleGetInfoResponse opResponse = response.getScheduleGetInfo();
    assertTrue(opResponse.hasHeader(), "Missing response header!");
    assertEquals(INVALID_SCHEDULE_ID, opResponse.getHeader().getNodeTransactionPrecheckCode());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) ScheduleGetInfoResponse(com.hederahashgraph.api.proto.java.ScheduleGetInfoResponse) Query(com.hederahashgraph.api.proto.java.Query) ScheduleGetInfoQuery(com.hederahashgraph.api.proto.java.ScheduleGetInfoQuery) ScheduleGetInfoResponse(com.hederahashgraph.api.proto.java.ScheduleGetInfoResponse) Test(org.junit.jupiter.api.Test)

Example 22 with Response

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

the class GetAccountNftInfosAnswerTest method respectsTypeOfUnsupportedQuery.

@Test
void respectsTypeOfUnsupportedQuery() {
    // given:
    Query costAnswer = getQuery(COST_ANSWER);
    Query answerOnly = getQuery(ANSWER_ONLY);
    // when:
    Response costAnswerResponse = subject.responseGiven(costAnswer, StateView.EMPTY_VIEW, OK, 0L);
    Response answerOnlyResponse = subject.responseGiven(answerOnly, StateView.EMPTY_VIEW, OK, 0L);
    // then:
    assertEquals(COST_ANSWER, costAnswerResponse.getTokenGetAccountNftInfos().getHeader().getResponseType());
    assertEquals(ANSWER_ONLY, answerOnlyResponse.getTokenGetAccountNftInfos().getHeader().getResponseType());
    // and:
    assertEquals(NOT_SUPPORTED, subject.extractValidityFrom(costAnswerResponse));
    assertEquals(NOT_SUPPORTED, subject.extractValidityFrom(answerOnlyResponse));
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TokenGetAccountNftInfosResponse(com.hederahashgraph.api.proto.java.TokenGetAccountNftInfosResponse) Query(com.hederahashgraph.api.proto.java.Query) TokenGetAccountNftInfosQuery(com.hederahashgraph.api.proto.java.TokenGetAccountNftInfosQuery) Test(org.junit.jupiter.api.Test)

Example 23 with Response

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

the class GetTokenInfoAnswerTest method getsInfoFromCtxWhenAvailable.

@Test
void getsInfoFromCtxWhenAvailable() throws Throwable {
    // setup:
    Query sensibleQuery = validQuery(ANSWER_ONLY, 5L, tokenId);
    Map<String, Object> ctx = new HashMap<>();
    // given:
    ctx.put(GetTokenInfoAnswer.TOKEN_INFO_CTX_KEY, info);
    // when:
    Response response = subject.responseGiven(sensibleQuery, view, OK, 0L, ctx);
    // then:
    var opResponse = response.getTokenGetInfo();
    assertTrue(opResponse.hasHeader(), "Missing response header!");
    assertEquals(OK, opResponse.getHeader().getNodeTransactionPrecheckCode());
    assertSame(info, opResponse.getTokenInfo());
    // and:
    verify(view, never()).infoForToken(any());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TokenGetInfoResponse(com.hederahashgraph.api.proto.java.TokenGetInfoResponse) TokenGetInfoQuery(com.hederahashgraph.api.proto.java.TokenGetInfoQuery) Query(com.hederahashgraph.api.proto.java.Query) HashMap(java.util.HashMap) ByteString(com.google.protobuf.ByteString) Test(org.junit.jupiter.api.Test)

Example 24 with Response

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

the class GetTokenInfoAnswerTest method recognizesMissingInfoWhenNoCtxGiven.

@Test
void recognizesMissingInfoWhenNoCtxGiven() throws Throwable {
    // setup:
    Query sensibleQuery = validQuery(ANSWER_ONLY, 5L, tokenId);
    given(view.infoForToken(tokenId)).willReturn(Optional.empty());
    // when:
    Response response = subject.responseGiven(sensibleQuery, view, OK, 0L);
    // then:
    TokenGetInfoResponse opResponse = response.getTokenGetInfo();
    assertTrue(opResponse.hasHeader(), "Missing response header!");
    assertEquals(INVALID_TOKEN_ID, opResponse.getHeader().getNodeTransactionPrecheckCode());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TokenGetInfoResponse(com.hederahashgraph.api.proto.java.TokenGetInfoResponse) TokenGetInfoResponse(com.hederahashgraph.api.proto.java.TokenGetInfoResponse) TokenGetInfoQuery(com.hederahashgraph.api.proto.java.TokenGetInfoQuery) Query(com.hederahashgraph.api.proto.java.Query) Test(org.junit.jupiter.api.Test)

Example 25 with Response

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

the class GetTokenInfoAnswerTest method getsValidity.

@Test
void getsValidity() {
    // given:
    Response response = Response.newBuilder().setTokenGetInfo(TokenGetInfoResponse.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) TokenGetInfoResponse(com.hederahashgraph.api.proto.java.TokenGetInfoResponse) 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