### Question:
ConversationScopeInterceptor extends AbstractInterceptor { @Override public String intercept(ActionInvocation invocation) throws Exception { Object action = invocation.getAction(); Map<String, Object> session = invocation.getInvocationContext().getSession(); Conversation conversation = getDefaultConversation(action, session); if (action instanceof ConversationAware) { ((ConversationAware) action).setConversation(conversation); } for (Field field : getInheritedPrivateFields(action.getClass())) { if (field.isAnnotationPresent(ConversationScoped.class)) { ConversationScoped annotation = field.getAnnotation(ConversationScoped.class); String name = StringUtils.defaultIfEmpty(annotation.value(), field.getName()); log.debug("setting value for {}", name); Object instance = conversation.get(field.getType(), name); field.setAccessible(true); field.set(action, instance); } } return invocation.invoke(); }  @Override String intercept(ActionInvocation invocation);  }### Answer:
@Test public void testIntercept() throws Exception { interceptor.intercept(invocation); assertNotNull("the action's object should be created", action.getObject()); assertSame("the action's object should be stored in the session", action.getObject(), getConversation().get(Object.class, "object")); }
@Test public void testConversationLookup() throws Exception { Object object = new Object(); getConversation().put("object", object); interceptor.intercept(invocation); assertSame("the object previously stored in the conversation should be set on the action", object, action.getObject()); }
@Test public void testAnnotationName() throws Exception { Object expected = new Object(); getConversation().put("otherObject", expected); interceptor.intercept(invocation); assertSame("the object should have been injected based on the value of the annotation", expected, action.getMyObject()); }
@Test public void testConversationAware() throws Exception { interceptor.intercept(invocation); assertNotNull(action.getConversation()); }
@Test public void testInjectionOnBaseProperties() throws Exception { Object expected = new Object(); getConversation().put("baseObject", expected); interceptor.intercept(invocation); assertSame("The object should be injected on the base class", expected, action.getBaseObject()); }