Skip to content

Commit 9285810

Browse files
author
zhangrongfan
committed
Improve testing entity
1 parent d6d6606 commit 9285810

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

mybatis-boost-core/src/main/java/cn/mybatisboost/support/Property.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cn.mybatisboost.support;
22

3+
import java.util.NoSuchElementException;
34
import java.util.Objects;
45
import java.util.function.Consumer;
56
import java.util.function.Supplier;
@@ -31,6 +32,9 @@ public static <T> Property<T> ofNullable(T value) {
3132
}
3233

3334
public T get() {
35+
if (value == null) {
36+
throw new NoSuchElementException("No value present");
37+
}
3438
return value;
3539
}
3640

mybatis-boost-test/src/main/java/cn/mybatisboost/test/Project.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ public Project setDeveloper(String developer) {
7979
}
8080

8181

82-
public Website getWebsite() {
83-
return website.get();
82+
public Property<Website> getWebsite() {
83+
return website;
8484
}
8585

8686
public void setWebsite(Website website) {

mybatis-boost-test/src/test/java/cn/mybatisboost/test/JsonTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public void testQuery() throws Exception {
5252
jdbcTemplate.execute("insert into project (id, group_id, website) values (999, 'cn.mybatisboost', '" + objectMapper.writeValueAsString(project.getWebsite()) + "')");
5353
project = mapper.selectById(999);
5454
assertNotNull(project);
55-
assertEquals("HTTPS", project.getWebsite().getProtocol());
56-
assertEquals("mybatisboost.cn", project.getWebsite().getHost());
57-
assertEquals(80, project.getWebsite().getPort());
55+
assertEquals("HTTPS", project.getWebsite().get().getProtocol());
56+
assertEquals("mybatisboost.cn", project.getWebsite().get().getHost());
57+
assertEquals(80, project.getWebsite().get().getPort());
5858
}
5959
}

0 commit comments

Comments
 (0)