AddAttributeModel { public void execute(Object value, String expression, String role, String type, Request request, ModelBody modelBody) throws IOException { Attribute attribute = new Attribute(); Deque<Object> composeStack = ComposeStackUtil.getComposeStack(request); composeStack.push(attribute); String body = modelBody.evaluateAsString(); attribute = (Attribute) composeStack.pop(); addAttributeToList(attribute, composeStack, value, expression, body, role, type); }  void execute(Object value, String expression, String role,
            String type, Request request, ModelBody modelBody);  }
@Test public void testExecute() throws IOException { Request request = createMock(Request.class); ModelBody modelBody = createMock(ModelBody.class); Deque<Object> composeStack = new ArrayDeque<Object>(); ListAttribute listAttribute = new ListAttribute(); Attribute attribute; composeStack.push(listAttribute); Map<String, Object> requestScope = new HashMap<String, Object>(); requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack); expect(request.getContext("request")).andReturn(requestScope).times(2); expect(modelBody.evaluateAsString()).andReturn(null); expect(modelBody.evaluateAsString()).andReturn("myBody"); replay(request, modelBody); model.execute("myValue", "myExpression", "myRole", "myType", request, modelBody); List<Attribute> attributes = listAttribute.getValue(); assertEquals(1, attributes.size()); attribute = attributes.iterator().next(); assertEquals("myValue", attribute.getValue()); assertEquals("myExpression", attribute.getExpressionObject().getExpression()); assertEquals("myRole", attribute.getRole()); assertEquals("myType", attribute.getRenderer()); composeStack.clear(); listAttribute = new ListAttribute(); attribute = new Attribute(); composeStack.push(listAttribute); composeStack.push(attribute); model.execute(null, "myExpression", "myRole", "myType", request, modelBody); attributes = listAttribute.getValue(); assertEquals(1, attributes.size()); attribute = attributes.iterator().next(); assertEquals("myBody", attribute.getValue()); assertEquals("myExpression", attribute.getExpressionObject() .getExpression()); assertEquals("myRole", attribute.getRole()); assertEquals("myType", attribute.getRenderer()); verify(request, modelBody); }