### Question:
FabricTopicAdmin implements IEventTopic { @Override public boolean close(String topic, String channelName) throws BrokerException { log.info("close topic: {} channelName: {}", topic, channelName); ParamCheckUtils.validateTopicName(topic); validateChannelName(channelName); if (exist(topic, channelName)) { return true; } throw new BrokerException(ErrorCode.TOPIC_NOT_EXIST); } FabricTopicAdmin(FabricDelegate fabricDelegate); @Override boolean open(String topic, String channelName); @Override boolean close(String topic, String channelName); @Override WeEvent getEvent(String eventId, String channelName); @Override boolean exist(String topic, String channelName); @Override TopicPage list(Integer pageIndex, Integer pageSize, String channelName); @Override TopicInfo state(String topic, String channelName); @Override List<String> listGroupId(); @Override Long getBlockHeight(String channelName); @Override GroupGeneral getGroupGeneral(String channelName); @Override ListPage<TbTransHash> queryTransList(QueryEntity queryEntity); @Override ListPage<TbBlock> queryBlockList(QueryEntity queryEntity); @Override ListPage<TbNode> queryNodeList(QueryEntity queryEntity); @Override ContractContext getContractContext(String groupId); @Override boolean addOperator(String groupId, String topicName, String address); @Override boolean delOperator(String groupId, String topicName, String address); @Override List<String> listOperator(String groupId, String topicName); @Override void validateGroupId(String channelName);  }### Answer:
@Test public void testCloseTopicExist() throws Exception { Assert.assertTrue(this.iProducer.close(this.topicName, this.channelName)); }
@Test public void testCloseTopicIsNull() { try { Assert.assertFalse(this.iProducer.close(null, this.channelName)); Assert.fail(); } catch (BrokerException e) { Assert.assertEquals(ErrorCode.TOPIC_IS_BLANK.getCode(), e.getCode()); } }
@Test public void testCloseTopicIsBlank() { try { this.iProducer.close(" ", this.channelName); Assert.fail(); } catch (BrokerException e) { Assert.assertEquals(ErrorCode.TOPIC_IS_BLANK.getCode(), e.getCode()); } }
@Test public void testCloseTopicOverMaxLen() { try { String topicStr = "topiclengthlonger64azxsqwedcvfrtgbnhyujmkiolpoiuytr-" + System.currentTimeMillis(); this.iProducer.close(topicStr, this.channelName); Assert.fail(); } catch (BrokerException e) { Assert.assertEquals(ErrorCode.TOPIC_EXCEED_MAX_LENGTH.getCode(), e.getCode()); } }
@Test public void testCloseTopicContainSpecialChar() { try { char[] charStr = {69, 72, 31}; String illegalTopic = new String(charStr); this.iProducer.close(illegalTopic, this.channelName); Assert.fail(); } catch (BrokerException e) { Assert.assertEquals(ErrorCode.TOPIC_CONTAIN_INVALID_CHAR.getCode(), e.getCode()); } }
@Test public void testCloseTopicContainChiChar() { try { this.iProducer.close("中国", channelName); Assert.fail(); } catch (BrokerException e) { Assert.assertEquals(ErrorCode.TOPIC_CONTAIN_INVALID_CHAR.getCode(), e.getCode()); } }
@Test public void testCloseChannelNameIsNull() { try { this.iProducer.close(this.topicName, null); Assert.fail(); } catch (BrokerException e) { Assert.assertEquals(ErrorCode.FABRICSDK_CHANNEL_NAME_INVALID.getCode(), e.getCode()); } }
@Test public void testCloseChannelNameNotExist() { try { this.iProducer.close(this.topicName, "4"); Assert.fail(); } catch (BrokerException e) { Assert.assertEquals(ErrorCode.FABRICSDK_CHANNEL_NAME_INVALID.getCode(), e.getCode()); } }