@Test void testValidateTopicLevelsNot() { Assertions.assertThrows(TopicFormatException.class, () -> AbstractTopic.validateTopicLevels(toTopicLevels("test", "#", "level")), "Expected topic format excpetion"); Assertions.assertThrows(TopicFormatException.class, () -> AbstractTopic.validateTopicLevels(toTopicLevels("", "#", "")), "Expected topic format excpetion"); Assertions.assertThrows(TopicFormatException.class, () -> AbstractTopic.validateTopicLevels(toTopicLevels("#", "level")), "Expected topic format excpetion"); Assertions.assertThrows(TopicFormatException.class, () -> AbstractTopic.validateTopicLevels(toTopicLevels("#", "")), "Expected topic format excpetion"); Assertions.assertThrows(TopicFormatException.class, () -> AbstractTopic.validateTopicLevels(toTopicLevels("", "#", "")), "Expected topic format excpetion"); Assertions.assertThrows(TopicFormatException.class, () -> AbstractTopic.validateTopicLevels(toTopicLevels("#", "+")), "Expected topic format excpetion"); }
protected static void validateTopicLevels(List<TopicLevel> levels) throws TopicFormatException { for (int i = 0; i < (levels.size() - 1); i++) { if (levels.get(i).isMultiLevelWildcard()) throw new TopicFormatException("Only the last level may be a multi level wildcard"); } }
AbstractTopic implements Topic { protected static void validateTopicLevels(List<TopicLevel> levels) throws TopicFormatException { for (int i = 0; i < (levels.size() - 1); i++) { if (levels.get(i).isMultiLevelWildcard()) throw new TopicFormatException("Only the last level may be a multi level wildcard"); } } }
AbstractTopic implements Topic { protected static void validateTopicLevels(List<TopicLevel> levels) throws TopicFormatException { for (int i = 0; i < (levels.size() - 1); i++) { if (levels.get(i).isMultiLevelWildcard()) throw new TopicFormatException("Only the last level may be a multi level wildcard"); } } protected  AbstractTopic(String topicString); }
AbstractTopic implements Topic { protected static void validateTopicLevels(List<TopicLevel> levels) throws TopicFormatException { for (int i = 0; i < (levels.size() - 1); i++) { if (levels.get(i).isMultiLevelWildcard()) throw new TopicFormatException("Only the last level may be a multi level wildcard"); } } protected  AbstractTopic(String topicString); @Override String getStringRepresentation(); @Override List<TopicLevel> getTopicLevels(); @Override boolean isSpecialTopic(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }
AbstractTopic implements Topic { protected static void validateTopicLevels(List<TopicLevel> levels) throws TopicFormatException { for (int i = 0; i < (levels.size() - 1); i++) { if (levels.get(i).isMultiLevelWildcard()) throw new TopicFormatException("Only the last level may be a multi level wildcard"); } } protected  AbstractTopic(String topicString); @Override String getStringRepresentation(); @Override List<TopicLevel> getTopicLevels(); @Override boolean isSpecialTopic(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }