OrganizationServiceImpl extends AbstractConsoleService<OrganizationTblDao> implements OrganizationService { 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; }  @Override void updateOrganizations(); @Override List<OrganizationTbl> getAllOrganizations(); @Override OrganizationTbl getOrganizationTblByCMSOrganiztionId(long organizationId); @Override OrganizationTbl getOrgByName(String name); @Override List<OrganizationTbl> getInvolvedOrgs(); @Override OrganizationTbl getOrganization(long xpipeOrgId);  }
@Test public void testGetOrgTblUpdateList() { List<OrganizationTbl> remoteDBOrgs = createOrganizationTblList(10) .stream().map(org->org.setOrgName(org.getOrgName() + "-suffix")).collect(Collectors.toList()); List<OrganizationTbl> localDBOrgs = createOrganizationTblList(10); List<OrganizationTbl> result = organizationService.getOrgTblUpdateList(remoteDBOrgs, localDBOrgs); result.forEach(org->logger.info("org id: {}, org name: {}", org.getOrgId(), org.getOrgName())); Assert.assertEquals(10, result.size()); }