Search in sources :

Example 1 with RetMessage

use of com.ctrip.xpipe.redis.console.controller.api.RetMessage in project x-pipe by ctripcorp.

the class ConfigControllerTest method testChangeConfig1.

@Test
public void testChangeConfig1() throws Exception {
    ConfigModel model = new ConfigModel();
    model.setKey(DefaultConsoleDbConfig.KEY_ALERT_SYSTEM_ON);
    model.setVal(String.valueOf(false));
    RetMessage ret = controller.changeConfig(request, model);
    Assert.assertEquals(RetMessage.SUCCESS_STATE, ret.getState());
}
Also used : ConfigModel(com.ctrip.xpipe.redis.console.model.ConfigModel) RetMessage(com.ctrip.xpipe.redis.console.controller.api.RetMessage) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 2 with RetMessage

use of com.ctrip.xpipe.redis.console.controller.api.RetMessage in project x-pipe by ctripcorp.

the class ConfigControllerTest method testChangeConfig2.

@Test
public void testChangeConfig2() throws Exception {
    ConfigModel model = new ConfigModel();
    model.setKey("Key Unknown");
    model.setVal(String.valueOf(false));
    RetMessage ret = controller.changeConfig(request, model);
    Assert.assertEquals(RetMessage.FAIL_STATE, ret.getState());
    Assert.assertEquals("Unknown config key: Key Unknown", ret.getMessage());
}
Also used : ConfigModel(com.ctrip.xpipe.redis.console.model.ConfigModel) RetMessage(com.ctrip.xpipe.redis.console.controller.api.RetMessage) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 3 with RetMessage

use of com.ctrip.xpipe.redis.console.controller.api.RetMessage in project x-pipe by ctripcorp.

the class SentinelUpdateControllerTest method reBalanceSentinels2.

@Test
public void reBalanceSentinels2() throws Exception {
    String expectedMessage = "Expected Message";
    when(clusterService.reBalanceSentinels(-1)).thenThrow(new RuntimeException(expectedMessage));
    RetMessage message = controller.reBalanceSentinels(-1);
    Assert.assertEquals(-1, message.getState());
    Assert.assertEquals(expectedMessage, message.getMessage());
}
Also used : RetMessage(com.ctrip.xpipe.redis.console.controller.api.RetMessage) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 4 with RetMessage

use of com.ctrip.xpipe.redis.console.controller.api.RetMessage in project x-pipe by ctripcorp.

the class MetaUpdateTest method testUpdateCLusterWithNoOrgIDFound.

@Test
public void testUpdateCLusterWithNoOrgIDFound() throws Exception {
    String CLUSTER_NAME = "cluster-name";
    long ORG_ID = 99L;
    String EXPECTED_MESSAGE = String.format("Organization Id: %d, could not be found", ORG_ID);
    ClusterTbl clusterTbl = new ClusterTbl().setClusterName(CLUSTER_NAME).setClusterDescription("").setActivedcId(1).setIsXpipeInterested(true).setStatus("normal").setClusterLastModifiedTime(DateTimeUtils.currentTimeAsString());
    clusterDao.createCluster(clusterTbl);
    ClusterCreateInfo clusterInfo = new ClusterCreateInfo();
    clusterInfo.setClusterName(CLUSTER_NAME);
    clusterInfo.setClusterAdminEmails("test@ctrip.com");
    clusterInfo.setOrganizationId(ORG_ID);
    RetMessage retMessage = clusterController.updateCluster(clusterInfo);
    logger.info("{}", retMessage.getMessage());
    RetMessage retMessage1 = clusterController.updateCluster(clusterInfo);
    Assert.assertEquals(RetMessage.FAIL_STATE, retMessage1.getState());
    Assert.assertEquals(EXPECTED_MESSAGE, retMessage1.getMessage());
}
Also used : ClusterTbl(com.ctrip.xpipe.redis.console.model.ClusterTbl) RetMessage(com.ctrip.xpipe.redis.console.controller.api.RetMessage) ClusterCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.ClusterCreateInfo) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 5 with RetMessage

use of com.ctrip.xpipe.redis.console.controller.api.RetMessage in project x-pipe by ctripcorp.

the class MetaUpdateTest method testUpdateClusterWithNoClusterFound.

@Test
public void testUpdateClusterWithNoClusterFound() throws Exception {
    String CLUSTER_NAME = "cluster-not-exist";
    String EXPECTED_MESSAGE = String.format("cluster not found: %s", CLUSTER_NAME);
    ClusterCreateInfo clusterCreateInfo = new ClusterCreateInfo();
    clusterCreateInfo.setClusterName(CLUSTER_NAME);
    RetMessage retMessage = clusterController.updateCluster(clusterCreateInfo);
    logger.info("{}", retMessage.getMessage());
    Assert.assertEquals(RetMessage.FAIL_STATE, retMessage.getState());
    Assert.assertEquals(EXPECTED_MESSAGE, retMessage.getMessage());
}
Also used : RetMessage(com.ctrip.xpipe.redis.console.controller.api.RetMessage) ClusterCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.ClusterCreateInfo) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Aggregations

RetMessage (com.ctrip.xpipe.redis.console.controller.api.RetMessage)13 Test (org.junit.Test)13 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)10 ClusterCreateInfo (com.ctrip.xpipe.redis.console.controller.api.data.meta.ClusterCreateInfo)4 ShardCreateInfo (com.ctrip.xpipe.redis.console.controller.api.data.meta.ShardCreateInfo)4 RedisCreateInfo (com.ctrip.xpipe.redis.console.controller.api.data.meta.RedisCreateInfo)3 ClusterTbl (com.ctrip.xpipe.redis.console.model.ClusterTbl)3 ConfigModel (com.ctrip.xpipe.redis.console.model.ConfigModel)2 ShardTbl (com.ctrip.xpipe.redis.console.model.ShardTbl)1 Matchers.anyString (org.mockito.Matchers.anyString)1