File path: /columba-1.4-src/mail/src/test/java/org/columba/mail/config/AccountItemTest.java | File path: /columba-1.4-src/mail/src/test/java/org/columba/mail/config/AccountItemTest.java | |||
Method name: void testEqualsObject()
|
Method name: void testHashCode()
|
|||
Number of AST nodes: 47 | Number of AST nodes: 42 | |||
1 | XmlElement xml = new XmlElement("account");↵ | 1 | XmlElement xml = new XmlElement("account");↵ | |
2 | xml.addAttribute("name", "my account");↵ | 2 | xml.addAttribute("name", "my account");↵ | |
3 | xml.addAttribute("uid", "0");↵ | 3 | xml.addAttribute("uid", "0");↵ | |
4 | XmlElement child = xml.addSubElement("identity");↵ | 4 | XmlElement child = xml.addSubElement("identity");↵ | |
5 | child.addAttribute("name", "John Doe");↵ | 5 | child.addAttribute("name", "John Doe");↵ | |
6 | child.addAttribute("attach_signature", "false");↵ | 6 | child.addAttribute("attach_signature", "false");↵ | |
7 | child = xml.addSubElement("popserver");↵ | 7 | child = xml.addSubElement("popserver");↵ | |
8 | child.addAttribute("port", "25");↵ | 8 | child.addAttribute("port", "25");↵ | |
9 | child.addAttribute("login_method", "USER");↵ | 9 | child.addAttribute("login_method", "USER");↵ | |
10 | child = xml.addSubElement("specialfolders");↵ | 10 | child = xml.addSubElement("specialfolders");↵ | |
11 | child.addAttribute("inbox", "101");↵ | 11 | child.addAttribute("inbox", "101");↵ | |
12 | child.addAttribute("sent", "104");↵ | 12 | child.addAttribute("sent", "104");↵ | |
13 | AccountItem item = new AccountItem(xml);↵ | 13 | AccountItem item = new AccountItem(xml);↵ | |
14 | // second account item↵ | 14 | // second account item↵ | |
15 | XmlElement xml2 = new XmlElement("account");↵ | 15 | XmlElement xml2 = new XmlElement("account");↵ | |
16 | xml2.addAttribute("uid", "0");↵ | 16 | xml2.addAttribute("uid", "0");↵ | |
17 | xml2.addAttribute("name", "my account");↵ | 17 | xml2.addAttribute("name", "my account");↵ | |
18 | XmlElement child2 = xml2.addSubElement("identity");↵ | 18 | XmlElement child2 = xml2.addSubElement("identity");↵ | |
19 | child2.addAttribute("attach_signature", "false");↵ | 19 | child2.addAttribute("attach_signature", "false");↵ | |
20 | child2.addAttribute("name", "John Doe");↵ | 20 | child2.addAttribute("name", "John Doe");↵ | |
21 | child2 = xml2.addSubElement("popserver");↵ | 21 | child2 = xml2.addSubElement("popserver");↵ | |
22 | child2.addAttribute("login_method", "USER");↵ | 22 | child2.addAttribute("login_method", "USER");↵ | |
23 | child2.addAttribute("port", "25");↵ | 23 | child2.addAttribute("port", "25");↵ | |
24 | child2 = xml2.addSubElement("specialfolders");↵ | 24 | child2 = xml2.addSubElement("specialfolders");↵ | |
25 | child2.addAttribute("sent", "104");↵ | 25 | child2.addAttribute("sent", "104");↵ | |
26 | child2.addAttribute("inbox", "101");↵ | 26 | child2.addAttribute("inbox", "101");↵ | |
27 | AccountItem item2 = new AccountItem(xml2);↵ | 27 | AccountItem item2 = new AccountItem(xml2);↵ | |
28 | // third item, a bit different from the first↵ | 28 | // third item, a bit different from the first↵ | |
29 | XmlElement xml3 = new XmlElement("account");↵ | 29 | XmlElement xml3 = new XmlElement("account");↵ | |
30 | xml3.addAttribute("name", "my account");↵ | 30 | xml3.addAttribute("name", "my account");↵ | |
31 | xml3.addAttribute("uid", "0");↵ | 31 | xml3.addAttribute("uid", "0");↵ | |
32 | XmlElement child3 = xml3.addSubElement("identity");↵ | 32 | XmlElement child3 = xml3.addSubElement("identity");↵ | |
33 | child3.addAttribute("name", "Kalle Kamel");↵ | 33 | child3.addAttribute("name", "Kalle Kamel");↵ | |
34 | child3.addAttribute("attach_signature", "false");↵ | 34 | child3.addAttribute("attach_signature", "false");↵ | |
35 | child3 = xml3.addSubElement("popserver");↵ | 35 | child3 = xml3.addSubElement("popserver");↵ | |
36 | child3.addAttribute("port", "25");↵ | 36 | child3.addAttribute("port", "25");↵ | |
37 | child3.addAttribute("login_method", "USER");↵ | 37 | child3.addAttribute("login_method", "USER");↵ | |
38 | child3 = xml3.addSubElement("specialfolders");↵ | 38 | child3 = xml3.addSubElement("specialfolders");↵ | |
39 | child3.addAttribute("inbox", "101");↵ | 39 | child3.addAttribute("inbox", "101");↵ | |
40 | child3.addAttribute("sent", "104");↵ | 40 | child3.addAttribute("sent", "104");↵ | |
41 | AccountItem item3 = new AccountItem(xml3);↵ | 41 | AccountItem item3 = new AccountItem(xml3);↵ | |
42 | // test self equality...↵ | 42 | // ↵ | |
43 | assertTrue("Self equality failed for item", item.equals(item));↵ | |||
44 | assertTrue("Self equality failed for item2", item2.equals(item2));↵ | |||
45 | // item and item2 should be equal...↵ | |||
46 | assertTrue("item and item2 are not equal", item.equals(item2));↵ | |||
47 | assertTrue("item2 and item are not equal", item2.equals(item));↵ | |||
48 | // item and item2 should be two different objects↵ | |||
49 | assertNotSame("item and item2 refers to the same object", item, item2);↵ | |||
50 | // item should not be equal to↵ | 43 | should have the same hashcodes...↵ | |
44 | assertTrue("The hashcodes of item and item2 are not the same",↵ | |||
45 | item.hashCode() == item2.hashCode());↵ | |||
51 | a newly created item or null↵ | 46 | // expect a different hashcode from a newly created item...↵ | |
52 | assertFalse("item is equal to a newly created AccountItem",↵ | 47 | assertFalse("The hashcodes of item and a new object are the same",↵ | |
53 | item.equals(new AccountItem(new XmlElement())));↵ | 48 | item.hashCode() == (new AccountItem(new XmlElement()))↵ | |
54 | assertFalse("item is equal to null", item.equals(null));↵ | |||
55 | // item and item3 should not be equal↵ | 49 | .hashCode());↵ | |
50 | // expect a different hashcode for item and item3↵ | |||
56 | assertFalse("item and item3 are equal", item.equals(item3↵ | 51 | assertFalse("The hashcodes of item and item3 are the same",↵ | |
57 | )); | 52 | item.hashCode() == item3.hashCode()); | |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.0 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 742 |
Number of mapped statements | 42 |
Number of unmapped statements in the first code fragment | 5 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | XmlElement xml = new XmlElement("account"); | 1 | XmlElement xml = new XmlElement("account"); | ||||||||||||||||
2 | xml.addAttribute("name", "my account"); | 2 | xml.addAttribute("name", "my account"); | ||||||||||||||||
3 | xml.addAttribute("uid", "0"); | 3 | xml.addAttribute("uid", "0"); | ||||||||||||||||
4 | XmlElement child = xml.addSubElement("identity"); | 4 | XmlElement child = xml.addSubElement("identity"); | ||||||||||||||||
5 | child.addAttribute("name", "John Doe"); | 5 | child.addAttribute("name", "John Doe"); | ||||||||||||||||
6 | child.addAttribute("attach_signature", "false"); | 6 | child.addAttribute("attach_signature", "false"); | ||||||||||||||||
7 | child = xml.addSubElement("popserver"); | 7 | child = xml.addSubElement("popserver"); | ||||||||||||||||
8 | child.addAttribute("port", "25"); | 8 | child.addAttribute("port", "25"); | ||||||||||||||||
9 | child.addAttribute("login_method", "USER"); | 9 | child.addAttribute("login_method", "USER"); | ||||||||||||||||
10 | child = xml.addSubElement("specialfolders"); | 10 | child = xml.addSubElement("specialfolders"); | ||||||||||||||||
11 | child.addAttribute("inbox", "101"); | 11 | child.addAttribute("inbox", "101"); | ||||||||||||||||
12 | child.addAttribute("sent", "104"); | 12 | child.addAttribute("sent", "104"); | ||||||||||||||||
13 | AccountItem item = new AccountItem(xml); | 13 | AccountItem item = new AccountItem(xml); | ||||||||||||||||
14 | XmlElement xml2 = new XmlElement("account"); | 14 | XmlElement xml2 = new XmlElement("account"); | ||||||||||||||||
15 | xml2.addAttribute("uid", "0"); | 15 | xml2.addAttribute("uid", "0"); | ||||||||||||||||
16 | xml2.addAttribute("name", "my account"); | 16 | xml2.addAttribute("name", "my account"); | ||||||||||||||||
17 | XmlElement child2 = xml2.addSubElement("identity"); | 17 | XmlElement child2 = xml2.addSubElement("identity"); | ||||||||||||||||
18 | child2.addAttribute("attach_signature", "false"); | 18 | child2.addAttribute("attach_signature", "false"); | ||||||||||||||||
19 | child2.addAttribute("name", "John Doe"); | 19 | child2.addAttribute("name", "John Doe"); | ||||||||||||||||
20 | child2 = xml2.addSubElement("popserver"); | 20 | child2 = xml2.addSubElement("popserver"); | ||||||||||||||||
21 | child2.addAttribute("login_method", "USER"); | 21 | child2.addAttribute("login_method", "USER"); | ||||||||||||||||
22 | child2.addAttribute("port", "25"); | 22 | child2.addAttribute("port", "25"); | ||||||||||||||||
23 | child2 = xml2.addSubElement("specialfolders"); | 23 | child2 = xml2.addSubElement("specialfolders"); | ||||||||||||||||
24 | child2.addAttribute("sent", "104"); | 24 | child2.addAttribute("sent", "104"); | ||||||||||||||||
25 | child2.addAttribute("inbox", "101"); | 25 | child2.addAttribute("inbox", "101"); | ||||||||||||||||
26 | AccountItem item2 = new AccountItem(xml2); | 26 | AccountItem item2 = new AccountItem(xml2); | ||||||||||||||||
27 | XmlElement xml3 = new XmlElement("account"); | 27 | XmlElement xml3 = new XmlElement("account"); | ||||||||||||||||
28 | xml3.addAttribute("name", "my account"); | 28 | xml3.addAttribute("name", "my account"); | ||||||||||||||||
29 | xml3.addAttribute("uid", "0"); | 29 | xml3.addAttribute("uid", "0"); | ||||||||||||||||
30 | XmlElement child3 = xml3.addSubElement("identity"); | 30 | XmlElement child3 = xml3.addSubElement("identity"); | ||||||||||||||||
31 | child3.addAttribute("name", "Kalle Kamel"); | 31 | child3.addAttribute("name", "Kalle Kamel"); | ||||||||||||||||
32 | child3.addAttribute("attach_signature", "false"); | 32 | child3.addAttribute("attach_signature", "false"); | ||||||||||||||||
33 | child3 = xml3.addSubElement("popserver"); | 33 | child3 = xml3.addSubElement("popserver"); | ||||||||||||||||
34 | child3.addAttribute("port", "25"); | 34 | child3.addAttribute("port", "25"); | ||||||||||||||||
35 | child3.addAttribute("login_method", "USER"); | 35 | child3.addAttribute("login_method", "USER"); | ||||||||||||||||
36 | child3 = xml3.addSubElement("specialfolders"); | 36 | child3 = xml3.addSubElement("specialfolders"); | ||||||||||||||||
37 | child3.addAttribute("inbox", "101"); | 37 | child3.addAttribute("inbox", "101"); | ||||||||||||||||
38 | child3.addAttribute("sent", "104"); | 38 | child3.addAttribute("sent", "104"); | ||||||||||||||||
39 | AccountItem item3 = new AccountItem(xml3); | 39 | AccountItem item3 = new AccountItem(xml3); | ||||||||||||||||
40 | assertTrue("Self equality failed for item", item.equals(item)); |
| 40 | assertTrue("The hashcodes of item and item2 are not the same", item.hashCode() == item2.hashCode()); | |||||||||||||||
41 | assertTrue("Self equality failed for item2", item2.equals(item2)); |
| | ||||||||||||||||
42 | assertTrue("item and item2 are not equal", item.equals(item2)); |
| | ||||||||||||||||
43 | assertTrue("item2 and item are not equal", item2.equals(item)); |
| | ||||||||||||||||
44 | assertNotSame("item and item2 refers to the same object", item, item2); |
| | ||||||||||||||||
45 | assertFalse("item is equal to a newly created AccountItem", item.equals(new AccountItem(new XmlElement()))); |
| | ||||||||||||||||
46 | assertFalse("item is equal to null", item.equals(null)); |
| 41 | assertFalse("The hashcodes of item and a new object are the same", item.hashCode() == (new AccountItem(new XmlElement())).hashCode()); | |||||||||||||||
47 | assertFalse("item and item3 are equal", item.equals(item3)); |
| 42 | assertFalse("The hashcodes of item and item3 are the same", item.hashCode() == item3.hashCode()); |
Row | Violation |
---|---|
1 | Expression item.equals(item) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression item.hashCode() == item2.hashCode() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Unmatched statement assertTrue("Self equality failed for item2",item2.equals(item2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
4 | Unmatched statement assertTrue("item and item2 are not equal",item.equals(item2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
5 | Unmatched statement assertTrue("item2 and item are not equal",item2.equals(item)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
6 | Unmatched statement assertNotSame("item and item2 refers to the same object",item,item2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
7 | Unmatched statement assertFalse("item is equal to a newly created AccountItem",item.equals(new AccountItem(new XmlElement()))); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
8 | Expression item.equals(null) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
9 | Expression item.hashCode() == (new AccountItem(new XmlElement())).hashCode() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
10 | Expression item.equals(item3) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Expression item.hashCode() == item3.hashCode() cannot be parameterized, because it has dependencies to/from statements that will be extracted |