<commit_before>package org.opennms.smoketest;

import java.net.URL;

import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.thoughtworks.selenium.SeleneseTestBase;


public class ServicePageTest extends SeleneseTestBase{
    @Before
    public void setUp() throws Exception {
        DesiredCapabilities capability = DesiredCapabilities.firefox();
        WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
        String baseUrl = "http://localhost:8980/";
        selenium = new WebDriverBackedSelenium(driver, baseUrl);
        //selenium.start();
        selenium.open("/opennms/login.jsp");
        selenium.type("name=j_username", "admin");
        selenium.type("name=j_password", "<PASSWORD>");
        selenium.click("name=Login");
        selenium.waitForPageToLoad("30000");
    }

    @Test
    public void testPrvoisioningGroupSetup() throws Exception {
        selenium.click("link=Admin");
        selenium.waitForPageToLoad("30000");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Manage Provisioning Groups");
        selenium.waitForPageToLoad("30000");
        selenium.type("css=form[name=takeAction] > input[name=groupName]", "SeleniumTestGroup");
        selenium.click("css=input[type=submit]");
        selenium.waitForPageToLoad("30000");
        selenium.click("//div[@id='content']/table/tbody/tr[2]/td[2]/a");
        selenium.waitForPageToLoad("30000");
        selenium.click("css=h4 > input[type=button]");
        selenium.waitForPageToLoad("30000");
        selenium.type("id=formData.detectors13.name", "HTTP-8980");
        selenium.select("id=formData.detectors13.pluginClass", "label=HTTP");
        selenium.click("//input[@value='Save']");
        selenium.waitForPageToLoad("30000");
        selenium.click("//form[@id='foreignSourceEditForm']/ul/li[14]/a[3]");
        selenium.waitForPageToLoad("30000");
        selenium.select("id=formData.detectors13.parameters0.key", "label=port");
        selenium.type("id=formData.detectors13.parameters0.value", "8980");
        selenium.click("css=li > input[type=button]");
        selenium.waitForPageToLoad("30000");
        selenium.click("css=input[type=button]");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Edit");
        selenium.waitForPageToLoad("30000");
        selenium.click("//input[@value='Add Node']");
        selenium.waitForPageToLoad("30000");
        selenium.type("id=formData.node0.nodeLabel", "localNode");
        selenium.click("css=li > input[type=button]");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=[Add Interface]");
        selenium.waitForPageToLoad("30000");
        selenium.type("id=formData.node0.interface0.ipAddr", "::1");
        selenium.click("css=li > input[type=button]");
        selenium.waitForPageToLoad("30000");
        selenium.click("css=input[type=button]");
        selenium.waitForPageToLoad("30000");
        selenium.click("//input[@value='Synchronize']");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Log out");
        selenium.waitForPageToLoad("30000");
    }

    @Test
    public void testCreateUser() { 
        selenium.click("link=Admin");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Configure Users, Groups and Roles");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Configure Users");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Add New User");
        selenium.waitForPageToLoad("30000");
        selenium.type("id=userID", "SmokeTestUser");
        selenium.type("id=pass1", "<PASSWORD>Password");
        selenium.type("id=pass2", "<PASSWORD>");
        selenium.click("id=doOK");
        selenium.waitForPageToLoad("30000");
        selenium.click("id=saveUserButton");
        selenium.waitForPageToLoad("30000");
        assertTrue(selenium.isElementPresent("id=users(SmokeTestUser).doDetails"));
        selenium.click("link=Log out");
        selenium.waitForPageToLoad("30000");
    }

    @Test  
    public void testCreateGroup() {
        selenium.click("link=Admin");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Configure Users, Groups and Roles");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Configure Groups");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Add new group");
        selenium.waitForPageToLoad("30000");
        selenium.type("id=groupName", "SmokeTestGroup");
        selenium.type("id=groupComment", "Test");
        selenium.click("id=doOK");
        selenium.waitForPageToLoad("30000");
        selenium.click("name=finish");
        selenium.waitForPageToLoad("30000");
        selenium.click("//div[@id='content']/form/table/tbody/tr[4]/td[2]/a/img");
        selenium.waitForPageToLoad("30000");
        selenium.addSelection("name=availableUsers", "label=SmokeTestUser");
        selenium.click("xpath=/html/body/div[2]/form/table[2]/tbody/tr[2]/td/table/tbody/tr[2]/td/p/input[2]");
        selenium.click("name=finish");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=SmokeTestGroup");
        selenium.waitForPageToLoad("30000");
        assertTrue(selenium.isTextPresent("SmokeTestUser"));
    }

    @Test
    public void testProvisioningGroupWasCreated() throws InterruptedException {
        selenium.click("link=Node List");
        selenium.waitForPageToLoad("30000");
        if(selenium.isElementPresent("link=localNode")) {
            selenium.click("link=localNode");
            selenium.waitForPageToLoad("30000");
            selenium.click("link=HTTP-8980");
            selenium.waitForPageToLoad("30000");
            assertTrue("Managed text not found",selenium.isTextPresent("Managed"));
            assertTrue("IP text not found",selenium.isTextPresent("0000:0000:0000:0000:0000:0000:0000:0001"));
            assertTrue("localNode text not found", selenium.isTextPresent("localNode"));
        }else if(selenium.isElementPresent("link=HTTP-8980")){
            selenium.click("link=HTTP-8980");
            selenium.waitForPageToLoad("30000");
            assertTrue("Managed text not found", selenium.isTextPresent("regexp:(Managed|Not Monitored)"));
            assertTrue("IP text not found", selenium.isTextPresent("0:0:0:0:0:0:0:1"));
            assertTrue("localNode text not found", selenium.isTextPresent("localNode"));
        }else {
            fail("Neither of the links were found. Printing page source: " + selenium.getHtmlSource());
        }
    }

    @Test
    public void testAllTopLevelLinks () throws InterruptedException {
        selenium.click("link=Node List");
        selenium.waitForPageToLoad("30000");
        long endTime = System.currentTimeMillis() + 60000;
        while(System.currentTimeMillis() < endTime){
            if(selenium.isTextPresent("Availability") || selenium.isElementPresent("link=localNode")){
                break;
            }
            selenium.refresh();
            selenium.waitForPageToLoad("30000");<commit_msg>take either format<commit_after>package org.opennms.smoketest;

import java.net.URL;

import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.thoughtworks.selenium.SeleneseTestBase;


public class ServicePageTest extends SeleneseTestBase{
    @Before
    public void setUp() throws Exception {
        DesiredCapabilities capability = DesiredCapabilities.firefox();
        WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
        String baseUrl = "http://localhost:8980/";
        selenium = new WebDriverBackedSelenium(driver, baseUrl);
        //selenium.start();
        selenium.open("/opennms/login.jsp");
        selenium.type("name=j_username", "admin");
        selenium.type("name=j_password", "<PASSWORD>");
        selenium.click("name=Login");
        selenium.waitForPageToLoad("30000");
    }

    @Test
    public void testPrvoisioningGroupSetup() throws Exception {
        selenium.click("link=Admin");
        selenium.waitForPageToLoad("30000");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Manage Provisioning Groups");
        selenium.waitForPageToLoad("30000");
        selenium.type("css=form[name=takeAction] > input[name=groupName]", "SeleniumTestGroup");
        selenium.click("css=input[type=submit]");
        selenium.waitForPageToLoad("30000");
        selenium.click("//div[@id='content']/table/tbody/tr[2]/td[2]/a");
        selenium.waitForPageToLoad("30000");
        selenium.click("css=h4 > input[type=button]");
        selenium.waitForPageToLoad("30000");
        selenium.type("id=formData.detectors13.name", "HTTP-8980");
        selenium.select("id=formData.detectors13.pluginClass", "label=HTTP");
        selenium.click("//input[@value='Save']");
        selenium.waitForPageToLoad("30000");
        selenium.click("//form[@id='foreignSourceEditForm']/ul/li[14]/a[3]");
        selenium.waitForPageToLoad("30000");
        selenium.select("id=formData.detectors13.parameters0.key", "label=port");
        selenium.type("id=formData.detectors13.parameters0.value", "8980");
        selenium.click("css=li > input[type=button]");
        selenium.waitForPageToLoad("30000");
        selenium.click("css=input[type=button]");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Edit");
        selenium.waitForPageToLoad("30000");
        selenium.click("//input[@value='Add Node']");
        selenium.waitForPageToLoad("30000");
        selenium.type("id=formData.node0.nodeLabel", "localNode");
        selenium.click("css=li > input[type=button]");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=[Add Interface]");
        selenium.waitForPageToLoad("30000");
        selenium.type("id=formData.node0.interface0.ipAddr", "::1");
        selenium.click("css=li > input[type=button]");
        selenium.waitForPageToLoad("30000");
        selenium.click("css=input[type=button]");
        selenium.waitForPageToLoad("30000");
        selenium.click("//input[@value='Synchronize']");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Log out");
        selenium.waitForPageToLoad("30000");
    }

    @Test
    public void testCreateUser() { 
        selenium.click("link=Admin");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Configure Users, Groups and Roles");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Configure Users");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Add New User");
        selenium.waitForPageToLoad("30000");
        selenium.type("id=userID", "SmokeTestUser");
        selenium.type("id=pass1", "<PASSWORD>");
        selenium.type("id=pass2", "<PASSWORD>");
        selenium.click("id=doOK");
        selenium.waitForPageToLoad("30000");
        selenium.click("id=saveUserButton");
        selenium.waitForPageToLoad("30000");
        assertTrue(selenium.isElementPresent("id=users(SmokeTestUser).doDetails"));
        selenium.click("link=Log out");
        selenium.waitForPageToLoad("30000");
    }

    @Test  
    public void testCreateGroup() {
        selenium.click("link=Admin");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Configure Users, Groups and Roles");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Configure Groups");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Add new group");
        selenium.waitForPageToLoad("30000");
        selenium.type("id=groupName", "SmokeTestGroup");
        selenium.type("id=groupComment", "Test");
        selenium.click("id=doOK");
        selenium.waitForPageToLoad("30000");
        selenium.click("name=finish");
        selenium.waitForPageToLoad("30000");
        selenium.click("//div[@id='content']/form/table/tbody/tr[4]/td[2]/a/img");
        selenium.waitForPageToLoad("30000");
        selenium.addSelection("name=availableUsers", "label=SmokeTestUser");
        selenium.click("xpath=/html/body/div[2]/form/table[2]/tbody/tr[2]/td/table/tbody/tr[2]/td/p/input[2]");
        selenium.click("name=finish");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=SmokeTestGroup");
        selenium.waitForPageToLoad("30000");
        assertTrue(selenium.isTextPresent("SmokeTestUser"));
    }

    @Test
    public void testProvisioningGroupWasCreated() throws InterruptedException {
        selenium.click("link=Node List");
        selenium.waitForPageToLoad("30000");
        if(selenium.isElementPresent("link=localNode")) {
            selenium.click("link=localNode");
            selenium.waitForPageToLoad("30000");
            selenium.click("link=HTTP-8980");
            selenium.waitForPageToLoad("30000");
            assertTrue("Managed text not found",selenium.isTextPresent("Managed"));
            assertTrue("IP text not found",selenium.isTextPresent("0000:0000:0000:0000:0000:0000:0000:0001"));
            assertTrue("localNode text not found", selenium.isTextPresent("localNode"));
        }else if(selenium.isElementPresent("link=HTTP-8980")){
            selenium.click("link=HTTP-8980");
            selenium.waitForPageToLoad("30000");
            assertTrue("Managed text not found", selenium.isTextPresent("regexp:(Managed|Not Monitored)"));
            assertTrue("IP text not found", selenium.isTextPresent("regexp:0+\\:0+\\:0+\\:0+\\:0+\\:0+\\:0+\\:0*1"));
            assertTrue("localNode text not found", selenium.isTextPresent("localNode"));
        }else {
            fail("Neither of the links were found. Printing page source: " + selenium.getHtmlSource());
        }
    }

    @Test
    public void testAllTopLevelLinks () throws InterruptedException {
        selenium.click("link=Node List");
        selenium.waitForPageToLoad("30000");
        long endTime = System.currentTimeMillis() + 60000;
        while(System.currentTimeMillis() < endTime){
            if(selenium.isTextPresent("Availability") || selenium.isElementPresent("link=localNode")){
                break;
            }
            selenium.refresh();
            selenium.waitForPageToLoad("30000");
{'fraction_non_alphanumeric': 0.1538513559207412, 'fraction_numerical': 0.04159058632582674, 'mean_word_length': 3.4880121396054626, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7488030', 'n_tokens_mistral': 5091, 'n_tokens_neox': 4482, 'n_words': 537}