FileComparator { public Set<ConstructChange> identifyChanges() { if (this.changes == null) { this.changes = new TreeSet<ConstructChange>(); if (this.defAnalyzer != null) { try { for (ConstructId key : this.defAnalyzer.getConstructs().keySet()) { if (this.fixAnalyzer != null && this.fixAnalyzer.containsConstruct(key)) { if (!this.defAnalyzer.getConstruct(key).equals(this.fixAnalyzer.getConstruct(key))) { final ConstructChange c = new ConstructChange( this.repo, this.repoPath, this.defAnalyzer.getConstruct(key), this.fixAnalyzer.getConstruct(key), this.revision, this.timeStamp); this.changes.add(c); } } else { this.changes.add( new ConstructChange( this.repo, this.repoPath, this.defAnalyzer.getConstruct(key), null, this.revision, this.timeStamp)); } } } catch (FileAnalysisException e) { FileComparator.log.error( "Error while comparing defective and fixed version: " + e.getMessage(), e); } } if (this.fixAnalyzer != null) { try { for (ConstructId key : this.fixAnalyzer.getConstructs().keySet()) { if (this.defAnalyzer != null && this.defAnalyzer.containsConstruct(key)) { if (!this.fixAnalyzer.getConstruct(key).equals(this.defAnalyzer.getConstruct(key))) { final ConstructChange chg = new ConstructChange( this.repo, this.repoPath, this.defAnalyzer.getConstruct(key), this.fixAnalyzer.getConstruct(key), this.revision, this.timeStamp); if (!this.changes.contains(chg)) this.changes.add(chg); } } else { this.changes.add( new ConstructChange( this.repo, this.repoPath, null, this.fixAnalyzer.getConstruct(key), this.revision, this.timeStamp)); } } } catch (FileAnalysisException e) { FileComparator.log.error( "Error while comparing defective and fixed version: " + e.getMessage(), e); } } } return changes; } FileComparator(FileChange _c, String _rev, String _time_stamp);  FileComparator(
      File _def, File _fix, String _rev, String _repo, String _repo_path, String _time_stamp); Set<ConstructChange> identifyChanges();  }
@Test public void testFileComparatorOnJava() { try { final FileComparator c = new FileComparator( new File( "./src/test/resources/ws_security_1438423/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java"), new File( "./src/test/resources/ws_security_1438424/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java"), null, null, null, null); final Set<ConstructChange> changes = c.identifyChanges(); for (ConstructChange chg : changes) System.out.println(chg); assertEquals(4, changes.size()); } catch (IOException e) { System.err.println(e.getMessage()); assertTrue(false); } catch (FileAnalysisException e) { System.err.println(e.getMessage()); assertTrue(false); } }
@Test public void testFileComparatorOnPy() { try { final FileComparator c = new FileComparator( new File("./src/test/resources/flask-oidc_e4ce5/flask_oidc/__init__.py"), new File("./src/test/resources/flask-oidc_f2ef8/flask_oidc/__init__.py"), null, null, null, null); final Set<ConstructChange> changes = c.identifyChanges(); for (ConstructChange chg : changes) System.out.println(chg); assertEquals(5, changes.size()); } catch (IOException e) { System.err.println(e.getMessage()); assertTrue(false); } catch (FileAnalysisException e) { System.err.println(e.getMessage()); assertTrue(false); } }