use of com.hederahashgraph.api.proto.java.Query 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());
}
use of com.hederahashgraph.api.proto.java.Query in project hedera-services by hashgraph.
the class GetScheduleInfoAnswerTest method getsExpectedPayment.
@Test
void getsExpectedPayment() throws Throwable {
// given:
Query query = validQuery(COST_ANSWER, fee, scheduleID);
// expect:
assertEquals(paymentTxn, subject.extractPaymentFrom(query).get().getSignedTxnWrapper());
}
use of com.hederahashgraph.api.proto.java.Query 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));
}
use of com.hederahashgraph.api.proto.java.Query 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());
}
use of com.hederahashgraph.api.proto.java.Query 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());
}
Aggregations