chained.addConfiguredMapper(mapperCX); FileNameMapper fileNameMapper = chained.getImplementation(); String[] targets = fileNameMapper.mapFileName("a"); assertNotNull("no filenames mapped", targets); assertEquals("wrong number of filenames mapped", 2, targets.length); List list = Arrays.asList(targets); assertTrue("cannot find expected target \"def\"", list.contains("def")); assertTrue("cannot find expected target \"ghi\"", list.contains("ghi"));
container.add(mapper3); FileNameMapper fileNameMapper = container.getImplementation(); String[] targets = fileNameMapper.mapFileName("fromfilename"); assertNotNull("no filenames mapped", targets); assertEquals("wrong number of filenames mapped", 3, targets.length); List list = Arrays.asList(targets); assertTrue("cannot find expected target \"tofilename\"", list.contains("tofilename")); assertTrue("cannot find expected target \"fromfilename\"", list.contains("fromfilename"));
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/MapperTest.java File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/MapperTest.java
Method name: void testChained() Method name: void testNested()
Number of AST nodes: 8 Number of AST nodes: 8
1
chained.addConfiguredMapper(mapperCX);
1
container.add(mapper3);
2
        FileNameMapper fileNameMapper = chained.getImplementation();
2
        FileNameMapper fileNameMapper = container.getImplementation();
3
        String[] targets = fileNameMapper.mapFileName("a");
3
        String[] targets = fileNameMapper.mapFileName("fromfilename");
4
        assertNotNull("no filenames mapped", targets);
4
        assertNotNull("no filenames mapped", targets);
5
        assertEquals("wrong number of filenames mapped", 2, targets.length);
5
        assertEquals("wrong number of filenames mapped", 3, targets.length);
6
        List list = Arrays.asList(targets);
6
        List list = Arrays.asList(targets);
7
        assertTrue("cannot find expected target \"def\"",
7
        assertTrue("cannot find expected target \"tofilename\"",
8
 list.contains("def"));
8
            list.contains("tofilename"));
9
        assertTrue("cannot find expected target \"ghi\"",
9
        assertTrue("cannot find expected target \"fromfilename\"",
10
 list.contains("ghi"));
10
            list.contains("fromfilename"));
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones locationClones are declared in the same class
Number of node comparisons40
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                          
    13
    container.add(mapper3);
    Preondition Violations
    Unmatched statement container.add(mapper3); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    13
    container.add(mapper3);
    20
    chained.addConfiguredMapper(mapperCX);
    20
    chained.addConfiguredMapper(mapperCX);
    Preondition Violations
    Unmatched statement chained.addConfiguredMapper(mapperCX); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                        
    21
    FileNameMapper fileNameMapper = chained.getImplementation();
    21
    FileNameMapper fileNameMapper = chained.getImplementation();
    14
    FileNameMapper fileNameMapper = container.getImplementation();
    Differences
    Expression1Expression2Difference
    chainedcontainerVARIABLE_NAME_MISMATCH
    14
    FileNameMapper fileNameMapper = container.getImplementation();
    22
    String[] targets = fileNameMapper.mapFileName("a");
    22
    String[] targets = fileNameMapper.mapFileName("a");
    15
    String[] targets = fileNameMapper.mapFileName("fromfilename");
    Differences
    Expression1Expression2Difference
    "a""fromfilename"LITERAL_VALUE_MISMATCH
    15
    String[] targets = fileNameMapper.mapFileName("fromfilename");
    23
    assertNotNull("no filenames mapped", targets);
    16
    assertNotNull("no filenames mapped", targets);
    24
    assertEquals("wrong number of filenames mapped", 2, targets.length);
    24
    assertEquals("wrong number of filenames mapped", 2, targets.length);
    17
    assertEquals("wrong number of filenames mapped", 3, targets.length);
    Differences
    Expression1Expression2Difference
    23LITERAL_VALUE_MISMATCH
    17
    assertEquals("wrong number of filenames mapped", 3, targets.length);
    25
    List list = Arrays.asList(targets);
    18
    List list = Arrays.asList(targets);
    26
    assertTrue("cannot find expected target \"def\"", list.contains("def"));
    26
    assertTrue("cannot find expected target \"def\"", list.contains("def"));
    19
    assertTrue("cannot find expected target \"tofilename\"", list.contains("tofilename"));
    Differences
    Expression1Expression2Difference
    "cannot find expected target \"def\"""cannot find expected target \"tofilename\""LITERAL_VALUE_MISMATCH
    "def""tofilename"LITERAL_VALUE_MISMATCH
    19
    assertTrue("cannot find expected target \"tofilename\"", list.contains("tofilename"));
    27
    assertTrue("cannot find expected target \"ghi\"", list.contains("ghi"));
    27
    assertTrue("cannot find expected target \"ghi\"", list.contains("ghi"));
    20
    assertTrue("cannot find expected target \"fromfilename\"", list.contains("fromfilename"));
    Differences
    Expression1Expression2Difference
    "cannot find expected target \"ghi\"""cannot find expected target \"fromfilename\""LITERAL_VALUE_MISMATCH
    "ghi""fromfilename"LITERAL_VALUE_MISMATCH
    20
    assertTrue("cannot find expected target \"fromfilename\"", list.contains("fromfilename"));
    Precondition Violations (3)
    Row Violation
    1Unmatched statement container.add(mapper3); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement chained.addConfiguredMapper(mapperCX); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Clone fragment #1 returns variables , while Clone fragment #2 returns variables list