### Question:
RepeatTagHandler extends AbstractTagHandler { public void process(final Node result, final Element tag, final TemplateProcessor processor) { Iterable<?> repeat = getValueFromTag(tag, EXPRESSION_ATTR, processor, Iterable.class); if (repeat != null) { final Attr ifAttribute = tag.getAttributeNode(IF_ATTR); processor.processRepeat(result, tag, repeat, new Runnable() { public void run() { if (ifAttribute != null) { if (!processor.evaluate(ifAttribute.getValue(), Boolean.class, false)) { return; } } processor.processChildNodes(result, tag); } }); } } @Inject  RepeatTagHandler(); void process(final Node result, final Element tag, final TemplateProcessor processor);  }### Answer:
@Test public void repeat() throws Exception { Document doc = documentProvider.createDocument(null, null, null); Element tag = doc.createElement("repeat"); tag.setAttribute(RepeatTagHandler.EXPRESSION_ATTR, "fakeExpression"); List<String> mockList = ImmutableList.of("a", "b", "c"); processor.expressionResults = ImmutableMap.of("fakeExpression", mockList); processor.processChildNodes(null, tag); EasyMock.expectLastCall().times(3); replay(processor); handler.process(null, tag, processor); verify(processor); }
@Test public void repeatWithoutExpression() throws Exception { Document doc = documentProvider.createDocument(null, null, null); Element tag = doc.createElement("repeat"); replay(processor); handler.process(null, tag, processor); verify(processor); }
@Test public void repeatWithIf() throws Exception { Document doc = documentProvider.createDocument(null, null, null); Element tag = doc.createElement("repeat"); tag.setAttribute(RepeatTagHandler.EXPRESSION_ATTR, "fakeExpression"); tag.setAttribute(RepeatTagHandler.IF_ATTR, "fakeIf"); List<String> mockList = ImmutableList.of("a", "b", "c"); processor.expressionResults = ImmutableMap.of("fakeExpression", mockList, "fakeIf", Lists.newArrayList(false, true, false)); processor.processChildNodes(null, tag); EasyMock.expectLastCall().times(1); replay(processor); handler.process(null, tag, processor); verify(processor); }