### Question:
AMSetupFilter implements Filter { @Override public void init(FilterConfig config) throws ServletException { System.out.println("Starting up OpenAM at " + DateFormat.getDateTimeInstance().format(Time.getCalendarInstance().getTime())); ServletContext servletContext = config.getServletContext(); SystemStartupInjectorHolder startupInjectorHolder = SystemStartupInjectorHolder.getInstance(); setupManager = startupInjectorHolder.getInstance(AMSetupManager.class); if (!setupManager.isConfigured()) { servletContext.setAttribute(AM_ENCRYPTION_PASSWORD_PROPERTY_KEY, AMSetupUtils.getRandomString()); } }  @Override void init(FilterConfig config); @Override void doFilter(ServletRequest req, ServletResponse resp, FilterChain filterChain); @Override void destroy();  }### Answer:
@Test public void initShouldSetEncryptionPasswordIfNotConfigured() throws Exception { FilterConfig config = mock(FilterConfig.class); ServletContext context = mock(ServletContext.class); given(config.getServletContext()).willReturn(context); systemIsNotConfigured(); setupFilter.init(config); verify(context).setAttribute(eq("am.enc.pwd"), anyString()); }
@Test public void initShouldNotSetEncryptionPasswordIfConfigured() throws Exception { FilterConfig config = mock(FilterConfig.class); ServletContext context = mock(ServletContext.class); given(config.getServletContext()).willReturn(context); systemIsConfigured(); setupFilter.init(config); verifyZeroInteractions(context); }