PutListAttributeModel { public void execute(@Parameter(required = true) String name, String role, boolean inherit, boolean cascade, Request request, ModelBody modelBody) throws IOException { Deque<Object> composeStack = ComposeStackUtil.getComposeStack(request); ListAttribute listAttribute = new ListAttribute(); listAttribute.setRole(role); listAttribute.setInherit(inherit); composeStack.push(listAttribute); modelBody.evaluateWithoutWriting(); TilesContainer container = TilesAccess.getCurrentContainer(request); listAttribute = (ListAttribute) composeStack.pop(); AttributeContext attributeContext = null; if (!composeStack.isEmpty()) { Object obj = composeStack.peek(); if (obj instanceof Definition) { attributeContext = (AttributeContext) obj; } } if (attributeContext == null) { attributeContext = container.getAttributeContext(request); } attributeContext.putAttribute(name, listAttribute, cascade); }  void execute(@Parameter(required = true) String name, String role,
            boolean inherit, boolean cascade, Request request,
            ModelBody modelBody);  }
@Test public void testExecute() throws IOException { TilesContainer container = createMock(TilesContainer.class); AttributeContext attributeContext = createMock(AttributeContext.class); Request request = createMock(Request.class); Deque<Object> composeStack = new ArrayDeque<Object>(); Map<String, Object> requestScope = new HashMap<String, Object>(); requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack); requestScope.put(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, container); ApplicationContext applicationContext = createMock(ApplicationContext.class); ModelBody modelBody = createMock(ModelBody.class); modelBody.evaluateWithoutWriting(); expect(request.getApplicationContext()).andReturn(applicationContext); expect(request.getContext("request")).andReturn(requestScope).anyTimes(); expect(container.getAttributeContext(request)).andReturn(attributeContext); attributeContext.putAttribute(eq("myName"), isA(ListAttribute.class), eq(false)); replay(container, attributeContext, request, modelBody); model.execute("myName", "myRole", false, false, request, modelBody); assertEquals(0, composeStack.size()); verify(container, attributeContext, request, modelBody); }