RoleConfigurationManager { void readFromInitParameter(ServletContext sc) { String param = sc.getInitParameter(Constants.Options.DASHBOARD_ROLES); if (param != null) { logger.debug("Read '{}' option from web.xml : '{}'.", Constants.Options.DASHBOARD_ROLES, param); roles.addAll(Arrays.asList(param.split(Constants.Options.SEPARATOR))); } }  void readDashboardRolesConfig(@Observes @Initialized(ApplicationScoped.class) ServletContext sc); Collection<String> getRoles();  }
@Test public void testReadFromInitParameter() { System.out.println("readFromInitParameter"); ServletContext sc = mock(ServletContext.class); when(sc.getInitParameter(eq(Constants.Options.DASHBOARD_ROLES))).thenReturn(null).thenReturn("R1,R2"); instance.getRoles().clear(); instance.readFromInitParameter(sc); assertThat(instance.getRoles()).isEmpty(); instance.getRoles().clear(); instance.readFromInitParameter(sc); assertThat(instance.getRoles()).hasSize(2); }