@Test public void parsingAndExportRefsTest() throws Exception { Contract refContract = Contract.fromDslFile(rootPath + "ref_conditions_root_contract.yml"); Binder conditions = refContract.getReferences().get("test_ref4").getConditions(); List<Object> condList = conditions.getList(all_of.name(), null); condList.add("\"string\"!=this.state.data.string3"); condList.add("\"==INFORMATION==\"==this.state.data.string2"); condList.add("\"string\"==this.state.data.string4"); refContract.getReferences().get("test_ref4").setConditions(conditions); conditions = refContract.getReferences().get("test_ref3").getConditions(); condList = conditions.getList(all_of.name(), null); Binder parsed = ((Binder)condList.get(0)); assertEquals(parsed.getString("leftOperand", ""), "this.definition.issuer"); assertEquals(parsed.getString("rightOperand", ""), "this.state.issuer"); assertEquals(parsed.getIntOrThrow("rightConversion"), 0); assertEquals(parsed.getIntOrThrow("typeOfLeftOperand"), 0); assertEquals(parsed.getIntOrThrow("leftConversion"), 0); assertEquals(parsed.getIntOrThrow("typeOfRightOperand"), 0); assertEquals(parsed.getIntOrThrow("operator"), 7); parsed = ((Binder)condList.get(9)); assertEquals(parsed.getString("leftOperand", ""), "this.state.data.bigdecimal_val"); assertEquals(parsed.getString("rightOperand", ""), "123980111893281903812098390128320192830219821321321321123910849732682917138291"); assertEquals(parsed.getIntOrThrow("rightConversion"), 0); assertEquals(parsed.getIntOrThrow("typeOfLeftOperand"), 0); assertEquals(parsed.getIntOrThrow("leftConversion"), 1); assertEquals(parsed.getIntOrThrow("typeOfRightOperand"), 1); assertEquals(parsed.getIntOrThrow("operator"), 3); conditions = refContract.getReferences().get("test_ref4").getConditions(); condList = conditions.getList(all_of.name(), null); parsed = ((Binder)condList.get(4)); assertEquals(parsed.getString("leftOperand", ""), "==INFORMATION=="); assertEquals(parsed.getString("rightOperand", ""), "this.state.data.string2"); assertEquals(parsed.getIntOrThrow("rightConversion"), 0); assertEquals(parsed.getIntOrThrow("typeOfLeftOperand"), 1); assertEquals(parsed.getIntOrThrow("leftConversion"), 0); assertEquals(parsed.getIntOrThrow("typeOfRightOperand"), 0); assertEquals(parsed.getIntOrThrow("operator"), 7); conditions = refContract.getReferences().get("test_ref_arithmetic").getConditions(); condList = conditions.getList(any_of.name(), null); parsed = ((Binder)condList.get(0)); Binder left = parsed.getBinder("left", null); Binder right = parsed.getBinder("right", null); assertEquals(parsed.getIntOrThrow("rightConversion"), 0); assertEquals(parsed.getIntOrThrow("typeOfLeftOperand"), 3); assertEquals(parsed.getIntOrThrow("leftConversion"), 0); assertEquals(parsed.getIntOrThrow("typeOfRightOperand"), 3); assertEquals(parsed.getIntOrThrow("operator"), 2); assertEquals(left.getString("leftOperand", ""), "this.state.data.double_val"); assertEquals(left.getString("rightOperand", ""), "this.state.data.int_val"); assertEquals(left.getIntOrThrow("rightConversion"), 0); assertEquals(left.getIntOrThrow("typeOfLeftOperand"), 0); assertEquals(left.getIntOrThrow("leftConversion"), 0); assertEquals(left.getIntOrThrow("typeOfRightOperand"), 0); assertEquals(left.getIntOrThrow("operation"), 2); assertEquals(right.getString("leftOperand", ""), "this.state.data.bigdecimal_val"); assertEquals(right.getString("rightOperand", ""), "734291738921738179832719873921873920100219.83912839289189189"); assertEquals(right.getIntOrThrow("rightConversion"), 0); assertEquals(right.getIntOrThrow("typeOfLeftOperand"), 0); assertEquals(right.getIntOrThrow("leftConversion"), 1); assertEquals(right.getIntOrThrow("typeOfRightOperand"), 2); assertEquals(right.getIntOrThrow("operation"), 1); conditions = ((Binder)condList.get(3)); condList = conditions.getList(all_of.name(), null); parsed = ((Binder)condList.get(0)); left = parsed.getBinder("left", null); assertEquals(parsed.getString("rightOperand", ""), "72"); assertEquals(parsed.getIntOrThrow("rightConversion"), 0); assertEquals(parsed.getIntOrThrow("typeOfLeftOperand"), 3); assertEquals(parsed.getIntOrThrow("leftConversion"), 0); assertEquals(parsed.getIntOrThrow("typeOfRightOperand"), 2); assertEquals(parsed.getIntOrThrow("operator"), 7); assertFalse(parsed.containsKey("leftParentheses")); assertFalse(parsed.containsKey("rightParentheses")); assertEquals(left.getString("leftOperand", ""), "12"); right = left.getBinder("right", null); assertEquals(left.getIntOrThrow("rightConversion"), 0); assertEquals(left.getIntOrThrow("typeOfLeftOperand"), 2); assertEquals(left.getIntOrThrow("leftConversion"), 0); assertEquals(left.getIntOrThrow("typeOfRightOperand"), 3); assertEquals(left.getIntOrThrow("operation"), 0); assertFalse(left.containsKey("leftParentheses")); assertFalse(left.containsKey("rightParentheses")); assertEquals(right.getString("leftOperand", ""), "4"); assertEquals(right.getIntOrThrow("rightConversion"), 0); assertEquals(right.getIntOrThrow("typeOfLeftOperand"), 2); assertEquals(right.getIntOrThrow("leftConversion"), 0); assertEquals(right.getIntOrThrow("typeOfRightOperand"), 3); assertEquals(right.getIntOrThrow("operation"), 2); assertFalse(right.containsKey("leftParentheses")); assertTrue(right.containsKey("rightParentheses")); right = right.getBinder("right", null); assertEquals(right.getString("leftOperand", ""), "10"); assertEquals(right.getString("rightOperand", ""), "5"); assertEquals(right.getIntOrThrow("rightConversion"), 0); assertEquals(right.getIntOrThrow("typeOfLeftOperand"), 2); assertEquals(right.getIntOrThrow("leftConversion"), 0); assertEquals(right.getIntOrThrow("typeOfRightOperand"), 2); assertEquals(right.getIntOrThrow("operation"), 0); assertFalse(right.containsKey("leftParentheses")); assertFalse(right.containsKey("rightParentheses")); parsed = ((Binder)condList.get(5)); left = parsed.getBinder("left", null); assertEquals(parsed.getString("rightOperand", ""), "450.59"); assertEquals(parsed.getIntOrThrow("operator"), 7); assertEquals(parsed.getIntOrThrow("rightConversion"), 0); assertEquals(parsed.getIntOrThrow("typeOfLeftOperand"), 3); assertEquals(parsed.getIntOrThrow("leftConversion"), 0); assertEquals(parsed.getIntOrThrow("typeOfRightOperand"), 2); assertFalse(parsed.containsKey("leftParentheses")); assertFalse(parsed.containsKey("rightParentheses")); assertEquals(left.getString("leftOperand", ""), "450.59012"); assertEquals(left.getString("rightOperand", ""), "3"); assertEquals(left.getIntOrThrow("rightConversion"), 0); assertEquals(left.getIntOrThrow("typeOfLeftOperand"), 2); assertEquals(left.getIntOrThrow("leftConversion"), 0); assertEquals(left.getIntOrThrow("typeOfRightOperand"), 2); assertEquals(left.getIntOrThrow("operation"), 100); assertFalse(left.containsKey("leftParentheses")); assertFalse(left.containsKey("rightParentheses")); refContract.addSignerKeyFromFile(rootPath + "_xer0yfe2nn1xthc.private.unikey"); refContract.seal(); refContract.check(); refContract.traceErrors(); CLIMain.saveContract(refContract, basePath + "ref_conditions_root_contract.unicon"); callMain( "-e", basePath + "ref_conditions_root_contract.unicon", "-as", "yaml"); System.out.println(output); assertTrue (output.indexOf("export as yaml ok") >= 0); assertEquals(0, errors.size()); File file = new File( basePath + "ref_conditions_root_contract.yaml"); Scanner scanner = new Scanner(file); List<String> list=new ArrayList<>(); while(scanner.hasNextLine()){ list.add(scanner.nextLine()); } assertTrue((list.contains(" - this.definition.issuer==this.state.issuer"))); assertTrue((list.contains(" - this.owner defined"))); assertTrue((list.contains(" - this.state.data.int_val>37"))); assertTrue((list.contains(" - this.state.data.string_val==\"==DATA==\""))); assertTrue((list.contains(" - false!=this.state.data.boolean_val"))); assertTrue((list.contains(" - this.state.data.long_val<=1540809613457836"))); assertTrue((list.contains(" - -67029039209309103.09204932<=this.state.data.double_val"))); assertTrue((list.contains(" - this.state.data.string_val!=\"jkdsjdksjakjl12901ndasds_ksdokaoss\""))); assertTrue((list.contains(" - 3242905403309310398882034989390309091424678928328433888839898041300111129094320492094029007845298372939==this.state.data.bigdecimal_val::number"))); assertTrue((list.contains(" - this.state.data.bigdecimal_val::number>=\"123980111893281903812098390128320192830219821321321321123910849732682917138291\""))); assertTrue((list.contains(" - this.definition.issuer defined"))); assertTrue((list.contains(" - inherits this.state.references.test_ref1"))); assertTrue((list.contains(" - this.state.data.int_val>37"))); assertTrue((list.contains(" - this.state.data.string_val==\"==DATA==\""))); assertTrue((list.contains(" - false!=this.state.data.boolean_val"))); assertTrue((list.contains(" - this.state.data.long_val<=1540809613457836"))); assertTrue((list.contains(" - -67029039209309103.09204932>this.state.data.double_val"))); assertTrue((list.contains(" - jkdsjdksjakjl12901ndasds_ksdokaoss!=this.state.data.string_val"))); assertTrue((list.contains(" - 3242905403309310398882034989390309091424678928328433888839898041300111129094320492094029007845298372939==this.state.data.bigdecimal_val::number"))); assertTrue((list.contains(" - this.state.data.bigdecimal_val::number>=\"123980111893281903812098390128320192830219821321321321123910849732682917138291\""))); assertTrue((list.contains(" - this.state.data.long_val<=1540809613457836"))); assertTrue((list.contains(" - -67029039209309103.09204932>this.state.data.double_val"))); assertTrue((list.contains(" - jkdsjdksjakjl12901ndasds_ksdokaoss!=this.state.data.string_val"))); assertTrue((list.contains(" - 3242905403309310398882034989390309091424678928328433888839898041300111129094320492094029007845298372939==this.state.data.bigdecimal_val::number"))); assertTrue((list.contains(" - this.state.data.bigdecimal_val::number>=\"123980111893281903812098390128320192830219821321321321123910849732682917138291\""))); assertTrue((list.contains(" - this.definition.issuer==this.state.issuer"))); assertTrue((list.contains(" - this.owner defined"))); assertTrue((list.contains(" - this.state.data.int_val>37"))); assertTrue((list.contains(" - this.state.data.string_val==\"==DATA==\""))); assertTrue((list.contains(" - false!=this.state.data.boolean_val"))); assertTrue((list.contains(" - this.state.data.long_val<=1540809613457836"))); assertTrue((list.contains(" - -67029039209309103.09204932<=this.state.data.double_val"))); assertTrue((list.contains(" - this.state.data.string_val!=\"jkdsjdksjakjl12901ndasds_ksdokaoss\""))); assertTrue((list.contains(" - 3242905403309310398882034989390309091424678928328433888839898041300111129094320492094029007845298372939==this.state.data.bigdecimal_val::number"))); assertTrue((list.contains(" - this.state.data.bigdecimal_val::number>=\"123980111893281903812098390128320192830219821321321321123910849732682917138291\""))); assertTrue((list.contains(" - this.state.references.test_ref2 is_a this.state.references.test_ref1"))); assertTrue((list.contains(" - this.definition.created_at>this.state.data.time3"))); assertTrue((list.contains(" - this.definition.expires_at<\"2908-04-18 23:58:00\""))); assertTrue((list.contains(" - this.state.data.time5<=this.definition.created_at"))); assertTrue((list.contains(" - '\"string\"!=this.state.data.string3'"))); assertTrue((list.contains(" - '\"==INFORMATION==\"==this.state.data.string2'"))); assertTrue((list.contains(" - '\"string\"==this.state.data.string4'"))); assertTrue((list.contains(" - this.state.data.double_val*this.state.data.int_val<=this.state.data.bigdecimal_val::number-734291738921738179832719873921873920100219.83912839289189189"))); assertTrue((list.contains(" - -67029039209309103.09204932<this.state.data.double_val/382138291832182819.391291092190901"))); assertTrue((list.contains(" - this.state.data.int_val<this.state.data.long_val+37"))); assertTrue((list.contains(" - this.state.data.int_val==1*this.state.data.int_val"))); assertTrue((list.contains(" - this.state.data.long_val==this.state.data.long_val/1+78-78"))); assertTrue((list.contains(" - this.state.data.long_val<=154*7836"))); assertTrue((list.contains(" - -67029039209309103.09204932>this.state.data.double_val-231892.293207"))); assertTrue((list.contains(" - 3242905403309310398882034989390309091424678928328433888839898041300111129094320492094029007845298300000+72939==this.state.data.bigdecimal_val::number"))); assertTrue((list.contains(" - this.state.data.bigdecimal_val::number>=1239801118932819038120*1123910849732682917138291-8938291839218928/382"))); assertTrue((list.contains(" - 12+4*(10+5)==72"))); assertTrue((list.contains(" - 12+(4)*(10+5)==72"))); assertTrue((list.contains(" - 12+(4*(10+5))==72"))); assertTrue((list.contains(" - (-5)+2<0"))); assertTrue((list.contains(" - (this.state.data.int_val-5)/(43+7)*20==((this.state.data.int_val-5)/10-5)+20"))); assertTrue((list.contains(" - round(450.59012,3)==450.59"))); }
public static boolean saveContract(Contract contract, String fileName, Boolean fromPackedTransaction, Boolean addSigners) throws IOException { return saveContract(contract,fileName,fromPackedTransaction,addSigners,null); }
CLIMain { public static boolean saveContract(Contract contract, String fileName, Boolean fromPackedTransaction, Boolean addSigners) throws IOException { return saveContract(contract,fileName,fromPackedTransaction,addSigners,null); } }
CLIMain { public static boolean saveContract(Contract contract, String fileName, Boolean fromPackedTransaction, Boolean addSigners) throws IOException { return saveContract(contract,fileName,fromPackedTransaction,addSigners,null); }  }
CLIMain { public static boolean saveContract(Contract contract, String fileName, Boolean fromPackedTransaction, Boolean addSigners) throws IOException { return saveContract(contract,fileName,fromPackedTransaction,addSigners,null); }  static void main(String[] args); static PrivateKey getPrivateKey(); static BasicHttpClientSession getSession(int nodeNumber); static void breakSession(int nodeNumber); static void clearSession(); static void clearSession(boolean full); static void saveSession(); static void setVerboseMode(boolean verboseMode); static Contract loadContract(String fileName, Boolean fromPackedTransaction); static Parcel loadParcel(String fileName); static Contract loadContract(String fileName); static void exportContract(Contract contract, String fileName, String format, Boolean jsonPretty); static boolean saveContract(Contract contract, String fileName, Boolean fromPackedTransaction, Boolean addSigners); static boolean saveContract(Contract contract, String fileName, Boolean fromPackedTransaction, Boolean addSigners, Set<Contract> referencedItems); static boolean saveParcel(Parcel parcel, String fileName); static void saveContract(Contract contract, String fileName); static List<Wallet> findWallets(String path); static HashMap<String, Contract> findContracts(String path); static HashMap<String, Contract> findContracts(String path, Boolean recursively); static List<File> findFiles(String path, Boolean recursively); static Contract downloadContract(String url); static Parcel revokeContract(Contract contract, Contract u, int amount, Set<PrivateKey> uKeys, boolean withTestPayment, PrivateKey... key); @Deprecated static Contract revokeContract(Contract contract, PrivateKey... key); @Deprecated static void registerContract(Contract contract, int waitTime, Boolean fromPackedTransaction); static Parcel prepareForRegisterContract(Contract contract, Contract u, int amount, Set<PrivateKey> uKeys, boolean withTestPayment); static Parcel prepareForRegisterPayingParcel(Contract contract, Contract u, int amount, int amountStorage, Set<PrivateKey> uKeys, boolean withTestPayment); static ItemResult registerParcel(Parcel parcel, int waitTime); static void registerContract(Contract contract); static void registerContract(Contract contract, int waitTime); static void setTestMode(); static void setTestRootPath(String rootPath); static void setNodeNumber(int number); static void setNodeUrl(String url); static void setTopologyFileName(String filename); static void setPrivateKey(PrivateKey key); static Reporter getReporter(); static synchronized ClientNetwork getClientNetwork(); static synchronized Map<String, PrivateKey> keysMap(); static synchronized Map<String, PrivateKey> keysMapContract(); }
CLIMain { public static boolean saveContract(Contract contract, String fileName, Boolean fromPackedTransaction, Boolean addSigners) throws IOException { return saveContract(contract,fileName,fromPackedTransaction,addSigners,null); }  static void main(String[] args); static PrivateKey getPrivateKey(); static BasicHttpClientSession getSession(int nodeNumber); static void breakSession(int nodeNumber); static void clearSession(); static void clearSession(boolean full); static void saveSession(); static void setVerboseMode(boolean verboseMode); static Contract loadContract(String fileName, Boolean fromPackedTransaction); static Parcel loadParcel(String fileName); static Contract loadContract(String fileName); static void exportContract(Contract contract, String fileName, String format, Boolean jsonPretty); static boolean saveContract(Contract contract, String fileName, Boolean fromPackedTransaction, Boolean addSigners); static boolean saveContract(Contract contract, String fileName, Boolean fromPackedTransaction, Boolean addSigners, Set<Contract> referencedItems); static boolean saveParcel(Parcel parcel, String fileName); static void saveContract(Contract contract, String fileName); static List<Wallet> findWallets(String path); static HashMap<String, Contract> findContracts(String path); static HashMap<String, Contract> findContracts(String path, Boolean recursively); static List<File> findFiles(String path, Boolean recursively); static Contract downloadContract(String url); static Parcel revokeContract(Contract contract, Contract u, int amount, Set<PrivateKey> uKeys, boolean withTestPayment, PrivateKey... key); @Deprecated static Contract revokeContract(Contract contract, PrivateKey... key); @Deprecated static void registerContract(Contract contract, int waitTime, Boolean fromPackedTransaction); static Parcel prepareForRegisterContract(Contract contract, Contract u, int amount, Set<PrivateKey> uKeys, boolean withTestPayment); static Parcel prepareForRegisterPayingParcel(Contract contract, Contract u, int amount, int amountStorage, Set<PrivateKey> uKeys, boolean withTestPayment); static ItemResult registerParcel(Parcel parcel, int waitTime); static void registerContract(Contract contract); static void registerContract(Contract contract, int waitTime); static void setTestMode(); static void setTestRootPath(String rootPath); static void setNodeNumber(int number); static void setNodeUrl(String url); static void setTopologyFileName(String filename); static void setPrivateKey(PrivateKey key); static Reporter getReporter(); static synchronized ClientNetwork getClientNetwork(); static synchronized Map<String, PrivateKey> keysMap(); static synchronized Map<String, PrivateKey> keysMapContract(); static String DEFAULT_WALLET_PATH; static final String AMOUNT_FIELD_NAME; }