use of com.ctrip.xpipe.redis.console.model.OrganizationTbl in project x-pipe by ctripcorp.
the class OrganizationServiceImpl method getOrgTblUpdateList.
List<OrganizationTbl> getOrgTblUpdateList(List<OrganizationTbl> remoteDBOrgs, List<OrganizationTbl> localDBOrgs) {
Map<Long, OrganizationTbl> storedOrgTbl = Maps.newHashMapWithExpectedSize(localDBOrgs.size());
localDBOrgs.forEach(org -> storedOrgTbl.put(org.getOrgId(), org));
List<OrganizationTbl> result = Lists.newArrayListWithCapacity(localDBOrgs.size());
for (OrganizationTbl remoteOrg : remoteDBOrgs) {
OrganizationTbl localOrg = storedOrgTbl.get(remoteOrg.getOrgId());
if (localOrg != null && !StringUtil.trimEquals(localOrg.getOrgName(), remoteOrg.getOrgName())) {
result.add(localOrg.setOrgName(remoteOrg.getOrgName()));
}
}
return result;
}
use of com.ctrip.xpipe.redis.console.model.OrganizationTbl in project x-pipe by ctripcorp.
the class ClusterDaoTest method testFindClusterAndOrgByName.
@Test
public void testFindClusterAndOrgByName() throws DalException {
String clusterName = "cluster2";
ClusterTbl clusterTbl1 = clusterDao.findClusterAndOrgByName(clusterName);
List<OrganizationTbl> orgs = organizationService.getAllOrganizations();
orgs.forEach(org -> logger.info("{}", org));
logger.info("{}", clusterTbl1);
Assert.assertEquals(2L, (long) clusterTbl1.getOrganizationInfo().getId());
Assert.assertEquals("org-1", clusterTbl1.getClusterOrgName());
}
use of com.ctrip.xpipe.redis.console.model.OrganizationTbl in project x-pipe by ctripcorp.
the class OrganizationDaoTest method createOrgTbl.
private OrganizationTbl createOrgTbl(long orgId, String orgName) {
OrganizationTbl organizationTbl = new OrganizationTbl();
organizationTbl.setOrgId(orgId).setOrgName(orgName);
return organizationTbl;
}
use of com.ctrip.xpipe.redis.console.model.OrganizationTbl in project x-pipe by ctripcorp.
the class OrganizationDaoTest method testFindByOrgId.
@Test
public void testFindByOrgId() {
organizationDao.createBatchOrganizations(createBatchOrgTbl(5));
OrganizationTbl organizationTbl = organizationDao.findByOrgId(2L);
Assert.assertEquals(2L, organizationTbl.getOrgId());
}
use of com.ctrip.xpipe.redis.console.model.OrganizationTbl in project x-pipe by ctripcorp.
the class OrganizationServiceImplTest method testUpdateOrganizations.
@Test
public void testUpdateOrganizations() {
List<OrganizationTbl> localDbOrgs = createOrganizationTblList(10);
organizationDao.createBatchOrganizations(localDbOrgs);
localDbOrgs = organizationService.getAllOrganizations();
List<OrganizationTbl> remoteDbOrgs = Lists.newArrayList(localDbOrgs);
OrganizationTbl org = new OrganizationTbl().setOrgId(remoteDbOrgs.get(0).getOrgId()).setOrgName("test-different");
remoteDbOrgs.set(0, org);
List<OrganizationTbl> result = organizationService.getOrgTblUpdateList(remoteDbOrgs, localDbOrgs);
Assert.assertEquals(1, result.size());
Assert.assertEquals("test-different", result.get(0).getOrgName());
OrganizationTbl organizationTbl = organizationService.getOrganizationTblByCMSOrganiztionId(result.get(0).getOrgId());
System.out.println(organizationTbl.getOrgName());
}
Aggregations