### Question:
InstanceDao { public void destroyServers(final List<ServerKey> serverKeys) { if (CollectionUtils.isEmpty(serverKeys)) { return; } DataConfig.jdbcTemplate().batchUpdate("delete from instance where region_id=? and instance_id=?", new BatchPreparedStatementSetter() { @Override public int getBatchSize() { return serverKeys.size(); } @Override public void setValues(final PreparedStatement ps, final int index) throws SQLException { ServerKey serverKey = serverKeys.get(index); ps.setString(1, serverKey.getRegionId()); ps.setString(2, serverKey.getServerId()); } }); } private  InstanceDao(); List<InstanceModel> queryInstance(final String regionId, final String serviceId, final String instanceId); List<InstanceModel> queryInstances(final String regionId); List<InstanceModel> queryInstances(); List<InstanceModel> queryInstances(final String regionId, final List<String> serviceIds); List<InstanceModel> query(final String condition, final String... args); void delete(final Long... ids); void delete(final InstanceModel... instances); void delete(final List<InstanceModel> instances); void destroyServers(final List<ServerKey> serverKeys); void insert(final InstanceModel... instances); void insert(final List<InstanceModel> instances); static final InstanceDao INSTANCE; }### Answer:
@Test public void testDestroyServers() { final InstanceModel instance1 = InstanceModels.newInstanceModel(); final InstanceModel instance2 = InstanceModels.newInstanceModel(); final List<InstanceModel> instances = Lists.newArrayList(instance1, instance2); instanceDao.insert(instances); List<ServerKey> serverKeys = Lists.newArrayList(); for (final InstanceModel instance : instances) { serverKeys.add(new ServerKey(instance.getRegionId(), instance.getInstanceId())); List<InstanceModel> instanceModels = query(instance); Assert.assertEquals(1, instanceModels.size()); } instanceDao.destroyServers(serverKeys); for (final InstanceModel instance : instances) { List<InstanceModel> instanceModels = query(instance); Assert.assertEquals(0, instanceModels.size()); } }