use of com.alibaba.cobar.manager.dataobject.xml.CobarDO in project cobar by alibaba.
the class CobarDaoTest method testAddManyCobar.
@Test
public void testAddManyCobar() {
int cobarNum = 10;
for (int i = 0; i < cobarNum; i++) {
CobarDO cobar = DOFactory.getCobar();
cobar.setName("" + i);
cobarDao.addCobar(cobar);
}
// int activeCobarNum = cobarDao.getCobarCountByStatus(1L, ConstantDefine.ACTIVE);
int activeCobarNum = cobarDao.getCobarList(1L).size();
Assert.assertEquals(cobarNum, activeCobarNum);
}
use of com.alibaba.cobar.manager.dataobject.xml.CobarDO in project cobar by alibaba.
the class CobarDaoTest method testGetCobarList.
@Test
public void testGetCobarList() {
long testClusterId = 1L;
int testCobarNum = 3;
int otherCobarNum = 4;
for (int i = 0; i < testCobarNum; i++) {
CobarDO cobar = DOFactory.getCobar();
cobar.setName("test" + i);
cobar.setClusterId(testClusterId);
cobarDao.addCobar(cobar);
}
for (int i = testCobarNum; i < testCobarNum + otherCobarNum; i++) {
CobarDO cobar = DOFactory.getCobar();
cobar.setName("test" + i);
cobar.setClusterId(testClusterId + 1L);
cobarDao.addCobar(cobar);
}
Assert.assertEquals(testCobarNum, cobarDao.getCobarList(testClusterId).size());
Assert.assertEquals(0, cobarDao.getCobarList(testClusterId + 3).size());
}
use of com.alibaba.cobar.manager.dataobject.xml.CobarDO in project cobar by alibaba.
the class CobarDaoTest method testModifyNotExistCobarId.
// same as add cluster
@Test
public void testModifyNotExistCobarId() {
CobarDO cobar = DOFactory.getCobar();
cobar.setId(3);
cobarDao.modifyCobar(cobar);
read();
Assert.assertNotNull(cobarDao.getCobarById(3));
Assert.assertNull(cobarDao.getCobarById(1));
}
use of com.alibaba.cobar.manager.dataobject.xml.CobarDO in project cobar by alibaba.
the class DOFactory method getCobar.
public static CobarDO getCobar() {
CobarDO cobar = new CobarDO();
cobar.setClusterId(1);
cobar.setHost("1.1.1.1");
cobar.setName("gxw");
cobar.setPassword("gxw");
cobar.setStatus(ConstantDefine.ACTIVE);
cobar.setPort(9090);
cobar.setTime_diff("time_diff");
cobar.setUser("gxw");
return cobar;
}
use of com.alibaba.cobar.manager.dataobject.xml.CobarDO in project cobar by alibaba.
the class CobarDAOImple method checkName.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public boolean checkName(String name, long clusterId) {
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Long, CobarDO> entry = (Entry<Long, CobarDO>) it.next();
CobarDO cobar = entry.getValue();
if (clusterId == cobar.getClusterId() && cobar.getName().equals(name)) {
return false;
}
}
return true;
}
Aggregations