移动类的位置。

feature/net-util
ZhouXY108 2023-05-09 14:32:14 +08:00
parent fa3f4695f1
commit c8e61a2a82
3 changed files with 9 additions and 12 deletions

View File

@ -1,4 +1,4 @@
package xyz.zhouxy.plusone.commons.util;
package xyz.zhouxy.plusone.commons.jdbc;
import java.util.ArrayList;
import java.util.Collection;
@ -15,6 +15,10 @@ import java.util.Set;
import com.google.common.annotations.Beta;
import xyz.zhouxy.plusone.commons.util.AbstractMapWrapper;
import xyz.zhouxy.plusone.commons.util.Assert;
import xyz.zhouxy.plusone.commons.util.OptionalUtil;
@Beta
public class DbRecord extends AbstractMapWrapper<String, Object, DbRecord> {

View File

@ -19,7 +19,6 @@ import org.apache.commons.lang3.ArrayUtils;
import com.google.common.annotations.Beta;
import xyz.zhouxy.plusone.commons.util.DbRecord;
import xyz.zhouxy.plusone.commons.util.MoreCollections;
@Beta

View File

@ -1,14 +1,11 @@
package xyz.zhouxy.plusone.commons.util;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.sql.DataSource;
@ -19,6 +16,7 @@ import org.slf4j.LoggerFactory;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import xyz.zhouxy.plusone.commons.jdbc.DbRecord;
import xyz.zhouxy.plusone.commons.jdbc.JdbcUtil;
class JdbcUtilTests {
@ -51,14 +49,10 @@ class JdbcUtilTests {
@Test
void testQuery() throws SQLException {
Connection conn = this.dataSource.getConnection();
List<Map<String, Object>> ms = JdbcUtil.connect(conn).query(
List<DbRecord> rs = JdbcUtil.connect(conn).queryToRecordList(
"SELECT * FROM public.base_table WHERE id IN (?, ?, ?)", 501533, 501554, 544599);
assertNotNull(ms);
List<DbRecord> es = ms.stream()
.map(input -> new DbRecord().putAll(input))
.collect(Collectors.toList());
assertEquals(3, es.size());
for (DbRecord baseEntity : es) {
assertEquals(3, rs.size());
for (DbRecord baseEntity : rs) {
log.info("id: {}", baseEntity.getValueAsLong("id"));
assertNull(baseEntity.getValueAsString("updated_by"));
}