### Question:
LazyExpression implements PrettyExpression { public String getELExpression() { if (expression == null) { expression = "#{" + finder.findBeanName(beanClass) + "." + component + "}"; if (log.isTraceEnabled()) { log.trace("Lazy expression resolved to: " + expression); } } return expression; } LazyExpression(LazyBeanNameFinder finder, Class<?> beanClass, String component); String getELExpression(); @Override String toString(); Class<?> getBeanClass(); String getComponent(); @Override int hashCode(); @Override boolean equals(Object obj);  }### Answer:
@Test public void testSimpleLazyExpression() { LazyBeanNameFinder beanNameFinder = EasyMock.createNiceMock(LazyBeanNameFinder.class); EasyMock.expect(beanNameFinder.findBeanName(SomeTestBean.class)).andReturn("someTestBean").once(); EasyMock.replay(beanNameFinder); PrettyExpression expr = new LazyExpression(beanNameFinder, SomeTestBean.class, "property"); assertEquals("#{someTestBean.property}", expr.getELExpression()); assertEquals("#{someTestBean.property}", expr.getELExpression()); EasyMock.verify(beanNameFinder); }
@Test(expected = IllegalStateException.class) public void testUnresolvableLazyExpression() { LazyBeanNameFinder beanNameFinder = EasyMock.createNiceMock(LazyBeanNameFinder.class); EasyMock.expect(beanNameFinder.findBeanName(SomeTestBean.class)).andThrow(new IllegalStateException()).once(); EasyMock.replay(beanNameFinder); PrettyExpression expr = new LazyExpression(beanNameFinder, SomeTestBean.class, "property"); expr.getELExpression(); }