Skip to content

Commit 29fc727

Browse files
committed
add PropertyCopier's Unit Test
1 parent 31ed79d commit 29fc727

File tree

3 files changed

+140
-0
lines changed

3 files changed

+140
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* Copyright 2009-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.apache.ibatis.reflection.property;
17+
18+
import org.junit.jupiter.api.Assertions;
19+
import org.junit.jupiter.api.Test;
20+
21+
/**
22+
* @author zhanghanlin
23+
*/
24+
class PropertyCopierTest {
25+
26+
@Test
27+
void testCopyBeanProperties() {
28+
29+
PropertyTestClass sourceBean =
30+
new PropertyTestClass("superStr", "childStr", 1, false);
31+
PropertyTestClass destinationBean =
32+
new PropertyTestClass();
33+
PropertyCopier.copyBeanProperties(PropertyTestClass.class,sourceBean,destinationBean);
34+
35+
Assertions.assertEquals("childStr",destinationBean.getTestStr());
36+
Assertions.assertEquals(1,destinationBean.getTestInt());
37+
Assertions.assertEquals(false,destinationBean.getTestBool());
38+
Assertions.assertEquals("superStr",destinationBean.getSupStr());
39+
40+
}
41+
42+
43+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* Copyright 2009-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.apache.ibatis.reflection.property;
17+
18+
public class PropertyTestClass extends SuperPropertyTestClass{
19+
20+
private String testStr;
21+
private Integer testInt;
22+
private Boolean testBool;
23+
24+
public PropertyTestClass(String supStr, String testStr, Integer testInt, Boolean testBool) {
25+
super(supStr);
26+
this.testStr = testStr;
27+
this.testInt = testInt;
28+
this.testBool = testBool;
29+
}
30+
31+
public PropertyTestClass() {
32+
super();
33+
}
34+
35+
public String getTestStr() {
36+
return testStr;
37+
}
38+
39+
public void setTestStr(String testStr) {
40+
this.testStr = testStr;
41+
}
42+
43+
public Integer getTestInt() {
44+
return testInt;
45+
}
46+
47+
public void setTestInt(Integer testInt) {
48+
this.testInt = testInt;
49+
}
50+
51+
public Boolean getTestBool() {
52+
return testBool;
53+
}
54+
55+
public void setTestBool(Boolean testBool) {
56+
this.testBool = testBool;
57+
}
58+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Copyright 2009-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.apache.ibatis.reflection.property;
17+
18+
/**
19+
* @author zhanghanlin
20+
*/
21+
public class SuperPropertyTestClass {
22+
23+
private String supStr ;
24+
25+
public SuperPropertyTestClass(String supStr) {
26+
this.supStr = supStr;
27+
}
28+
29+
public SuperPropertyTestClass() {
30+
}
31+
32+
public String getSupStr() {
33+
return supStr;
34+
}
35+
36+
public void setSupStr(String supStr) {
37+
this.supStr = supStr;
38+
}
39+
}

0 commit comments

Comments
 (0)