### Question:
EntityProvider extends AbstractObjectProvider<ENTITY> { @Override public ENTITY get(ResultSet resultSet) throws SQLException { return build(resultSet); } EntityProvider(EntityType<ENTITY> entityType, Query query, boolean resultMappingEnsured); @Override ENTITY get(ResultSet resultSet);  }### Answer:
@Test public void testGetEntity() throws Exception { MockResultSetMetaData metaData = new MockResultSetMetaData(); metaData.columns.add(new ColumnMetaData("id")); metaData.columns.add(new ColumnMetaData("name")); metaData.columns.add(new ColumnMetaData("salary")); metaData.columns.add(new ColumnMetaData("version")); MockResultSet resultSet = new MockResultSet(metaData); resultSet.rows.add(new RowData(1, "aaa", new BigDecimal(10), 100)); resultSet.next(); _Emp entityType = _Emp.getSingletonInternal(); EntityProvider<Emp> provider = new EntityProvider<>(entityType, new MySelectQuery(new MockConfig()), false); Emp emp = provider.get(resultSet); assertEquals(1, emp.getId()); assertEquals("aaa", emp.getName()); assertEquals(new BigDecimal(10), emp.getSalary()); assertEquals(100, emp.getVersion()); }
@Test public void testGetEntity_UnknownColumnException() throws Exception { MockResultSetMetaData metaData = new MockResultSetMetaData(); metaData.columns.add(new ColumnMetaData("id")); metaData.columns.add(new ColumnMetaData("name")); metaData.columns.add(new ColumnMetaData("salary")); metaData.columns.add(new ColumnMetaData("version")); metaData.columns.add(new ColumnMetaData("unknown")); MockResultSet resultSet = new MockResultSet(metaData); resultSet.rows.add(new RowData(1, "aaa", new BigDecimal(10), 100, "bbb")); resultSet.next(); _Emp entityType = _Emp.getSingletonInternal(); EntityProvider<Emp> provider = new EntityProvider<>(entityType, new MySelectQuery(new MockConfig()), false); try { provider.get(resultSet); fail(); } catch (UnknownColumnException expected) { } }
@Test public void testGetEntity_EmptyUnknownColumnHandler() throws Exception { MockResultSetMetaData metaData = new MockResultSetMetaData(); metaData.columns.add(new ColumnMetaData("id")); metaData.columns.add(new ColumnMetaData("name")); metaData.columns.add(new ColumnMetaData("salary")); metaData.columns.add(new ColumnMetaData("version")); metaData.columns.add(new ColumnMetaData("unknown")); MockResultSet resultSet = new MockResultSet(metaData); resultSet.rows.add(new RowData(1, "aaa", new BigDecimal(10), 100, "bbb")); resultSet.next(); _Emp entityType = _Emp.getSingletonInternal(); EntityProvider<Emp> provider = new EntityProvider<>( entityType, new MySelectQuery(new EmptyUnknownColumnHandlerConfig()), false); Emp emp = provider.get(resultSet); assertEquals(1, emp.getId()); assertEquals("aaa", emp.getName()); assertEquals(new BigDecimal(10), emp.getSalary()); assertEquals(100, emp.getVersion()); }