Search in sources :

Example 1 with OrganizationTbl

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;
}
Also used : OrganizationTbl(com.ctrip.xpipe.redis.console.model.OrganizationTbl)

Example 2 with OrganizationTbl

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());
}
Also used : ClusterTbl(com.ctrip.xpipe.redis.console.model.ClusterTbl) OrganizationTbl(com.ctrip.xpipe.redis.console.model.OrganizationTbl) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 3 with OrganizationTbl

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;
}
Also used : OrganizationTbl(com.ctrip.xpipe.redis.console.model.OrganizationTbl)

Example 4 with 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());
}
Also used : OrganizationTbl(com.ctrip.xpipe.redis.console.model.OrganizationTbl) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 5 with OrganizationTbl

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());
}
Also used : OrganizationTbl(com.ctrip.xpipe.redis.console.model.OrganizationTbl) Test(org.junit.Test)

Aggregations

OrganizationTbl (com.ctrip.xpipe.redis.console.model.OrganizationTbl)7 Test (org.junit.Test)4 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)2 ClusterTbl (com.ctrip.xpipe.redis.console.model.ClusterTbl)1 DcTbl (com.ctrip.xpipe.redis.console.model.DcTbl)1