@Test public void testReplaceUsers() { List<ReadUser> allUsers = Users.defaultUsers().list(); File tmpDir = Files.createTempDir(); File users = new File(tmpDir, "users.csv"); try { PrintWriter userPrintWriter = new PrintWriter(new BufferedWriter(new FileWriter(users, false))); userPrintWriter.println("姓名,帐号,微信号,手机号,邮箱,所在部门,职位"); for (ReadUser user : allUsers) { CreateUser createUser = new CreateUser(); createUser.setName(user.getName()); createUser.setMobile(user.getMobile()); createUser.setUserId(user.getUserId()); createUser.setPosition(user.getPosition()); createUser.setWeixinId(user.getWeixinId()); createUser.setDepartment(user.getDepartment()); createUser.setEmail(user.getEmail()); userPrintWriter.print(csv(createUser)); } userPrintWriter.close(); String job = Jobs.defaultJobs().replaceUsers(users); while (true) { JobResult jobResult = Jobs.defaultJobs().getResult(job); if (3 == jobResult.getStatus()) { if (100 == jobResult.getPercentage()) { Assert.assertTrue(true); } break; } else { System.out.println("正在同步:" + jobResult.getPercentage()); sleep(10); } } } catch (Exception e) { e.printStackTrace(); Assert.fail("test failed."); } finally { try { FileUtils.forceDelete(tmpDir); } catch (IOException e) { } } }
public String replaceUsers(File file) { String mediaId = mediaUpload(file); return replaceUsers(mediaId); }
Jobs { public String replaceUsers(File file) { String mediaId = mediaUpload(file); return replaceUsers(mediaId); } }
Jobs { public String replaceUsers(File file) { String mediaId = mediaUpload(file); return replaceUsers(mediaId); }  }
Jobs { public String replaceUsers(File file) { String mediaId = mediaUpload(file); return replaceUsers(mediaId); }  static Jobs defaultJobs(); static Jobs with(CorpSetting corpSetting); void setWxClient(WxClient wxClient); String invite(List<String> users, List<Integer> departments, List<Integer> tags); JobResult getResult(String id); String syncUsers(File file); String syncUsers(String mediaId); String replaceUsers(File file); String replaceUsers(String mediaId); String replaceDepartments(File file); String replaceDepartments(String mediaId); }
Jobs { public String replaceUsers(File file) { String mediaId = mediaUpload(file); return replaceUsers(mediaId); }  static Jobs defaultJobs(); static Jobs with(CorpSetting corpSetting); void setWxClient(WxClient wxClient); String invite(List<String> users, List<Integer> departments, List<Integer> tags); JobResult getResult(String id); String syncUsers(File file); String syncUsers(String mediaId); String replaceUsers(File file); String replaceUsers(String mediaId); String replaceDepartments(File file); String replaceDepartments(String mediaId);  }