SystemService { public Document getUsers() throws ServletException, IOException, IllegalAccessException { if ( !canAdminister() ) { throw new IllegalAccessException(); } IUserRoleListService service = PentahoSystem.get( IUserRoleListService.class ); Element rootElement = new DefaultElement( "users" ); Document doc = DocumentHelper.createDocument( rootElement ); if ( service != null ) { List<String> users = service.getAllUsers(); for ( Iterator<String> usersIterator = users.iterator(); usersIterator.hasNext(); ) { String username = usersIterator.next().toString(); if ( ( null != username ) && ( username.length() > 0 ) ) { rootElement.addElement( "user" ).setText( username ); } } } return doc; }  static SystemService getSystemService(); Document getUsers(); Document getRoles(); List<String> getRolesForUser( String user ); List<String> getUsersInRole( String role ); Document getPermissions(); Document getAll();  }
@Test public void testGetUsers() throws Exception { IUserRoleListService service = mock( IUserRoleListService.class ); PentahoSystem.registerObject( service ); doReturn( true ).when( systemService ).canAdminister(); assertNotNull( systemService.getUsers() ); PentahoSystem.clearObjectFactory(); }