try {
cfg.addResource( resourceName );
fail();
}
catch ( InvalidMappingException inv ) {
assertEquals( inv.getType(), "resource" );
assertEquals( inv.getPath(), resourceName );
assertClassAssignability( inv.getCause().getClass(), DuplicateMappingException.class );
}
try {
cfg.addFile( file );
fail();
}
catch ( InvalidMappingException inv ) {
assertEquals( inv.getType(), "file" );
assertEquals( inv.getPath(), file.getPath() );
assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
}
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/mappingexception/MappingExceptionTest.java
|
|
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/mappingexception/MappingExceptionTest.java
|
Method name: void testDuplicateMapping()
|
|
Method name: void testInvalidMapping()
|
Number of AST nodes: 3
|
|
Number of AST nodes: 3
|
|
1 | try {↵ | | 1 | try {↵
|
2 | cfg.addResource( resourceName );↵ | | 2 | cfg.addFile( file );↵
|
3 | fail();↵ | | 3 | fail();↵
|
4 | }↵ | | 4 | }↵
|
5 | catch ( InvalidMappingException inv ) {↵ | | 5 | catch ( InvalidMappingException inv ) {↵
|
6 | assertEquals( inv.getType(), "resource" );↵ | | 6 | assertEquals( inv.getType(), "file" );↵
|
7 | assertEquals( inv.getPath(), resourceName );↵ | | 7 | assertEquals( inv.getPath(), ↵
|
8 | assertClassAssignability( inv.getCause().getClass(), DuplicateMapping↵ | | 8 | file.getPath() );↵
|
9 | Exception.class );↵ | | 9 | assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );↵
|
10 | } | | 10 | }
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.3 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 9 |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 2 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 3.9 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
4 | try | | 18 | try |
5 | cfg.addResource(resourceName); | | | |
| | | 19 | |
6 | | | 20 | |
Precondition Violations (6)
Row |
Violation |
1 | Expression assertClassAssignability(inv.getCause().getClass(),DuplicateMappingException.class) is a void method call, and thus it cannot be parameterized |
2 | Expression assertTrue(!(inv.getCause() instanceof MappingNotFoundException)) is a void method call, and thus it cannot be parameterized |
3 | Expression assertClassAssignability(inv.getCause().getClass(),DuplicateMappingException.class) is a void method call, and thus it cannot be parameterized |
4 | Expression assertTrue(!(inv.getCause() instanceof MappingNotFoundException)) is a void method call, and thus it cannot be parameterized |
5 | Unmatched statement cfg.addResource(resourceName); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
6 | Unmatched statement cfg.addFile(file); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |