ComposeStackUtil { @SuppressWarnings("unchecked") public static Deque<Object> getComposeStack(Request request) { Map<String, Object> requestScope = request.getContext("request"); Deque<Object> composeStack = (Deque<Object>) requestScope .get(COMPOSE_STACK_ATTRIBUTE_NAME); if (composeStack == null) { composeStack = new LinkedList<Object>(); requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack); } return composeStack; } private  ComposeStackUtil(); static Object findAncestorWithClass(Deque<Object> composeStack, Class<?> clazz); @SuppressWarnings("unchecked") static Deque<Object> getComposeStack(Request request); static final String COMPOSE_STACK_ATTRIBUTE_NAME; }
@Test public void testGetComposeStackNull() { Request request = createMock(Request.class); Map<String, Object> requestScope = new HashMap<String, Object>(); expect(request.getContext("request")).andReturn(requestScope); replay(request); assertSame(ComposeStackUtil.getComposeStack(request), requestScope.get(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME)); verify(request); }
@Test public void testGetComposeStackNotNull() { Request request = createMock(Request.class); @SuppressWarnings("unchecked") Deque<Object> composeStack = createMock(Deque.class); Map<String, Object> requestScope = new HashMap<String, Object>(); requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack); expect(request.getContext("request")).andReturn(requestScope); replay(request, composeStack); assertSame(composeStack, ComposeStackUtil.getComposeStack(request)); verify(request, composeStack); }
@Test public void testGetComposeStackNoNull() { Request request = createMock(Request.class); Map<String, Object> requestScope = new HashMap<String, Object>(); expect(request.getContext("request")).andReturn(requestScope); replay(request); assertSame(ComposeStackUtil.getComposeStack(request), requestScope.get(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME)); verify(request); }