package org.osiam.addons.administration.integration;

import static org.junit.Assert.*;

import org.junit.Test;
import org.osiam.addons.administration.Element.UserList;
import org.osiam.addons.administration.selenium.Field;

public class UserListIT extends Integrationtest {

    @Override
    public void setup() {
        super.setup();

        browser.doOauthLogin(ADMIN_USERNAME, ADMIN_PASSWORD);
    }

    @Test
    public void show_list_of_user() {
        assertTrue(isUserVisible(ADMIN_USERNAME));
    }
    
    @Test
    public void apply_empty_filter(){
        browser.click(UserList.FilterButton);

        assertTrue(isUserVisible(ADMIN_USERNAME));
    }
    
    @Test
    public void apply_single_filter(){
        browser.fill(new Field(UserList.FilterLogin, ADMIN_USERNAME));
        browser.click(UserList.FilterButton);
        
        assertTrue(isUserVisible(ADMIN_USERNAME));
        assertFalse(isUserVisible("adavies"));  //an another user
    }

    @Test
    public void apply_multi_filter(){
        browser.fill(new Field(UserList.FilterLogin, ADMIN_USERNAME));
        browser.click(UserList.FilterButton);
        
        assertTrue(isUserVisible(ADMIN_USERNAME));
        assertFalse(isUserVisible("adavies"));  //an another user
    }
    
    private boolean isUserVisible(String username) {
        return browser.isTextPresent(username);
    }
}

@@ -1029,32 +1029,49 @@
    browser.fill(
+%0A                
 new Field(UserLi
@@ -1079,37 +1079,100 @@
 t.Filter
-Login, ADMIN_USERNAME
+GivenName, %22Adeline%22),%0A                new Field(UserList.FilterFamilyName, %22Davies%22
 ));%0A    
@@ -1228,35 +1228,36 @@
  %0A        assert
-Tru
+Fals
 e(isUserVisible(
@@ -1280,36 +1280,35 @@
 ;%0A        assert
-Fals
+Tru
 e(isUserVisible(

fix test for multiple filtering in user-list