### Question:
AbstractUndoExecutor { protected Map<String, List<Field>> parsePkValues(TableRecords records) { return parsePkValues(records.getRows(), records.getTableMeta().getPrimaryKeyOnlyName()); } AbstractUndoExecutor(SQLUndoLog sqlUndoLog); SQLUndoLog getSqlUndoLog(); void executeOn(Connection conn); static final boolean IS_UNDO_DATA_VALIDATION_ENABLE; }### Answer:
@Test public void testParsePK() { TableMeta tableMeta = Mockito.mock(TableMeta.class); Mockito.when(tableMeta.getPrimaryKeyOnlyName()).thenReturn(Arrays.asList(new String[]{"id"})); Mockito.when(tableMeta.getTableName()).thenReturn("table_name"); TableRecords beforeImage = new TableRecords(); beforeImage.setTableName("table_name"); beforeImage.setTableMeta(tableMeta); List<Row> beforeRows = new ArrayList<>(); Row row0 = new Row(); Field field01 = addField(row0, "id", 1, "12345"); Field field02 = addField(row0, "age", 1, "2"); beforeRows.add(row0); Row row1 = new Row(); Field field11 = addField(row1, "id", 1, "12346"); Field field12 = addField(row1, "age", 1, "2"); beforeRows.add(row1); beforeImage.setRows(beforeRows); SQLUndoLog sqlUndoLog = new SQLUndoLog(); sqlUndoLog.setSqlType(SQLType.UPDATE); sqlUndoLog.setTableMeta(tableMeta); sqlUndoLog.setTableName("table_name"); sqlUndoLog.setBeforeImage(beforeImage); sqlUndoLog.setAfterImage(null); TestUndoExecutor executor = new TestUndoExecutor(sqlUndoLog, true); Map<String,List<Field>> pkValues = executor.parsePkValues(beforeImage); Assertions.assertEquals(2, pkValues.get("id").size()); }