ClusterServiceImpl extends AbstractConsoleService<ClusterTblDao> implements ClusterService { public boolean checkEmails(String emails) { if(emails == null || emails.trim().isEmpty()) { return false; } String splitter = "\\s*(,|;)\\s*"; String[] emailStrs = StringUtil.splitRemoveEmpty(splitter, emails); for(String email : emailStrs) { EmailService.CheckEmailResponse response = EmailService.DEFAULT.checkEmailAddress(email); if(!response.isOk()) return false; } return true; }  @Override ClusterTbl find(final String clusterName); @Override List<ClusterTbl> findAllByNames(List<String> clusterNames); @Override ClusterStatus clusterStatus(String clusterName); @Override List<DcTbl> getClusterRelatedDcs(String clusterName); @Override ClusterTbl find(final long clusterId); @Override List<String> findAllClusterNames(); @Override Long getAllCount(); @Override @DalTransaction synchronized ClusterTbl createCluster(ClusterModel clusterModel); long getOrgIdFromClusterOrgName(ClusterTbl cluster); @Override ClusterTbl findClusterAndOrg(String clusterName); @Override List<ClusterTbl> findClustersWithOrgInfoByActiveDcId(long activeDc); @Override List<ClusterTbl> findAllClustersWithOrgInfo(); @Override List<ClusterTbl> findClustersWithOrgInfoByClusterType(String clusterType); @Override void updateCluster(String clusterName, ClusterTbl cluster); @Override void updateActivedcId(long id, long activeDcId); @Override void updateStatusById(long id, ClusterStatus clusterStatus); @Override void deleteCluster(String clusterName); @Override void bindDc(String clusterName, String dcName); @Override void unbindDc(String clusterName, String dcName); @Override void update(final ClusterTbl cluster); boolean checkEmails(String emails); @Override List<String> reBalanceSentinels(String dcName, final int numOfClusters, final boolean activeOnly); @Override void reBalanceClusterSentinels(String dcName, final List<String> clusters); @Override List<ClusterListUnhealthyClusterModel> findUnhealthyClusters(); @Override List<ClusterTbl> findAllClusterByDcNameBind(String dcName); @Override List<ClusterTbl> findActiveClustersByDcName(String dcName); @Override List<ClusterTbl> findAllClustersByDcName(String dcName); @Override List<ClusterTbl> findAllClusterByKeeperContainer(long keeperContainerId);  }
@Test public void testCheckEmails() { ClusterServiceImpl service = new ClusterServiceImpl(); String emails = "test@ctrip.com"; Assert.assertTrue(service.checkEmails(emails)); emails = "test@ctrip.com, test2@ctrip.com"; Assert.assertTrue(service.checkEmails(emails)); emails = "test@ctrip.com; test2@ctrip.com"; Assert.assertTrue(service.checkEmails(emails)); emails = "test@ctrip.com,test2@ctrip.com,test3@Ctrip.com"; Assert.assertTrue(service.checkEmails(emails)); emails = "tetsataemail@"; Assert.assertFalse(service.checkEmails(emails)); }