<commit_before>package org.jtalks.tests.jcommune;

import java.util.List;

import org.jtalks.tests.jcommune.common.JCommuneSeleniumTest;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import org.testng.Assert;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import utils.CollectionHelp;
import utils.StringHelp;

/**
 * This functional test covers Creating topic test case TC-JC1
 * http://jtalks.org/display/jcommune/TC-JC1++Create+topic
 *
 * @author erik
 */
public class CreateTopicTCJC1 extends JCommuneSeleniumTest {
	List<WebElement> webElementsList;
	String branchId;
	String subject;
	String message;

	@Test(priority = 1)
	@Parameters({"app-url", "uUsername", "uPassword"})
	public void clickOnRandomSection(String appURL, String username,
									 String password) {
		driver.get(appURL);
		signIn(username, password, appURL);

		webElementsList = driver.findElements(By
				.xpath("//a[@class='forum_header_link']"));
		if (webElementsList.size() == 0) {
			throw new NoSuchElementException("Sections not found");
		}

		CollectionHelp.getRandomWebElementFromCollection(webElementsList)
				.click();

	}

	@Test(priority = 2)
	public void clickOnRandomBranch() {
		webElementsList = driver.findElements(By
				.xpath("//a[@class='forum_link']"));
		if (webElementsList.size() == 0) {
			throw new NoSuchElementException("Branches not found");
		}
		CollectionHelp.getRandomWebElementFromCollection(webElementsList)
				.click();
	}

	@Test(priority = 3)
	public void clickOnNewTopicButton() {
		driver.findElement(
				By.xpath("//a[contains(@href, '/jcommune/topics/new')]"))
				.click();
		Assert.assertTrue(driver.findElement(By.id("subject")).isDisplayed());
		Assert.assertTrue(driver.findElement(By.id("tbMsg")).isDisplayed());
	}

	@Test(priority = 4)
	public void createNewTopic() {
		subject = StringHelp.getRandomString(50);
		message = StringHelp.getRandomString(500);
		driver.findElement(By.id("subject")).sendKeys(subject);
		StringHelp.setLongTextValue(driver, driver.findElement(By.id("tbMsg")),
				message);
		driver.findElement(By.id("post")).click();

		Assert.assertEquals(
				driver.findElement(By.xpath("//a[@class='heading']")).getText(),
				subject);
		Assert.assertEquals(
				driver.findElement(
						By.xpath("//div[@class='forum_message_cell_text']"))
						.getText(), message);
	}

	@Test(priority = 5)
	@Parameters({"app-url"})
	public void clickOnBackButton(String appURL) {

		driver.findElement(
				By.xpath("//a[contains(@href, '/jcommune/branches')]")).click();

		List<WebElement> list = driver
				.findElements(By
						.xpath("//ul[@class='forum_table']/li//a[@class='forum_link']"));
		Assert.assertTrue(assertThatTopicPresent(list, subject));
	}

	/**
	 * this method return true when in list presents the desired text
	 *
	 * @param list The list of webelements
	 * @param text the desired text
	 * @return
	 */
	private boolean assertThatTopicPresent(List<WebElement> list, String text) {
		for (WebElement webElement : list) {
			String t = webElement.getText();
			if (t.equals(text)) {
				return true;
			}
		}
		return false;
	}

}
<commit_msg>some fixes in CreateTopicTCJC1.java<commit_after>package org.jtalks.tests.jcommune;

import java.util.List;

import org.jtalks.tests.jcommune.common.JCommuneSeleniumTest;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import org.testng.Assert;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import utils.CollectionHelp;
import utils.StringHelp;

/**
 * This functional test covers Creating topic test case TC-JC1
 * http://jtalks.org/display/jcommune/TC-JC1++Create+topic
 *
 * @author erik
 */
public class CreateTopicTCJC1 extends JCommuneSeleniumTest {
	List<WebElement> webElementsList;
	String branchId;
	String subject;
	String message;

	@Test(priority = 1)
	@Parameters({"app-url", "uUsername", "uPassword"})
	public void clickOnRandomSectionTest(String appURL, String username,
									 String password) {
		driver.get(appURL);
		signIn(username, password, appURL);

		webElementsList = driver.findElements(By
				.xpath("//a[@class='forum_header_link']"));
		if (webElementsList.size() == 0) {
			throw new NoSuchElementException("Sections not found");
		}

		CollectionHelp.getRandomWebElementFromCollection(webElementsList)
				.click();

	}

	@Test(priority = 2)
	public void clickOnRandomBranchTest() {
		webElementsList = driver.findElements(By
				.xpath("//a[@class='forum_link']"));
		if (webElementsList.size() == 0) {
			throw new NoSuchElementException("Branches not found");
		}
		CollectionHelp.getRandomWebElementFromCollection(webElementsList)
				.click();
	}

	@Test(priority = 3)
	public void clickOnNewTopicButtonTest() {
		driver.findElement(
				By.xpath("//a[contains(@href, '/jcommune/topics/new')]"))
				.click();
		Assert.assertTrue(driver.findElement(By.id("subject")).isDisplayed());
		Assert.assertTrue(driver.findElement(By.id("tbMsg")).isDisplayed());
	}

	@Test(priority = 4)
	public void createNewTopicTest() {
		subject = StringHelp.getRandomString(50);
		message = StringHelp.getRandomString(500);
		driver.findElement(By.id("subject")).sendKeys(subject);
		StringHelp.setLongTextValue(driver, driver.findElement(By.id("tbMsg")),
				message);
		driver.findElement(By.id("post")).click();

		Assert.assertEquals(
				driver.findElement(By.xpath("//a[@class='heading']")).getText(),
				subject);
		Assert.assertEquals(
				driver.findElement(
						By.xpath("//div[@class='forum_message_cell_text']"))
						.getText(), message);
	}

	@Test(priority = 5)
	@Parameters({"app-url"})
	public void clickOnBackButtonTest(String appURL) {

		driver.findElement(
				By.xpath("//a[contains(@href, '/jcommune/branches')]")).click();

		List<WebElement> list = driver
				.findElements(By
						.xpath("//ul[@class='forum_table']/li//a[@class='forum_link']"));
		Assert.assertTrue(assertThatTopicPresent(list, subject));
	}

	/**
	 * this method return true when in list presents the desired text
	 *
	 * @param list The list of webelements
	 * @param text the desired text
	 * @return
	 */
	private boolean assertThatTopicPresent(List<WebElement> list, String text) {
		for (WebElement webElement : list) {
			String t = webElement.getText();
			if (t.equals(text)) {
				return true;
			}
		}
		return false;
	}

}

{'fraction_non_alphanumeric': 0.14649583204692807, 'fraction_numerical': 0.004785427601111454, 'mean_word_length': 4.810762331838565, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '7254090', 'n_tokens_mistral': 2363, 'n_tokens_neox': 2088, 'n_words': 377}