diff --git a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/impl/sql/HibernateTopicDao.java b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/impl/sql/HibernateTopicDao.java index 099f77bd5b..f9a4943fa7 100644 --- a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/impl/sql/HibernateTopicDao.java +++ b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/impl/sql/HibernateTopicDao.java @@ -95,7 +95,7 @@ public Topic findTopicByAppIdAndName(String appId, String topicName) { Restrictions.eq(TOPIC_NAME, topicName))); } if (LOG.isTraceEnabled()) { - LOG.trace("[{},{}] Search result: {}.", appId, topicName, topic != null); + LOG.trace("[{},{}] Search result: {}.", appId, topicName, topic); } else { LOG.debug("[{},{}] Search result: {}.", appId, topicName, topic != null); } diff --git a/server/control/src/test/java/org/kaaproject/kaa/server/control/cli/ControlServerCliIT.java b/server/control/src/test/java/org/kaaproject/kaa/server/control/cli/ControlServerCliIT.java index be6fa6ffce..97587d7965 100644 --- a/server/control/src/test/java/org/kaaproject/kaa/server/control/cli/ControlServerCliIT.java +++ b/server/control/src/test/java/org/kaaproject/kaa/server/control/cli/ControlServerCliIT.java @@ -556,8 +556,8 @@ public void testExecuteTopicCommandFromCli() throws TException, UnsupportedEncod ControlApiCliThriftClient cli = new ControlApiCliThriftClient(); String applicationId = editApplicationCli(cli, null, "testApplication", null, "testTenant", false); - String topicId = editTopicCli(cli, null, applicationId, null, null, SubscriptionType.MANDATORY, true); - topicId = editTopicCli(cli, null, applicationId, null, null, SubscriptionType.MANDATORY, false); + String topicId = editTopicCli(cli, null, applicationId, "topic1", null, null, SubscriptionType.MANDATORY, true); + topicId = editTopicCli(cli, null, applicationId, "topic2", null, null, SubscriptionType.MANDATORY, false); Assert.assertFalse(strIsEmpty(topicId)); // Assert.assertEquals(LENGTH_OF_ID_IN_MONGODB, topicId.length()); editTopicCli(cli, topicId, applicationId, null, null, SubscriptionType.MANDATORY, false); @@ -1654,7 +1654,7 @@ private void activateConfigurationCli(ControlApiCliThriftClient cli, String conf String output = cliOut.toString("UTF-8"); Assert.assertTrue(output.trim().startsWith("Configuration Activated.")); } - + /** * Edits/Creates the endpoint group from cli. * @@ -1667,6 +1667,21 @@ private void activateConfigurationCli(ControlApiCliThriftClient cli, String conf * @throws UnsupportedEncodingException the unsupported encoding exception */ private String editTopicCli(ControlApiCliThriftClient cli, String topicId, String applicationId, String applicationName, String tenantName, SubscriptionType subscriptionType, boolean createOut) throws UnsupportedEncodingException { + return editTopicCli(cli, topicId, applicationId, null, applicationName, tenantName, subscriptionType, createOut); + } + + /** + * Edits/Creates the endpoint group from cli. + * + * @param cli the control cli client + * @param topicId the topic id + * @param applicationId the application Id + * @param subscriptionType the subscription type + * @param createOut create output file with object id + * @return the endpointGroupId + * @throws UnsupportedEncodingException the unsupported encoding exception + */ + private String editTopicCli(ControlApiCliThriftClient cli, String topicId, String applicationId, String topicName, String applicationName, String tenantName, SubscriptionType subscriptionType, boolean createOut) throws UnsupportedEncodingException { cliOut.reset(); boolean create = strIsEmpty(topicId); int result = -1; @@ -1675,14 +1690,20 @@ private String editTopicCli(ControlApiCliThriftClient cli, String topicId, Strin applicationId = editApplicationCli(cli, null, applicationName, null, tenantName, false); cliOut.reset(); } - String cmdLine = "createTopic -n testTopic -a " + applicationId + " -t " + subscriptionType.name(); + if(topicName == null){ + topicName = "testTopic"; + } + String cmdLine = "createTopic -n " + topicName + " -a " + applicationId + " -t " + subscriptionType.name(); if (createOut) { cmdLine += " -o dummy.out"; } result = cli.processLine(cmdLine); } else { - result = cli.processLine("editTopic -n testTopic2 -i " + topicId); + if(topicName == null){ + topicName = "testTopic2"; + } + result = cli.processLine("editTopic -n " + topicName + " -i " + topicId); } Assert.assertEquals(result, 0); String output = cliOut.toString("UTF-8");