### Question:
InstanceDao { public void insert(final InstanceModel... instances) { if ((instances == null) || (instances.length == 0)) { return; } this.insert(Lists.newArrayList(instances)); } 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 testInsert() { final InstanceModel instance1 = InstanceModels.newInstanceModel(); final InstanceModel instance2 = InstanceModels.newInstanceModel(); final List<InstanceModel> instances = Lists.newArrayList(instance1, instance2); instanceDao.insert(instance1, instance2); instanceDao.insert(instances); for (final InstanceModel instance : instances) { final List<InstanceModel> instanceModels = query(instance); Assert.assertTrue(instanceModels.size() == 1); InstanceModels.assertInstance(instance, instanceModels.get(0)); instance.setOperatorId(InstanceModels.newInstanceModel().getOperatorId()); instance.setToken(InstanceModels.newInstanceModel().getToken()); } instanceDao.insert(instances); for (final InstanceModel instance : instances) { final List<InstanceModel> instanceModels = query(instance); Assert.assertTrue(instanceModels.size() == 1); InstanceModels.assertInstance(instance, instanceModels.get(0)); } }