### Question:
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);  }### Answer:
@Test void testValidateTopicLevels() throws Exception { AbstractTopic.validateTopicLevels(toTopicLevels("test", "", "level")); AbstractTopic.validateTopicLevels(toTopicLevels("", "test", "")); AbstractTopic.validateTopicLevels(toTopicLevels("test", "+", "level")); AbstractTopic.validateTopicLevels(toTopicLevels("test", "level", "#")); AbstractTopic.validateTopicLevels(toTopicLevels("+", "+", "#")); AbstractTopic.validateTopicLevels(toTopicLevels("#")); AbstractTopic.validateTopicLevels(toTopicLevels("+")); AbstractTopic.validateTopicLevels(toTopicLevels("", "#")); }
@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"); }