| 1 |
|
package org.springframework.beans; |
| 2 |
|
|
| 3 |
|
import junit.framework.Assert; |
| 4 |
|
|
| 5 |
|
import org.junit.Test; |
| 6 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.09 |
|
| 7 |
|
public class BeanUtilsTest { |
| 8 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 4 |
Complexity Density: 1 |
|
| 9 |
|
public class A { |
| 10 |
|
String foo; |
| 11 |
|
String bar; |
| 12 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 13 |
3
|
public String getFoo() {... |
| 14 |
3
|
return foo; |
| 15 |
|
} |
| 16 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 17 |
2
|
public void setFoo(String foo) {... |
| 18 |
2
|
this.foo = foo; |
| 19 |
|
} |
| 20 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 21 |
2
|
public String getBar() {... |
| 22 |
2
|
return bar; |
| 23 |
|
} |
| 24 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 25 |
1
|
public void setBar(String bar) {... |
| 26 |
1
|
this.bar = bar; |
| 27 |
|
} |
| 28 |
|
} |
| 29 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 4 |
Complexity Density: 1 |
|
| 30 |
|
public class B { |
| 31 |
|
String foo; |
| 32 |
|
String bar; |
| 33 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 34 |
2
|
public String getFoo() {... |
| 35 |
2
|
return foo; |
| 36 |
|
} |
| 37 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 38 |
3
|
public void setFoo(String foo) {... |
| 39 |
3
|
this.foo = foo; |
| 40 |
|
} |
| 41 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 42 |
2
|
public String getBar() {... |
| 43 |
2
|
return bar; |
| 44 |
|
} |
| 45 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 46 |
2
|
public void setBar(String bar) {... |
| 47 |
2
|
this.bar = bar; |
| 48 |
|
} |
| 49 |
|
} |
| 50 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1
PASS
|
|
| 51 |
1
|
@Test... |
| 52 |
|
public void copyProperties() { |
| 53 |
1
|
A a = new A(); |
| 54 |
1
|
a.setFoo("foo"); |
| 55 |
1
|
a.setBar("bar"); |
| 56 |
|
|
| 57 |
1
|
B b = new B(); |
| 58 |
|
|
| 59 |
1
|
BeanUtils.copyProperties(a, b); |
| 60 |
1
|
Assert.assertEquals(b.getFoo(), a.getFoo()); |
| 61 |
1
|
Assert.assertEquals(b.getBar(), b.getBar()); |
| 62 |
|
|
| 63 |
1
|
a.setFoo(null); |
| 64 |
1
|
b.setFoo("foo-times-2"); |
| 65 |
|
|
| 66 |
1
|
BeanUtils.copyProperties(a, b); |
| 67 |
1
|
System.out.println(b.getFoo()); |
| 68 |
|
|
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
} |