SmartContract { public BigInteger callFuncReturningInt(String function, ContractParameter... params) throws IOException, UnexpectedReturnTypeException { StackItem item; if (params.length == 0) { item = callInvokeFunction(function).getInvocationResult().getStack().get(0); } else { item = callInvokeFunction(function, Arrays.asList(params)) .getInvocationResult().getStack().get(0); } if (item.getType().equals(StackItemType.INTEGER)) { return item.asInteger().getValue(); } throw new UnexpectedReturnTypeException(item.getType(), StackItemType.INTEGER); } SmartContract(ScriptHash scriptHash, Neow3j neow);  SmartContract(File nef, File manifestFile, Neow3j neow);  SmartContract(NefFile nefFile, ContractManifest manifest, Neow3j neow); TransactionBuilder invokeFunction(String function,
            ContractParameter... contractParameters); String callFuncReturningString(String function, ContractParameter... params); BigInteger callFuncReturningInt(String function, ContractParameter... params); NeoInvokeFunction callInvokeFunction(String function, Signer... signers); NeoInvokeFunction callInvokeFunction(String function, List<ContractParameter> params,
            Signer... signers); ScriptHash getScriptHash(); NefFile getNefFile(); ContractManifest getManifest(); TransactionBuilder deploy();  }
@Test public void callFunctionReturningInt() throws IOException { setUpWireMockForCall("invokefunction", "invokefunction_totalSupply.json", NEO_SCRIPT_HASH.toString(), NEP5_TOTALSUPPLY); SmartContract sc = new SmartContract(NEO_SCRIPT_HASH, this.neow); BigInteger supply = sc.callFuncReturningInt(NEP5_TOTALSUPPLY); assertThat(supply, is(BigInteger.valueOf(3000000000000000L))); }
@Test public void callFunctionReturningNonInt() throws IOException { setUpWireMockForCall("invokefunction", "invokescript_registercandidate.json", NEO_SCRIPT_HASH.toString(), NEP5_TOTALSUPPLY); SmartContract sc = new SmartContract(NEO_SCRIPT_HASH, this.neow); expectedException.expect(UnexpectedReturnTypeException.class); expectedException.expectMessage(new StringContains(StackItemType.BOOLEAN.jsonValue())); sc.callFuncReturningInt(NEP5_TOTALSUPPLY); }