Plugin { public LoopDescriptor query(String segment, String currentLoopStack, int currentLevel, Set<String> resultFlags) { LoopDescriptor result = null; logger.debug("plugin query for segment {}", segment); if (loops == null) return null; if (optimizedForm == null) throw new RuntimeException("Internal error: plugin not properly constructed"); List<LoopDescriptor> descriptorList = optimizedForm.getList(segment); if (descriptorList == null) { logger.debug("No descriptors found"); return null; } logger.debug("Number of descriptors found: {}", descriptorList.size()); for (LoopDescriptor descriptor : descriptorList) { boolean candidate = matchesWithoutRegardToFlagConditionals(descriptor, segment, currentLoopStack, currentLevel); if (candidate) { Set<String> conditions = descriptor.getConditionFlags(); boolean satisfied = true; for (String condition : conditions) { if (!resultFlags.contains(condition)) { satisfied = false; break; } } if (satisfied) { result = descriptor; break; } } } if (result != null && result.getName() == null) result = null; return result; } Plugin(String documentType, String documentName); protected  Plugin(String documentType, String documentName, boolean validating); void init(); String getDocumentType(); String getDocumentName(); LoopDescriptor[] getLoopDescriptors(); LoopDescriptor query(String segment, String currentLoopStack, int currentLevel, Set<String> resultFlags); static int getCount(); @Override String toString(); void prepare(); boolean isValidating(); PluginControllerImpl createController(String standard, Tokenizer tokenizer); String getDocumentVersion(); PluginDiff compare(Plugin pluginB); static final String ANY_CONTEXT; static final String INITIAL_CONTEXT; static final String CURRENT; }
@Test(expected = RuntimeException.class) public void mustPrepareOptimizedForm() { plugin.loops = LOOP_DESCRIPTORS; plugin.query("seg1", null, -1, resultFlags); }