### Question:
HBCK2 extends Configured implements org.apache.hadoop.util.Tool { int setRegionState(ClusterConnection connection, String region, RegionState.State newState) throws IOException { if (newState == null) { throw new IllegalArgumentException("State can't be null."); } RegionState.State currentState = null; Table table = connection.getTable(TableName.valueOf("hbase:meta")); RowFilter filter = new RowFilter(CompareOperator.EQUAL, new SubstringComparator(region)); Scan scan = new Scan(); scan.setFilter(filter); Result result = table.getScanner(scan).next(); if (result != null) { byte[] currentStateValue = result.getValue(HConstants.CATALOG_FAMILY, HConstants.STATE_QUALIFIER); if (currentStateValue == null) { System.out.println("WARN: Region state info on meta was NULL"); } else { currentState = RegionState.State.valueOf( org.apache.hadoop.hbase.util.Bytes.toString(currentStateValue)); } Put put = new Put(result.getRow()); put.addColumn(HConstants.CATALOG_FAMILY, HConstants.STATE_QUALIFIER, org.apache.hadoop.hbase.util.Bytes.toBytes(newState.name())); table.put(put); System.out.println("Changed region " + region + " STATE from " + currentState + " to " + newState); return EXIT_SUCCESS; } else { System.out.println("ERROR: Could not find region " + region + " in meta."); } return EXIT_FAILURE; } HBCK2(Configuration conf); @Override void setConf(Configuration configuration); @Override Configuration getConf(); @Override int run(String[] args); static void main(String [] args);  }### Answer:
@Test public void testSetRegionState() throws IOException { TEST_UTIL.createTable(REGION_STATES_TABLE_NAME, Bytes.toBytes("family1")); try (Admin admin = TEST_UTIL.getConnection().getAdmin()) { List<RegionInfo> regions = admin.getRegions(REGION_STATES_TABLE_NAME); RegionInfo info = regions.get(0); assertEquals(RegionState.State.OPEN, getCurrentRegionState(info)); String region = info.getEncodedName(); try (ClusterConnection connection = this.hbck2.connect()) { this.hbck2.setRegionState(connection, region, RegionState.State.CLOSING); } assertEquals(RegionState.State.CLOSING, getCurrentRegionState(info)); } finally { TEST_UTIL.deleteTable(REGION_STATES_TABLE_NAME); } }