Search in sources :

Example 1 with RegionDao

use of org.apache.cloudstack.region.dao.RegionDao in project cloudstack by apache.

the class RegionManagerTest method testUniqueName.

@Test
public void testUniqueName() {
    RegionManagerImpl regionMgr = new RegionManagerImpl();
    RegionDao regionDao = Mockito.mock(RegionDao.class);
    RegionVO region = new RegionVO(2, "APAC", "");
    Mockito.when(regionDao.findByName(Matchers.anyString())).thenReturn(region);
    regionMgr._regionDao = regionDao;
    try {
        regionMgr.addRegion(2, "APAC", "");
    } catch (InvalidParameterValueException e) {
        Assert.assertEquals("Region with name: APAC already exists", e.getMessage());
    }
}
Also used : InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) RegionDao(org.apache.cloudstack.region.dao.RegionDao) Test(org.junit.Test)

Aggregations

InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 RegionDao (org.apache.cloudstack.region.dao.RegionDao)1 Test (org.junit.Test)1