Abi extends ArrayList<Abi.Entry> { public static Abi fromJson(String json) { try { return DEFAULT_MAPPER.readValue(json, Abi.class); } catch (IOException e) { throw new RuntimeException(e); } }  static Abi fromJson(String json); String toJson(); Function findFunction(Predicate<Function> searchPredicate); Event findEvent(Predicate<Event> searchPredicate); Abi.Constructor findConstructor(); @Override String toString();  }
@Test public void simpleTest() throws IOException { String contractAbi = "[{" + "\"name\":\"simpleFunction\"," + "\"constant\":true," + "\"payable\":true," + "\"type\":\"function\"," + "\"inputs\": [{\"name\":\"_in\", \"type\":\"bytes32\"}]," + "\"outputs\":[{\"name\":\"_out\",\"type\":\"bytes32\"}]}]"; Abi abi = Abi.fromJson(contractAbi); assertEquals(abi.size(), 1); Entry onlyFunc = abi.get(0); assertEquals(onlyFunc.type, Type.function); assertEquals(onlyFunc.inputs.size(), 1); assertEquals(onlyFunc.outputs.size(), 1); assertTrue(onlyFunc.payable); assertTrue(onlyFunc.constant); }
@Test public void simpleLegacyTest() throws IOException { String contractAbi = "[{" + "\"name\":\"simpleFunction\"," + "\"constant\":true," + "\"type\":\"function\"," + "\"inputs\": [{\"name\":\"_in\", \"type\":\"bytes32\"}]," + "\"outputs\":[{\"name\":\"_out\",\"type\":\"bytes32\"}]}]"; Abi abi = Abi.fromJson(contractAbi); assertEquals(abi.size(), 1); Entry onlyFunc = abi.get(0); assertEquals(onlyFunc.type, Type.function); assertEquals(onlyFunc.inputs.size(), 1); assertEquals(onlyFunc.outputs.size(), 1); assertTrue(onlyFunc.constant); }