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());
}
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());
}
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));
}
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());
}
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);
}
Aggregations