ASTSignatureComparator implements SignatureComparator { @Override public SignatureChange computeChange(Signature _a, Signature _b) { SignatureChange astChange = new ASTSignatureChange(_a, _b); astChange.getModifications(); return astChange; } ASTSignatureComparator();  ASTSignatureComparator(double stringSimilarity); @Override float computeSimilarity(Signature _a, Signature _b); @Override SignatureChange computeChange(Signature _a, Signature _b); int getTotalNumChanges(); int getMatchedNumChanges(); @Override boolean containsChange(Signature _s, SignatureChange _change); double getStringSimilarityThreshold(); void setStringSimilarityThreshold(double _threshold); Node searchForNode(SourceCodeChange change, Node astRoot); boolean searchForEntity(SourceCodeChange change, Node astRoot); boolean searchForEntity(String _entityUniqueName, Node astRoot);  }
@Test public void testChangeComparison() throws FileAnalysisException, IOException { final String sig_chg_json = FileUtil.readFile( Paths.get("./src/test/resources/methodBody/deserialize/signatureChange.json")); final SignatureChange ddf = (ASTSignatureChange) JacksonUtil.asObject(sig_chg_json, custom_deserializers, ASTSignatureChange.class); SignatureComparator signComparator = new ASTSignatureComparator(); SignatureChange ddt = signComparator.computeChange(signatureDef, signatureUnderTest); this.setupDefectiveConstruct(); this.setupFixedConstruct(); this.setupConstructUnderTest(); SignatureChange dtf = signComparator.computeChange(signatureUnderTest, signatureFix); final Set<Object> i_dt = ASTUtil.intersectSourceCodeChanges(ddt.getModifications(), ddf.getModifications(), false); final Set<Object> i_tf = ASTUtil.intersectSourceCodeChanges(dtf.getModifications(), ddf.getModifications(), false); this.setupConstructUnderTest(); }
@Test public void testCompareFromJson() { try { final String vul_sig_json = FileUtil.readFile( Paths.get("./src/test/resources/methodBody/deserialize/signatureDef.json")); final String fix_sig_json = FileUtil.readFile( Paths.get("./src/test/resources/methodBody/deserialize/signatureFix.json")); assertEquals(vul_sig_json, vulSigJson); assertEquals(fix_sig_json, fixSigJson); final Signature vul_sig = (Signature) JacksonUtil.asObject( vul_sig_json, custom_deserializers, ASTConstructBodySignature.class); final Signature fix_sig = (Signature) JacksonUtil.asObject( fix_sig_json, custom_deserializers, ASTConstructBodySignature.class); final SignatureComparator comparator = new ASTSignatureComparator(); SignatureChange chg = comparator.computeChange(vul_sig, fix_sig); final String sig_chg_json = FileUtil.readFile( Paths.get("./src/test/resources/methodBody/deserialize/signatureChange.json")); assertEquals(sig_chg_json, sigChange); final SignatureChange sig_chg = (ASTSignatureChange) JacksonUtil.asObject(sig_chg_json, custom_deserializers, ASTSignatureChange.class); assertEquals(chg, sig_chg); } catch (JsonSyntaxException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }