repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/general/PagesLoader.java | // Path: src/main/java/ru/colibri/ui/core/exception/PageDescriptionException.java
// public class PageDescriptionException extends RuntimeException {
// public PageDescriptionException(File file) {
// super(format("Ошибка в описании файла %s. %n " +
// "Проверьте файл на наличие пустых строк и корректность их заполнения", file.getAbsolutePath()));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/Page.java
// @ToString
// @EqualsAndHashCode
// public class Page implements IPage {
// private String systemId;
// private String name;
// private Map<String, IElement> elements = new HashMap<>();
//
// public Page(String name, String systemId) {
// this.systemId = systemId;
// this.name = name;
// }
//
// @Override
// public void addElement(IElement element) {
// elements.put(elementNameToKey(element.getName()), element);
// }
//
// @Override
// public IElement getElementByName(String name) {
// return elements.get(elementNameToKey(name));
// }
//
// @Override
// public List<IElement> getSpecificElements() {
// return elements.entrySet().stream()
// .map(Map.Entry::getValue)
// .filter(IElement::isSpecific)
// .collect(Collectors.toList());
// }
//
// @Override
// public String getSystemId() {
// return systemId;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// private String elementNameToKey(String name) {
// return name.toLowerCase();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
| import com.opencsv.CSVReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.PageDescriptionException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.Page;
import ru.colibri.ui.core.utils.FileUtils;
import java.io.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import static ru.colibri.ui.core.builders.ElementBuilders.element; | package ru.colibri.ui.settings.general;
@Component
public class PagesLoader {
@Autowired
private PropertyUtils propertyUtils;
@Autowired | // Path: src/main/java/ru/colibri/ui/core/exception/PageDescriptionException.java
// public class PageDescriptionException extends RuntimeException {
// public PageDescriptionException(File file) {
// super(format("Ошибка в описании файла %s. %n " +
// "Проверьте файл на наличие пустых строк и корректность их заполнения", file.getAbsolutePath()));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/Page.java
// @ToString
// @EqualsAndHashCode
// public class Page implements IPage {
// private String systemId;
// private String name;
// private Map<String, IElement> elements = new HashMap<>();
//
// public Page(String name, String systemId) {
// this.systemId = systemId;
// this.name = name;
// }
//
// @Override
// public void addElement(IElement element) {
// elements.put(elementNameToKey(element.getName()), element);
// }
//
// @Override
// public IElement getElementByName(String name) {
// return elements.get(elementNameToKey(name));
// }
//
// @Override
// public List<IElement> getSpecificElements() {
// return elements.entrySet().stream()
// .map(Map.Entry::getValue)
// .filter(IElement::isSpecific)
// .collect(Collectors.toList());
// }
//
// @Override
// public String getSystemId() {
// return systemId;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// private String elementNameToKey(String name) {
// return name.toLowerCase();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// Path: src/main/java/ru/colibri/ui/settings/general/PagesLoader.java
import com.opencsv.CSVReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.PageDescriptionException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.Page;
import ru.colibri.ui.core.utils.FileUtils;
import java.io.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import static ru.colibri.ui.core.builders.ElementBuilders.element;
package ru.colibri.ui.settings.general;
@Component
public class PagesLoader {
@Autowired
private PropertyUtils propertyUtils;
@Autowired | private FileUtils fileUtils; |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/general/PagesLoader.java | // Path: src/main/java/ru/colibri/ui/core/exception/PageDescriptionException.java
// public class PageDescriptionException extends RuntimeException {
// public PageDescriptionException(File file) {
// super(format("Ошибка в описании файла %s. %n " +
// "Проверьте файл на наличие пустых строк и корректность их заполнения", file.getAbsolutePath()));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/Page.java
// @ToString
// @EqualsAndHashCode
// public class Page implements IPage {
// private String systemId;
// private String name;
// private Map<String, IElement> elements = new HashMap<>();
//
// public Page(String name, String systemId) {
// this.systemId = systemId;
// this.name = name;
// }
//
// @Override
// public void addElement(IElement element) {
// elements.put(elementNameToKey(element.getName()), element);
// }
//
// @Override
// public IElement getElementByName(String name) {
// return elements.get(elementNameToKey(name));
// }
//
// @Override
// public List<IElement> getSpecificElements() {
// return elements.entrySet().stream()
// .map(Map.Entry::getValue)
// .filter(IElement::isSpecific)
// .collect(Collectors.toList());
// }
//
// @Override
// public String getSystemId() {
// return systemId;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// private String elementNameToKey(String name) {
// return name.toLowerCase();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
| import com.opencsv.CSVReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.PageDescriptionException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.Page;
import ru.colibri.ui.core.utils.FileUtils;
import java.io.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import static ru.colibri.ui.core.builders.ElementBuilders.element; | package ru.colibri.ui.settings.general;
@Component
public class PagesLoader {
@Autowired
private PropertyUtils propertyUtils;
@Autowired
private FileUtils fileUtils;
| // Path: src/main/java/ru/colibri/ui/core/exception/PageDescriptionException.java
// public class PageDescriptionException extends RuntimeException {
// public PageDescriptionException(File file) {
// super(format("Ошибка в описании файла %s. %n " +
// "Проверьте файл на наличие пустых строк и корректность их заполнения", file.getAbsolutePath()));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/Page.java
// @ToString
// @EqualsAndHashCode
// public class Page implements IPage {
// private String systemId;
// private String name;
// private Map<String, IElement> elements = new HashMap<>();
//
// public Page(String name, String systemId) {
// this.systemId = systemId;
// this.name = name;
// }
//
// @Override
// public void addElement(IElement element) {
// elements.put(elementNameToKey(element.getName()), element);
// }
//
// @Override
// public IElement getElementByName(String name) {
// return elements.get(elementNameToKey(name));
// }
//
// @Override
// public List<IElement> getSpecificElements() {
// return elements.entrySet().stream()
// .map(Map.Entry::getValue)
// .filter(IElement::isSpecific)
// .collect(Collectors.toList());
// }
//
// @Override
// public String getSystemId() {
// return systemId;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// private String elementNameToKey(String name) {
// return name.toLowerCase();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// Path: src/main/java/ru/colibri/ui/settings/general/PagesLoader.java
import com.opencsv.CSVReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.PageDescriptionException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.Page;
import ru.colibri.ui.core.utils.FileUtils;
import java.io.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import static ru.colibri.ui.core.builders.ElementBuilders.element;
package ru.colibri.ui.settings.general;
@Component
public class PagesLoader {
@Autowired
private PropertyUtils propertyUtils;
@Autowired
private FileUtils fileUtils;
| public List<IPage> loadPagesFromDirectory(File directory) { |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/general/PagesLoader.java | // Path: src/main/java/ru/colibri/ui/core/exception/PageDescriptionException.java
// public class PageDescriptionException extends RuntimeException {
// public PageDescriptionException(File file) {
// super(format("Ошибка в описании файла %s. %n " +
// "Проверьте файл на наличие пустых строк и корректность их заполнения", file.getAbsolutePath()));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/Page.java
// @ToString
// @EqualsAndHashCode
// public class Page implements IPage {
// private String systemId;
// private String name;
// private Map<String, IElement> elements = new HashMap<>();
//
// public Page(String name, String systemId) {
// this.systemId = systemId;
// this.name = name;
// }
//
// @Override
// public void addElement(IElement element) {
// elements.put(elementNameToKey(element.getName()), element);
// }
//
// @Override
// public IElement getElementByName(String name) {
// return elements.get(elementNameToKey(name));
// }
//
// @Override
// public List<IElement> getSpecificElements() {
// return elements.entrySet().stream()
// .map(Map.Entry::getValue)
// .filter(IElement::isSpecific)
// .collect(Collectors.toList());
// }
//
// @Override
// public String getSystemId() {
// return systemId;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// private String elementNameToKey(String name) {
// return name.toLowerCase();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
| import com.opencsv.CSVReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.PageDescriptionException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.Page;
import ru.colibri.ui.core.utils.FileUtils;
import java.io.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import static ru.colibri.ui.core.builders.ElementBuilders.element; | package ru.colibri.ui.settings.general;
@Component
public class PagesLoader {
@Autowired
private PropertyUtils propertyUtils;
@Autowired
private FileUtils fileUtils;
public List<IPage> loadPagesFromDirectory(File directory) {
return fileUtils.getAllFilesAtDirectory(directory).stream()
.map(this::loadPageFromFile)
.collect(Collectors.toList());
}
public IPage loadPageFromFile(File file) {
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
CSVReader reader = new CSVReader(bufferedReader);
String[] firstLine = reader.readNext();
String pageName = firstLine[0];
String pageId = firstLine[2];
reader.readNext(); //skip line with column name | // Path: src/main/java/ru/colibri/ui/core/exception/PageDescriptionException.java
// public class PageDescriptionException extends RuntimeException {
// public PageDescriptionException(File file) {
// super(format("Ошибка в описании файла %s. %n " +
// "Проверьте файл на наличие пустых строк и корректность их заполнения", file.getAbsolutePath()));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/Page.java
// @ToString
// @EqualsAndHashCode
// public class Page implements IPage {
// private String systemId;
// private String name;
// private Map<String, IElement> elements = new HashMap<>();
//
// public Page(String name, String systemId) {
// this.systemId = systemId;
// this.name = name;
// }
//
// @Override
// public void addElement(IElement element) {
// elements.put(elementNameToKey(element.getName()), element);
// }
//
// @Override
// public IElement getElementByName(String name) {
// return elements.get(elementNameToKey(name));
// }
//
// @Override
// public List<IElement> getSpecificElements() {
// return elements.entrySet().stream()
// .map(Map.Entry::getValue)
// .filter(IElement::isSpecific)
// .collect(Collectors.toList());
// }
//
// @Override
// public String getSystemId() {
// return systemId;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// private String elementNameToKey(String name) {
// return name.toLowerCase();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// Path: src/main/java/ru/colibri/ui/settings/general/PagesLoader.java
import com.opencsv.CSVReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.PageDescriptionException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.Page;
import ru.colibri.ui.core.utils.FileUtils;
import java.io.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import static ru.colibri.ui.core.builders.ElementBuilders.element;
package ru.colibri.ui.settings.general;
@Component
public class PagesLoader {
@Autowired
private PropertyUtils propertyUtils;
@Autowired
private FileUtils fileUtils;
public List<IPage> loadPagesFromDirectory(File directory) {
return fileUtils.getAllFilesAtDirectory(directory).stream()
.map(this::loadPageFromFile)
.collect(Collectors.toList());
}
public IPage loadPageFromFile(File file) {
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
CSVReader reader = new CSVReader(bufferedReader);
String[] firstLine = reader.readNext();
String pageName = firstLine[0];
String pageId = firstLine[2];
reader.readNext(); //skip line with column name | IPage result = new Page(pageName, pageId); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/general/PagesLoader.java | // Path: src/main/java/ru/colibri/ui/core/exception/PageDescriptionException.java
// public class PageDescriptionException extends RuntimeException {
// public PageDescriptionException(File file) {
// super(format("Ошибка в описании файла %s. %n " +
// "Проверьте файл на наличие пустых строк и корректность их заполнения", file.getAbsolutePath()));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/Page.java
// @ToString
// @EqualsAndHashCode
// public class Page implements IPage {
// private String systemId;
// private String name;
// private Map<String, IElement> elements = new HashMap<>();
//
// public Page(String name, String systemId) {
// this.systemId = systemId;
// this.name = name;
// }
//
// @Override
// public void addElement(IElement element) {
// elements.put(elementNameToKey(element.getName()), element);
// }
//
// @Override
// public IElement getElementByName(String name) {
// return elements.get(elementNameToKey(name));
// }
//
// @Override
// public List<IElement> getSpecificElements() {
// return elements.entrySet().stream()
// .map(Map.Entry::getValue)
// .filter(IElement::isSpecific)
// .collect(Collectors.toList());
// }
//
// @Override
// public String getSystemId() {
// return systemId;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// private String elementNameToKey(String name) {
// return name.toLowerCase();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
| import com.opencsv.CSVReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.PageDescriptionException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.Page;
import ru.colibri.ui.core.utils.FileUtils;
import java.io.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import static ru.colibri.ui.core.builders.ElementBuilders.element; | package ru.colibri.ui.settings.general;
@Component
public class PagesLoader {
@Autowired
private PropertyUtils propertyUtils;
@Autowired
private FileUtils fileUtils;
public List<IPage> loadPagesFromDirectory(File directory) {
return fileUtils.getAllFilesAtDirectory(directory).stream()
.map(this::loadPageFromFile)
.collect(Collectors.toList());
}
public IPage loadPageFromFile(File file) {
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
CSVReader reader = new CSVReader(bufferedReader);
String[] firstLine = reader.readNext();
String pageName = firstLine[0];
String pageId = firstLine[2];
reader.readNext(); //skip line with column name
IPage result = new Page(pageName, pageId);
StreamSupport.stream(reader.spliterator(), false)
.map(cells -> getIElement(file, cells))
.forEach(result::addElement);
return result;
} catch (IOException e) {
throw new RuntimeException("Can't parse file " + file.getName(), e);
}
}
| // Path: src/main/java/ru/colibri/ui/core/exception/PageDescriptionException.java
// public class PageDescriptionException extends RuntimeException {
// public PageDescriptionException(File file) {
// super(format("Ошибка в описании файла %s. %n " +
// "Проверьте файл на наличие пустых строк и корректность их заполнения", file.getAbsolutePath()));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/Page.java
// @ToString
// @EqualsAndHashCode
// public class Page implements IPage {
// private String systemId;
// private String name;
// private Map<String, IElement> elements = new HashMap<>();
//
// public Page(String name, String systemId) {
// this.systemId = systemId;
// this.name = name;
// }
//
// @Override
// public void addElement(IElement element) {
// elements.put(elementNameToKey(element.getName()), element);
// }
//
// @Override
// public IElement getElementByName(String name) {
// return elements.get(elementNameToKey(name));
// }
//
// @Override
// public List<IElement> getSpecificElements() {
// return elements.entrySet().stream()
// .map(Map.Entry::getValue)
// .filter(IElement::isSpecific)
// .collect(Collectors.toList());
// }
//
// @Override
// public String getSystemId() {
// return systemId;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// private String elementNameToKey(String name) {
// return name.toLowerCase();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// Path: src/main/java/ru/colibri/ui/settings/general/PagesLoader.java
import com.opencsv.CSVReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.PageDescriptionException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.Page;
import ru.colibri.ui.core.utils.FileUtils;
import java.io.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import static ru.colibri.ui.core.builders.ElementBuilders.element;
package ru.colibri.ui.settings.general;
@Component
public class PagesLoader {
@Autowired
private PropertyUtils propertyUtils;
@Autowired
private FileUtils fileUtils;
public List<IPage> loadPagesFromDirectory(File directory) {
return fileUtils.getAllFilesAtDirectory(directory).stream()
.map(this::loadPageFromFile)
.collect(Collectors.toList());
}
public IPage loadPageFromFile(File file) {
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
CSVReader reader = new CSVReader(bufferedReader);
String[] firstLine = reader.readNext();
String pageName = firstLine[0];
String pageId = firstLine[2];
reader.readNext(); //skip line with column name
IPage result = new Page(pageName, pageId);
StreamSupport.stream(reader.spliterator(), false)
.map(cells -> getIElement(file, cells))
.forEach(result::addElement);
return result;
} catch (IOException e) {
throw new RuntimeException("Can't parse file " + file.getName(), e);
}
}
| private IElement getIElement(File file, String[] cells) { |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/general/PagesLoader.java | // Path: src/main/java/ru/colibri/ui/core/exception/PageDescriptionException.java
// public class PageDescriptionException extends RuntimeException {
// public PageDescriptionException(File file) {
// super(format("Ошибка в описании файла %s. %n " +
// "Проверьте файл на наличие пустых строк и корректность их заполнения", file.getAbsolutePath()));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/Page.java
// @ToString
// @EqualsAndHashCode
// public class Page implements IPage {
// private String systemId;
// private String name;
// private Map<String, IElement> elements = new HashMap<>();
//
// public Page(String name, String systemId) {
// this.systemId = systemId;
// this.name = name;
// }
//
// @Override
// public void addElement(IElement element) {
// elements.put(elementNameToKey(element.getName()), element);
// }
//
// @Override
// public IElement getElementByName(String name) {
// return elements.get(elementNameToKey(name));
// }
//
// @Override
// public List<IElement> getSpecificElements() {
// return elements.entrySet().stream()
// .map(Map.Entry::getValue)
// .filter(IElement::isSpecific)
// .collect(Collectors.toList());
// }
//
// @Override
// public String getSystemId() {
// return systemId;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// private String elementNameToKey(String name) {
// return name.toLowerCase();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
| import com.opencsv.CSVReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.PageDescriptionException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.Page;
import ru.colibri.ui.core.utils.FileUtils;
import java.io.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import static ru.colibri.ui.core.builders.ElementBuilders.element; |
@Autowired
private FileUtils fileUtils;
public List<IPage> loadPagesFromDirectory(File directory) {
return fileUtils.getAllFilesAtDirectory(directory).stream()
.map(this::loadPageFromFile)
.collect(Collectors.toList());
}
public IPage loadPageFromFile(File file) {
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
CSVReader reader = new CSVReader(bufferedReader);
String[] firstLine = reader.readNext();
String pageName = firstLine[0];
String pageId = firstLine[2];
reader.readNext(); //skip line with column name
IPage result = new Page(pageName, pageId);
StreamSupport.stream(reader.spliterator(), false)
.map(cells -> getIElement(file, cells))
.forEach(result::addElement);
return result;
} catch (IOException e) {
throw new RuntimeException("Can't parse file " + file.getName(), e);
}
}
private IElement getIElement(File file, String[] cells) {
if (cells.length == 1 || cells.length < 6 || cells.length > 7) { | // Path: src/main/java/ru/colibri/ui/core/exception/PageDescriptionException.java
// public class PageDescriptionException extends RuntimeException {
// public PageDescriptionException(File file) {
// super(format("Ошибка в описании файла %s. %n " +
// "Проверьте файл на наличие пустых строк и корректность их заполнения", file.getAbsolutePath()));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/Page.java
// @ToString
// @EqualsAndHashCode
// public class Page implements IPage {
// private String systemId;
// private String name;
// private Map<String, IElement> elements = new HashMap<>();
//
// public Page(String name, String systemId) {
// this.systemId = systemId;
// this.name = name;
// }
//
// @Override
// public void addElement(IElement element) {
// elements.put(elementNameToKey(element.getName()), element);
// }
//
// @Override
// public IElement getElementByName(String name) {
// return elements.get(elementNameToKey(name));
// }
//
// @Override
// public List<IElement> getSpecificElements() {
// return elements.entrySet().stream()
// .map(Map.Entry::getValue)
// .filter(IElement::isSpecific)
// .collect(Collectors.toList());
// }
//
// @Override
// public String getSystemId() {
// return systemId;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// private String elementNameToKey(String name) {
// return name.toLowerCase();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// Path: src/main/java/ru/colibri/ui/settings/general/PagesLoader.java
import com.opencsv.CSVReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.PageDescriptionException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.Page;
import ru.colibri.ui.core.utils.FileUtils;
import java.io.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import static ru.colibri.ui.core.builders.ElementBuilders.element;
@Autowired
private FileUtils fileUtils;
public List<IPage> loadPagesFromDirectory(File directory) {
return fileUtils.getAllFilesAtDirectory(directory).stream()
.map(this::loadPageFromFile)
.collect(Collectors.toList());
}
public IPage loadPageFromFile(File file) {
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
CSVReader reader = new CSVReader(bufferedReader);
String[] firstLine = reader.readNext();
String pageName = firstLine[0];
String pageId = firstLine[2];
reader.readNext(); //skip line with column name
IPage result = new Page(pageName, pageId);
StreamSupport.stream(reader.spliterator(), false)
.map(cells -> getIElement(file, cells))
.forEach(result::addElement);
return result;
} catch (IOException e) {
throw new RuntimeException("Can't parse file " + file.getName(), e);
}
}
private IElement getIElement(File file, String[] cells) {
if (cells.length == 1 || cells.length < 6 || cells.length > 7) { | throw new PageDescriptionException(file); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/general/PagesLoader.java | // Path: src/main/java/ru/colibri/ui/core/exception/PageDescriptionException.java
// public class PageDescriptionException extends RuntimeException {
// public PageDescriptionException(File file) {
// super(format("Ошибка в описании файла %s. %n " +
// "Проверьте файл на наличие пустых строк и корректность их заполнения", file.getAbsolutePath()));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/Page.java
// @ToString
// @EqualsAndHashCode
// public class Page implements IPage {
// private String systemId;
// private String name;
// private Map<String, IElement> elements = new HashMap<>();
//
// public Page(String name, String systemId) {
// this.systemId = systemId;
// this.name = name;
// }
//
// @Override
// public void addElement(IElement element) {
// elements.put(elementNameToKey(element.getName()), element);
// }
//
// @Override
// public IElement getElementByName(String name) {
// return elements.get(elementNameToKey(name));
// }
//
// @Override
// public List<IElement> getSpecificElements() {
// return elements.entrySet().stream()
// .map(Map.Entry::getValue)
// .filter(IElement::isSpecific)
// .collect(Collectors.toList());
// }
//
// @Override
// public String getSystemId() {
// return systemId;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// private String elementNameToKey(String name) {
// return name.toLowerCase();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
| import com.opencsv.CSVReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.PageDescriptionException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.Page;
import ru.colibri.ui.core.utils.FileUtils;
import java.io.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import static ru.colibri.ui.core.builders.ElementBuilders.element; | public IPage loadPageFromFile(File file) {
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
CSVReader reader = new CSVReader(bufferedReader);
String[] firstLine = reader.readNext();
String pageName = firstLine[0];
String pageId = firstLine[2];
reader.readNext(); //skip line with column name
IPage result = new Page(pageName, pageId);
StreamSupport.stream(reader.spliterator(), false)
.map(cells -> getIElement(file, cells))
.forEach(result::addElement);
return result;
} catch (IOException e) {
throw new RuntimeException("Can't parse file " + file.getName(), e);
}
}
private IElement getIElement(File file, String[] cells) {
if (cells.length == 1 || cells.length < 6 || cells.length > 7) {
throw new PageDescriptionException(file);
}
String name = cells[0];
String contentDesc = propertyUtils.injectProperties(cells[1]);
String id = propertyUtils.injectProperties(cells[2]);
String text = propertyUtils.injectProperties(cells[3]);
String xpath = propertyUtils.injectProperties(cells[4]);
Boolean specific = Boolean.valueOf(cells[cells.length - 1]);
String nsPredicate = "";
if (cells.length == 7) nsPredicate = propertyUtils.injectProperties(cells[5]); | // Path: src/main/java/ru/colibri/ui/core/exception/PageDescriptionException.java
// public class PageDescriptionException extends RuntimeException {
// public PageDescriptionException(File file) {
// super(format("Ошибка в описании файла %s. %n " +
// "Проверьте файл на наличие пустых строк и корректность их заполнения", file.getAbsolutePath()));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/Page.java
// @ToString
// @EqualsAndHashCode
// public class Page implements IPage {
// private String systemId;
// private String name;
// private Map<String, IElement> elements = new HashMap<>();
//
// public Page(String name, String systemId) {
// this.systemId = systemId;
// this.name = name;
// }
//
// @Override
// public void addElement(IElement element) {
// elements.put(elementNameToKey(element.getName()), element);
// }
//
// @Override
// public IElement getElementByName(String name) {
// return elements.get(elementNameToKey(name));
// }
//
// @Override
// public List<IElement> getSpecificElements() {
// return elements.entrySet().stream()
// .map(Map.Entry::getValue)
// .filter(IElement::isSpecific)
// .collect(Collectors.toList());
// }
//
// @Override
// public String getSystemId() {
// return systemId;
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// private String elementNameToKey(String name) {
// return name.toLowerCase();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// Path: src/main/java/ru/colibri/ui/settings/general/PagesLoader.java
import com.opencsv.CSVReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.PageDescriptionException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.Page;
import ru.colibri.ui.core.utils.FileUtils;
import java.io.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import static ru.colibri.ui.core.builders.ElementBuilders.element;
public IPage loadPageFromFile(File file) {
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
CSVReader reader = new CSVReader(bufferedReader);
String[] firstLine = reader.readNext();
String pageName = firstLine[0];
String pageId = firstLine[2];
reader.readNext(); //skip line with column name
IPage result = new Page(pageName, pageId);
StreamSupport.stream(reader.spliterator(), false)
.map(cells -> getIElement(file, cells))
.forEach(result::addElement);
return result;
} catch (IOException e) {
throw new RuntimeException("Can't parse file " + file.getName(), e);
}
}
private IElement getIElement(File file, String[] cells) {
if (cells.length == 1 || cells.length < 6 || cells.length > 7) {
throw new PageDescriptionException(file);
}
String name = cells[0];
String contentDesc = propertyUtils.injectProperties(cells[1]);
String id = propertyUtils.injectProperties(cells[2]);
String text = propertyUtils.injectProperties(cells[3]);
String xpath = propertyUtils.injectProperties(cells[4]);
Boolean specific = Boolean.valueOf(cells[cells.length - 1]);
String nsPredicate = "";
if (cells.length == 7) nsPredicate = propertyUtils.injectProperties(cells[5]); | return element() |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/steps/ios/IOSTextFieldSteps.java | // Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/steps/general/TextFieldSteps.java
// @Log
// @Component
// public class TextFieldSteps extends AbsSteps {
//
// @Autowired
// private PropertyUtils propertyUtils;
//
// @When("очистить \"$fieldName\"")
// public void clearField(@Named("$fieldName") String fieldName) {
// WebElement webElement = getWebElementByName(fieldName);
// try {
// webElement.clear();
// } catch (WebDriverException ignored) {
// }
// for (int i = webElement.getText().length(); i > 0; i--) {
// webElement.sendKeys(Keys.BACK_SPACE);
// }
// }
//
// @Step
// @When("поле \"$field\" заполняется значением \"$valueOrKeyword\"")
// public void sendKeys(@Named("$field") String field, @Named("$valueOrKeyword") String valueOrKeyword) {
// WebElement webElement = getWebElementByName(field);
// String value = propertyUtils.injectProperties(valueOrKeyword);
// webElement.sendKeys(value);
// }
//
// @Step
// @When("(Optional) поле \"$field\" заполняется значением \"$valueOrKeyword\"")
// public void optionalSendKeys(@Named("$field") String field, @Named("$valueOrKeyword") String valueOrKeyword) {
// try {
// sendKeys(field, valueOrKeyword);
// } catch (Exception ignored) {
// System.out.println("Не удалось ввести");
// }
// }
//
// protected void sendText(String textOrKeyword, By editTextLocator) {
// String text = propertyUtils.injectProperties(textOrKeyword);
// List elements = driver.findElements(editTextLocator);
// WebElement activeElement = null;
// boolean isFocused = false;
// for (int i = 0; !isFocused && i < elements.size(); i++) {
// activeElement = (WebElement) elements.get(i);
// isFocused = Boolean.valueOf(activeElement.getAttribute("focused"));
// }
// if (isFocused) {
// activeElement.sendKeys(text);
// } else {
// log.log(Level.SEVERE, "Нет активных полей ввода!");
// }
// }
// }
| import io.appium.java_client.MobileBy;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.When;
import org.openqa.selenium.By;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.colibri.ui.steps.general.TextFieldSteps;
import ru.yandex.qatools.allure.annotations.Step; | package ru.colibri.ui.steps.ios;
@Component
public class IOSTextFieldSteps extends TextFieldSteps {
private static final By editTextLocator = MobileBy.iOSNsPredicateString("type like 'XCUIElementTypeTextField'");
@Autowired | // Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/steps/general/TextFieldSteps.java
// @Log
// @Component
// public class TextFieldSteps extends AbsSteps {
//
// @Autowired
// private PropertyUtils propertyUtils;
//
// @When("очистить \"$fieldName\"")
// public void clearField(@Named("$fieldName") String fieldName) {
// WebElement webElement = getWebElementByName(fieldName);
// try {
// webElement.clear();
// } catch (WebDriverException ignored) {
// }
// for (int i = webElement.getText().length(); i > 0; i--) {
// webElement.sendKeys(Keys.BACK_SPACE);
// }
// }
//
// @Step
// @When("поле \"$field\" заполняется значением \"$valueOrKeyword\"")
// public void sendKeys(@Named("$field") String field, @Named("$valueOrKeyword") String valueOrKeyword) {
// WebElement webElement = getWebElementByName(field);
// String value = propertyUtils.injectProperties(valueOrKeyword);
// webElement.sendKeys(value);
// }
//
// @Step
// @When("(Optional) поле \"$field\" заполняется значением \"$valueOrKeyword\"")
// public void optionalSendKeys(@Named("$field") String field, @Named("$valueOrKeyword") String valueOrKeyword) {
// try {
// sendKeys(field, valueOrKeyword);
// } catch (Exception ignored) {
// System.out.println("Не удалось ввести");
// }
// }
//
// protected void sendText(String textOrKeyword, By editTextLocator) {
// String text = propertyUtils.injectProperties(textOrKeyword);
// List elements = driver.findElements(editTextLocator);
// WebElement activeElement = null;
// boolean isFocused = false;
// for (int i = 0; !isFocused && i < elements.size(); i++) {
// activeElement = (WebElement) elements.get(i);
// isFocused = Boolean.valueOf(activeElement.getAttribute("focused"));
// }
// if (isFocused) {
// activeElement.sendKeys(text);
// } else {
// log.log(Level.SEVERE, "Нет активных полей ввода!");
// }
// }
// }
// Path: src/main/java/ru/colibri/ui/steps/ios/IOSTextFieldSteps.java
import io.appium.java_client.MobileBy;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.When;
import org.openqa.selenium.By;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.colibri.ui.steps.general.TextFieldSteps;
import ru.yandex.qatools.allure.annotations.Step;
package ru.colibri.ui.steps.ios;
@Component
public class IOSTextFieldSteps extends TextFieldSteps {
private static final By editTextLocator = MobileBy.iOSNsPredicateString("type like 'XCUIElementTypeTextField'");
@Autowired | private PropertyUtils propertyUtils; |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/android/AndroidFinder.java | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/AbsFinder.java
// public abstract class AbsFinder<T extends AppiumDriver> implements IFinder {
// protected abstract T getDriver();
//
// protected abstract DriversSettings getDriversSettings();
//
// @Override
// public WebElement waitClickable(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.elementToBeClickable(by));
// }
//
// @Override
// public WebElement waitVisible(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.visibilityOfElementLocated(by));
// }
//
// @Override
// public WebElement findWebElement(By by) {
// return getDriver().findElement(by);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
| import io.appium.java_client.android.AndroidDriver;
import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.AbsFinder;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.List; | package ru.colibri.ui.settings.android;
@Component
@Qualifier("android") | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/AbsFinder.java
// public abstract class AbsFinder<T extends AppiumDriver> implements IFinder {
// protected abstract T getDriver();
//
// protected abstract DriversSettings getDriversSettings();
//
// @Override
// public WebElement waitClickable(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.elementToBeClickable(by));
// }
//
// @Override
// public WebElement waitVisible(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.visibilityOfElementLocated(by));
// }
//
// @Override
// public WebElement findWebElement(By by) {
// return getDriver().findElement(by);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
// Path: src/main/java/ru/colibri/ui/settings/android/AndroidFinder.java
import io.appium.java_client.android.AndroidDriver;
import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.AbsFinder;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.List;
package ru.colibri.ui.settings.android;
@Component
@Qualifier("android") | public class AndroidFinder extends AbsFinder<AndroidDriver> { |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/android/AndroidFinder.java | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/AbsFinder.java
// public abstract class AbsFinder<T extends AppiumDriver> implements IFinder {
// protected abstract T getDriver();
//
// protected abstract DriversSettings getDriversSettings();
//
// @Override
// public WebElement waitClickable(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.elementToBeClickable(by));
// }
//
// @Override
// public WebElement waitVisible(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.visibilityOfElementLocated(by));
// }
//
// @Override
// public WebElement findWebElement(By by) {
// return getDriver().findElement(by);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
| import io.appium.java_client.android.AndroidDriver;
import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.AbsFinder;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.List; | package ru.colibri.ui.settings.android;
@Component
@Qualifier("android")
public class AndroidFinder extends AbsFinder<AndroidDriver> {
@Autowired
protected AndroidByFactory byFactory;
@Autowired(required = false)
@Qualifier("android")
private AndroidDriver driver;
@Autowired(required = false)
@Qualifier("android") | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/AbsFinder.java
// public abstract class AbsFinder<T extends AppiumDriver> implements IFinder {
// protected abstract T getDriver();
//
// protected abstract DriversSettings getDriversSettings();
//
// @Override
// public WebElement waitClickable(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.elementToBeClickable(by));
// }
//
// @Override
// public WebElement waitVisible(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.visibilityOfElementLocated(by));
// }
//
// @Override
// public WebElement findWebElement(By by) {
// return getDriver().findElement(by);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
// Path: src/main/java/ru/colibri/ui/settings/android/AndroidFinder.java
import io.appium.java_client.android.AndroidDriver;
import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.AbsFinder;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.List;
package ru.colibri.ui.settings.android;
@Component
@Qualifier("android")
public class AndroidFinder extends AbsFinder<AndroidDriver> {
@Autowired
protected AndroidByFactory byFactory;
@Autowired(required = false)
@Qualifier("android")
private AndroidDriver driver;
@Autowired(required = false)
@Qualifier("android") | private DriversSettings driversSettings; |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/android/AndroidFinder.java | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/AbsFinder.java
// public abstract class AbsFinder<T extends AppiumDriver> implements IFinder {
// protected abstract T getDriver();
//
// protected abstract DriversSettings getDriversSettings();
//
// @Override
// public WebElement waitClickable(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.elementToBeClickable(by));
// }
//
// @Override
// public WebElement waitVisible(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.visibilityOfElementLocated(by));
// }
//
// @Override
// public WebElement findWebElement(By by) {
// return getDriver().findElement(by);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
| import io.appium.java_client.android.AndroidDriver;
import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.AbsFinder;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.List; | package ru.colibri.ui.settings.android;
@Component
@Qualifier("android")
public class AndroidFinder extends AbsFinder<AndroidDriver> {
@Autowired
protected AndroidByFactory byFactory;
@Autowired(required = false)
@Qualifier("android")
private AndroidDriver driver;
@Autowired(required = false)
@Qualifier("android")
private DriversSettings driversSettings;
@Override | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/AbsFinder.java
// public abstract class AbsFinder<T extends AppiumDriver> implements IFinder {
// protected abstract T getDriver();
//
// protected abstract DriversSettings getDriversSettings();
//
// @Override
// public WebElement waitClickable(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.elementToBeClickable(by));
// }
//
// @Override
// public WebElement waitVisible(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.visibilityOfElementLocated(by));
// }
//
// @Override
// public WebElement findWebElement(By by) {
// return getDriver().findElement(by);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
// Path: src/main/java/ru/colibri/ui/settings/android/AndroidFinder.java
import io.appium.java_client.android.AndroidDriver;
import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.AbsFinder;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.List;
package ru.colibri.ui.settings.android;
@Component
@Qualifier("android")
public class AndroidFinder extends AbsFinder<AndroidDriver> {
@Autowired
protected AndroidByFactory byFactory;
@Autowired(required = false)
@Qualifier("android")
private AndroidDriver driver;
@Autowired(required = false)
@Qualifier("android")
private DriversSettings driversSettings;
@Override | public WebElement findWebElement(IElement element) { |
alfa-laboratory/colibri-ui | src/test/java/ru/colibri/ui/settings/general/UtilsTestConfig.java | // Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// @Component
// public class ElementBuilders {
//
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
| import io.appium.java_client.AppiumDriver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import ru.colibri.ui.core.builders.ElementBuilders;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.utils.FileUtils;
import java.util.HashMap;
import java.util.Map;
import static org.mockito.Mockito.mock; | package ru.colibri.ui.settings.general;
@Configuration
public class UtilsTestConfig {
@Bean
public PropertyUtils getPropertyUtils() {
return new PropertyUtils();
}
@Bean | // Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// @Component
// public class ElementBuilders {
//
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
// Path: src/test/java/ru/colibri/ui/settings/general/UtilsTestConfig.java
import io.appium.java_client.AppiumDriver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import ru.colibri.ui.core.builders.ElementBuilders;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.utils.FileUtils;
import java.util.HashMap;
import java.util.Map;
import static org.mockito.Mockito.mock;
package ru.colibri.ui.settings.general;
@Configuration
public class UtilsTestConfig {
@Bean
public PropertyUtils getPropertyUtils() {
return new PropertyUtils();
}
@Bean | public AppSettings getFakeAppSettings() { |
alfa-laboratory/colibri-ui | src/test/java/ru/colibri/ui/settings/general/UtilsTestConfig.java | // Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// @Component
// public class ElementBuilders {
//
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
| import io.appium.java_client.AppiumDriver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import ru.colibri.ui.core.builders.ElementBuilders;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.utils.FileUtils;
import java.util.HashMap;
import java.util.Map;
import static org.mockito.Mockito.mock; | package ru.colibri.ui.settings.general;
@Configuration
public class UtilsTestConfig {
@Bean
public PropertyUtils getPropertyUtils() {
return new PropertyUtils();
}
@Bean
public AppSettings getFakeAppSettings() {
return AppSettings.builder().packageName("ru.company.android").userProfile(createFakeUser()).build();
}
@Bean
public AppiumDriver getAppiumDriver() {
return mock(AppiumDriver.class);
}
@Bean | // Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// @Component
// public class ElementBuilders {
//
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
// Path: src/test/java/ru/colibri/ui/settings/general/UtilsTestConfig.java
import io.appium.java_client.AppiumDriver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import ru.colibri.ui.core.builders.ElementBuilders;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.utils.FileUtils;
import java.util.HashMap;
import java.util.Map;
import static org.mockito.Mockito.mock;
package ru.colibri.ui.settings.general;
@Configuration
public class UtilsTestConfig {
@Bean
public PropertyUtils getPropertyUtils() {
return new PropertyUtils();
}
@Bean
public AppSettings getFakeAppSettings() {
return AppSettings.builder().packageName("ru.company.android").userProfile(createFakeUser()).build();
}
@Bean
public AppiumDriver getAppiumDriver() {
return mock(AppiumDriver.class);
}
@Bean | public TestContext getTestContext() { |
alfa-laboratory/colibri-ui | src/test/java/ru/colibri/ui/settings/general/UtilsTestConfig.java | // Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// @Component
// public class ElementBuilders {
//
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
| import io.appium.java_client.AppiumDriver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import ru.colibri.ui.core.builders.ElementBuilders;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.utils.FileUtils;
import java.util.HashMap;
import java.util.Map;
import static org.mockito.Mockito.mock; | package ru.colibri.ui.settings.general;
@Configuration
public class UtilsTestConfig {
@Bean
public PropertyUtils getPropertyUtils() {
return new PropertyUtils();
}
@Bean
public AppSettings getFakeAppSettings() {
return AppSettings.builder().packageName("ru.company.android").userProfile(createFakeUser()).build();
}
@Bean
public AppiumDriver getAppiumDriver() {
return mock(AppiumDriver.class);
}
@Bean
public TestContext getTestContext() {
return mock(TestContext.class);
}
@Bean
public PagesLoader getPagesLoader() {
return new PagesLoader();
}
@Bean | // Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// @Component
// public class ElementBuilders {
//
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
// Path: src/test/java/ru/colibri/ui/settings/general/UtilsTestConfig.java
import io.appium.java_client.AppiumDriver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import ru.colibri.ui.core.builders.ElementBuilders;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.utils.FileUtils;
import java.util.HashMap;
import java.util.Map;
import static org.mockito.Mockito.mock;
package ru.colibri.ui.settings.general;
@Configuration
public class UtilsTestConfig {
@Bean
public PropertyUtils getPropertyUtils() {
return new PropertyUtils();
}
@Bean
public AppSettings getFakeAppSettings() {
return AppSettings.builder().packageName("ru.company.android").userProfile(createFakeUser()).build();
}
@Bean
public AppiumDriver getAppiumDriver() {
return mock(AppiumDriver.class);
}
@Bean
public TestContext getTestContext() {
return mock(TestContext.class);
}
@Bean
public PagesLoader getPagesLoader() {
return new PagesLoader();
}
@Bean | public FileUtils getFileUtils() { |
alfa-laboratory/colibri-ui | src/test/java/ru/colibri/ui/settings/general/UtilsTestConfig.java | // Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// @Component
// public class ElementBuilders {
//
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
| import io.appium.java_client.AppiumDriver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import ru.colibri.ui.core.builders.ElementBuilders;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.utils.FileUtils;
import java.util.HashMap;
import java.util.Map;
import static org.mockito.Mockito.mock; | package ru.colibri.ui.settings.general;
@Configuration
public class UtilsTestConfig {
@Bean
public PropertyUtils getPropertyUtils() {
return new PropertyUtils();
}
@Bean
public AppSettings getFakeAppSettings() {
return AppSettings.builder().packageName("ru.company.android").userProfile(createFakeUser()).build();
}
@Bean
public AppiumDriver getAppiumDriver() {
return mock(AppiumDriver.class);
}
@Bean
public TestContext getTestContext() {
return mock(TestContext.class);
}
@Bean
public PagesLoader getPagesLoader() {
return new PagesLoader();
}
@Bean
public FileUtils getFileUtils() {
return new FileUtils();
}
@Bean | // Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// @Component
// public class ElementBuilders {
//
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
// Path: src/test/java/ru/colibri/ui/settings/general/UtilsTestConfig.java
import io.appium.java_client.AppiumDriver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import ru.colibri.ui.core.builders.ElementBuilders;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.utils.FileUtils;
import java.util.HashMap;
import java.util.Map;
import static org.mockito.Mockito.mock;
package ru.colibri.ui.settings.general;
@Configuration
public class UtilsTestConfig {
@Bean
public PropertyUtils getPropertyUtils() {
return new PropertyUtils();
}
@Bean
public AppSettings getFakeAppSettings() {
return AppSettings.builder().packageName("ru.company.android").userProfile(createFakeUser()).build();
}
@Bean
public AppiumDriver getAppiumDriver() {
return mock(AppiumDriver.class);
}
@Bean
public TestContext getTestContext() {
return mock(TestContext.class);
}
@Bean
public PagesLoader getPagesLoader() {
return new PagesLoader();
}
@Bean
public FileUtils getFileUtils() {
return new FileUtils();
}
@Bean | public ElementBuilders getElementBuilders() { |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/loaders/AbsSettingsLoader.java | // Path: src/main/java/ru/colibri/ui/core/exception/PropertyNotFoundException.java
// public class PropertyNotFoundException extends IllegalArgumentException {
// public PropertyNotFoundException(String message) {
// super(message);
// }
//
// public PropertyNotFoundException(String propertyName, String propertyPath) {
// this(format("Property %s not found on file: %s", propertyName, propertyPath));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/TestSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class TestSettings {
// private List<String> flagsMetaFilters;
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
| import lombok.extern.java.Log;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.InitializingBean;
import ru.colibri.ui.core.exception.PropertyNotFoundException;
import ru.colibri.ui.core.settings.TestSettings;
import ru.colibri.ui.settings.general.PropertyUtils;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import java.util.stream.Collectors;
import static java.lang.String.format;
import static org.apache.commons.io.FileUtils.copyURLToFile; | package ru.colibri.ui.settings.loaders;
@Log
public abstract class AbsSettingsLoader implements ISettingsLoader, InitializingBean {
protected static final String PATH_TEMPLATE = "src/test/resources/environment/%s/device.properties";
protected static final String PATH_USER = "src/test/resources/users/%s.properties";
private static final String TEST_TYPE_FILTER = "src/test/resources/planTestCycle/testCycle.properties";
protected Map<String, String> convertPropertyToMap(Properties properties) {
return properties.entrySet().stream().collect(
Collectors.toMap(
e -> e.getKey().toString(),
e -> e.getValue().toString()
)
);
}
protected void takeArtifact(String from, String to) {
try {
log.log(Level.INFO, format("Loading artifact from: %s", from));
copyURLToFile(new URL(from), new File(to));
log.log(Level.INFO, format("Loading artifact complete to: %s", to));
} catch (IOException e) {
log.log(Level.WARNING, "Error loading file.", e);
}
}
@Override | // Path: src/main/java/ru/colibri/ui/core/exception/PropertyNotFoundException.java
// public class PropertyNotFoundException extends IllegalArgumentException {
// public PropertyNotFoundException(String message) {
// super(message);
// }
//
// public PropertyNotFoundException(String propertyName, String propertyPath) {
// this(format("Property %s not found on file: %s", propertyName, propertyPath));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/TestSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class TestSettings {
// private List<String> flagsMetaFilters;
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
// Path: src/main/java/ru/colibri/ui/settings/loaders/AbsSettingsLoader.java
import lombok.extern.java.Log;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.InitializingBean;
import ru.colibri.ui.core.exception.PropertyNotFoundException;
import ru.colibri.ui.core.settings.TestSettings;
import ru.colibri.ui.settings.general.PropertyUtils;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import java.util.stream.Collectors;
import static java.lang.String.format;
import static org.apache.commons.io.FileUtils.copyURLToFile;
package ru.colibri.ui.settings.loaders;
@Log
public abstract class AbsSettingsLoader implements ISettingsLoader, InitializingBean {
protected static final String PATH_TEMPLATE = "src/test/resources/environment/%s/device.properties";
protected static final String PATH_USER = "src/test/resources/users/%s.properties";
private static final String TEST_TYPE_FILTER = "src/test/resources/planTestCycle/testCycle.properties";
protected Map<String, String> convertPropertyToMap(Properties properties) {
return properties.entrySet().stream().collect(
Collectors.toMap(
e -> e.getKey().toString(),
e -> e.getValue().toString()
)
);
}
protected void takeArtifact(String from, String to) {
try {
log.log(Level.INFO, format("Loading artifact from: %s", from));
copyURLToFile(new URL(from), new File(to));
log.log(Level.INFO, format("Loading artifact complete to: %s", to));
} catch (IOException e) {
log.log(Level.WARNING, "Error loading file.", e);
}
}
@Override | public TestSettings loadTestSettings(String testType) { |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/loaders/AbsSettingsLoader.java | // Path: src/main/java/ru/colibri/ui/core/exception/PropertyNotFoundException.java
// public class PropertyNotFoundException extends IllegalArgumentException {
// public PropertyNotFoundException(String message) {
// super(message);
// }
//
// public PropertyNotFoundException(String propertyName, String propertyPath) {
// this(format("Property %s not found on file: %s", propertyName, propertyPath));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/TestSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class TestSettings {
// private List<String> flagsMetaFilters;
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
| import lombok.extern.java.Log;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.InitializingBean;
import ru.colibri.ui.core.exception.PropertyNotFoundException;
import ru.colibri.ui.core.settings.TestSettings;
import ru.colibri.ui.settings.general.PropertyUtils;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import java.util.stream.Collectors;
import static java.lang.String.format;
import static org.apache.commons.io.FileUtils.copyURLToFile; |
protected void takeArtifact(String from, String to) {
try {
log.log(Level.INFO, format("Loading artifact from: %s", from));
copyURLToFile(new URL(from), new File(to));
log.log(Level.INFO, format("Loading artifact complete to: %s", to));
} catch (IOException e) {
log.log(Level.WARNING, "Error loading file.", e);
}
}
@Override
public TestSettings loadTestSettings(String testType) {
if (StringUtils.isEmpty(testType))
throw new IllegalArgumentException("Не задан тестовый цикл, проверьте данные");
List<String> testCycleFilters = getTestCycleFilters(testType);
return TestSettings.builder()
.flagsMetaFilters(testCycleFilters)
.build();
}
private List<String> getTestCycleFilters(String testType) {
if (testType.matches(".*?[+-].*?")) {
return getFreeTypeTestCycleFilters(testType);
} else {
return getTestCycleFiltersFromProperty(testType);
}
}
private List<String> getTestCycleFiltersFromProperty(String testType) { | // Path: src/main/java/ru/colibri/ui/core/exception/PropertyNotFoundException.java
// public class PropertyNotFoundException extends IllegalArgumentException {
// public PropertyNotFoundException(String message) {
// super(message);
// }
//
// public PropertyNotFoundException(String propertyName, String propertyPath) {
// this(format("Property %s not found on file: %s", propertyName, propertyPath));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/TestSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class TestSettings {
// private List<String> flagsMetaFilters;
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
// Path: src/main/java/ru/colibri/ui/settings/loaders/AbsSettingsLoader.java
import lombok.extern.java.Log;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.InitializingBean;
import ru.colibri.ui.core.exception.PropertyNotFoundException;
import ru.colibri.ui.core.settings.TestSettings;
import ru.colibri.ui.settings.general.PropertyUtils;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import java.util.stream.Collectors;
import static java.lang.String.format;
import static org.apache.commons.io.FileUtils.copyURLToFile;
protected void takeArtifact(String from, String to) {
try {
log.log(Level.INFO, format("Loading artifact from: %s", from));
copyURLToFile(new URL(from), new File(to));
log.log(Level.INFO, format("Loading artifact complete to: %s", to));
} catch (IOException e) {
log.log(Level.WARNING, "Error loading file.", e);
}
}
@Override
public TestSettings loadTestSettings(String testType) {
if (StringUtils.isEmpty(testType))
throw new IllegalArgumentException("Не задан тестовый цикл, проверьте данные");
List<String> testCycleFilters = getTestCycleFilters(testType);
return TestSettings.builder()
.flagsMetaFilters(testCycleFilters)
.build();
}
private List<String> getTestCycleFilters(String testType) {
if (testType.matches(".*?[+-].*?")) {
return getFreeTypeTestCycleFilters(testType);
} else {
return getTestCycleFiltersFromProperty(testType);
}
}
private List<String> getTestCycleFiltersFromProperty(String testType) { | Properties props = PropertyUtils.readProperty(TEST_TYPE_FILTER); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/loaders/AbsSettingsLoader.java | // Path: src/main/java/ru/colibri/ui/core/exception/PropertyNotFoundException.java
// public class PropertyNotFoundException extends IllegalArgumentException {
// public PropertyNotFoundException(String message) {
// super(message);
// }
//
// public PropertyNotFoundException(String propertyName, String propertyPath) {
// this(format("Property %s not found on file: %s", propertyName, propertyPath));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/TestSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class TestSettings {
// private List<String> flagsMetaFilters;
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
| import lombok.extern.java.Log;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.InitializingBean;
import ru.colibri.ui.core.exception.PropertyNotFoundException;
import ru.colibri.ui.core.settings.TestSettings;
import ru.colibri.ui.settings.general.PropertyUtils;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import java.util.stream.Collectors;
import static java.lang.String.format;
import static org.apache.commons.io.FileUtils.copyURLToFile; | log.log(Level.INFO, format("Loading artifact from: %s", from));
copyURLToFile(new URL(from), new File(to));
log.log(Level.INFO, format("Loading artifact complete to: %s", to));
} catch (IOException e) {
log.log(Level.WARNING, "Error loading file.", e);
}
}
@Override
public TestSettings loadTestSettings(String testType) {
if (StringUtils.isEmpty(testType))
throw new IllegalArgumentException("Не задан тестовый цикл, проверьте данные");
List<String> testCycleFilters = getTestCycleFilters(testType);
return TestSettings.builder()
.flagsMetaFilters(testCycleFilters)
.build();
}
private List<String> getTestCycleFilters(String testType) {
if (testType.matches(".*?[+-].*?")) {
return getFreeTypeTestCycleFilters(testType);
} else {
return getTestCycleFiltersFromProperty(testType);
}
}
private List<String> getTestCycleFiltersFromProperty(String testType) {
Properties props = PropertyUtils.readProperty(TEST_TYPE_FILTER);
String testCycle = props.getProperty(testType);
if (StringUtils.isEmpty(testCycle)) { | // Path: src/main/java/ru/colibri/ui/core/exception/PropertyNotFoundException.java
// public class PropertyNotFoundException extends IllegalArgumentException {
// public PropertyNotFoundException(String message) {
// super(message);
// }
//
// public PropertyNotFoundException(String propertyName, String propertyPath) {
// this(format("Property %s not found on file: %s", propertyName, propertyPath));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/TestSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class TestSettings {
// private List<String> flagsMetaFilters;
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
// Path: src/main/java/ru/colibri/ui/settings/loaders/AbsSettingsLoader.java
import lombok.extern.java.Log;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.InitializingBean;
import ru.colibri.ui.core.exception.PropertyNotFoundException;
import ru.colibri.ui.core.settings.TestSettings;
import ru.colibri.ui.settings.general.PropertyUtils;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import java.util.stream.Collectors;
import static java.lang.String.format;
import static org.apache.commons.io.FileUtils.copyURLToFile;
log.log(Level.INFO, format("Loading artifact from: %s", from));
copyURLToFile(new URL(from), new File(to));
log.log(Level.INFO, format("Loading artifact complete to: %s", to));
} catch (IOException e) {
log.log(Level.WARNING, "Error loading file.", e);
}
}
@Override
public TestSettings loadTestSettings(String testType) {
if (StringUtils.isEmpty(testType))
throw new IllegalArgumentException("Не задан тестовый цикл, проверьте данные");
List<String> testCycleFilters = getTestCycleFilters(testType);
return TestSettings.builder()
.flagsMetaFilters(testCycleFilters)
.build();
}
private List<String> getTestCycleFilters(String testType) {
if (testType.matches(".*?[+-].*?")) {
return getFreeTypeTestCycleFilters(testType);
} else {
return getTestCycleFiltersFromProperty(testType);
}
}
private List<String> getTestCycleFiltersFromProperty(String testType) {
Properties props = PropertyUtils.readProperty(TEST_TYPE_FILTER);
String testCycle = props.getProperty(testType);
if (StringUtils.isEmpty(testCycle)) { | throw new PropertyNotFoundException(testType, TEST_TYPE_FILTER); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/steps/ios/IOSPageSteps.java | // Path: src/main/java/ru/colibri/ui/core/exception/ElementFoundOnPageException.java
// public class ElementFoundOnPageException extends RuntimeException {
// public ElementFoundOnPageException(String elementName, String pageName) {
// super("Element \"" + elementName + " found on \"" + pageName + "\". But should not be there.");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
| import io.appium.java_client.MobileBy;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.ElementFoundOnPageException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import static java.lang.String.format; | package ru.colibri.ui.steps.ios;
@Component
public class IOSPageSteps extends AbsSteps {
@Autowired | // Path: src/main/java/ru/colibri/ui/core/exception/ElementFoundOnPageException.java
// public class ElementFoundOnPageException extends RuntimeException {
// public ElementFoundOnPageException(String elementName, String pageName) {
// super("Element \"" + elementName + " found on \"" + pageName + "\". But should not be there.");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
// Path: src/main/java/ru/colibri/ui/steps/ios/IOSPageSteps.java
import io.appium.java_client.MobileBy;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.ElementFoundOnPageException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import static java.lang.String.format;
package ru.colibri.ui.steps.ios;
@Component
public class IOSPageSteps extends AbsSteps {
@Autowired | private PropertyUtils propertyUtils; |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/steps/ios/IOSPageSteps.java | // Path: src/main/java/ru/colibri/ui/core/exception/ElementFoundOnPageException.java
// public class ElementFoundOnPageException extends RuntimeException {
// public ElementFoundOnPageException(String elementName, String pageName) {
// super("Element \"" + elementName + " found on \"" + pageName + "\". But should not be there.");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
| import io.appium.java_client.MobileBy;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.ElementFoundOnPageException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import static java.lang.String.format; | package ru.colibri.ui.steps.ios;
@Component
public class IOSPageSteps extends AbsSteps {
@Autowired
private PropertyUtils propertyUtils;
@Step
@Then("на экране нет \"$elementName\"")
public void checkNoElement(@Named("$elementName") String elementName) { | // Path: src/main/java/ru/colibri/ui/core/exception/ElementFoundOnPageException.java
// public class ElementFoundOnPageException extends RuntimeException {
// public ElementFoundOnPageException(String elementName, String pageName) {
// super("Element \"" + elementName + " found on \"" + pageName + "\". But should not be there.");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
// Path: src/main/java/ru/colibri/ui/steps/ios/IOSPageSteps.java
import io.appium.java_client.MobileBy;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.ElementFoundOnPageException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import static java.lang.String.format;
package ru.colibri.ui.steps.ios;
@Component
public class IOSPageSteps extends AbsSteps {
@Autowired
private PropertyUtils propertyUtils;
@Step
@Then("на экране нет \"$elementName\"")
public void checkNoElement(@Named("$elementName") String elementName) { | IElement element = getCurrentPage().getElementByName(elementName); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/steps/ios/IOSPageSteps.java | // Path: src/main/java/ru/colibri/ui/core/exception/ElementFoundOnPageException.java
// public class ElementFoundOnPageException extends RuntimeException {
// public ElementFoundOnPageException(String elementName, String pageName) {
// super("Element \"" + elementName + " found on \"" + pageName + "\". But should not be there.");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
| import io.appium.java_client.MobileBy;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.ElementFoundOnPageException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import static java.lang.String.format; | package ru.colibri.ui.steps.ios;
@Component
public class IOSPageSteps extends AbsSteps {
@Autowired
private PropertyUtils propertyUtils;
@Step
@Then("на экране нет \"$elementName\"")
public void checkNoElement(@Named("$elementName") String elementName) {
IElement element = getCurrentPage().getElementByName(elementName);
try {
finder.findWebElement(element); | // Path: src/main/java/ru/colibri/ui/core/exception/ElementFoundOnPageException.java
// public class ElementFoundOnPageException extends RuntimeException {
// public ElementFoundOnPageException(String elementName, String pageName) {
// super("Element \"" + elementName + " found on \"" + pageName + "\". But should not be there.");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
// Path: src/main/java/ru/colibri/ui/steps/ios/IOSPageSteps.java
import io.appium.java_client.MobileBy;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.ElementFoundOnPageException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import static java.lang.String.format;
package ru.colibri.ui.steps.ios;
@Component
public class IOSPageSteps extends AbsSteps {
@Autowired
private PropertyUtils propertyUtils;
@Step
@Then("на экране нет \"$elementName\"")
public void checkNoElement(@Named("$elementName") String elementName) {
IElement element = getCurrentPage().getElementByName(elementName);
try {
finder.findWebElement(element); | throw new ElementFoundOnPageException(elementName, getCurrentPage().getName()); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/steps/general/PagesSteps.java | // Path: src/main/java/ru/colibri/ui/core/exception/ElementNotFoundException.java
// public class ElementNotFoundException extends RuntimeException {
// public ElementNotFoundException(String elementName, String pageName) {
// super("Element \"" + elementName + "not found on \"" + pageName + "\".");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/exception/PageNoLoadException.java
// public class PageNoLoadException extends RuntimeException {
// public PageNoLoadException(String pageName) {
// super(format("Page \"%s\" not load", pageName));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
| import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.ElementNotFoundException;
import ru.colibri.ui.core.exception.PageNoLoadException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List; | package ru.colibri.ui.steps.general;
@Component
public class PagesSteps extends AbsSteps {
@Autowired | // Path: src/main/java/ru/colibri/ui/core/exception/ElementNotFoundException.java
// public class ElementNotFoundException extends RuntimeException {
// public ElementNotFoundException(String elementName, String pageName) {
// super("Element \"" + elementName + "not found on \"" + pageName + "\".");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/exception/PageNoLoadException.java
// public class PageNoLoadException extends RuntimeException {
// public PageNoLoadException(String pageName) {
// super(format("Page \"%s\" not load", pageName));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
// Path: src/main/java/ru/colibri/ui/steps/general/PagesSteps.java
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.ElementNotFoundException;
import ru.colibri.ui.core.exception.PageNoLoadException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List;
package ru.colibri.ui.steps.general;
@Component
public class PagesSteps extends AbsSteps {
@Autowired | private PropertyUtils propertyUtils; |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/steps/general/PagesSteps.java | // Path: src/main/java/ru/colibri/ui/core/exception/ElementNotFoundException.java
// public class ElementNotFoundException extends RuntimeException {
// public ElementNotFoundException(String elementName, String pageName) {
// super("Element \"" + elementName + "not found on \"" + pageName + "\".");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/exception/PageNoLoadException.java
// public class PageNoLoadException extends RuntimeException {
// public PageNoLoadException(String pageName) {
// super(format("Page \"%s\" not load", pageName));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
| import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.ElementNotFoundException;
import ru.colibri.ui.core.exception.PageNoLoadException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List; | package ru.colibri.ui.steps.general;
@Component
public class PagesSteps extends AbsSteps {
@Autowired
private PropertyUtils propertyUtils;
@Step
@Then("загружена страница \"$screenName\"")
public void pageLoaded(@Named("$screenName") String screenName) { | // Path: src/main/java/ru/colibri/ui/core/exception/ElementNotFoundException.java
// public class ElementNotFoundException extends RuntimeException {
// public ElementNotFoundException(String elementName, String pageName) {
// super("Element \"" + elementName + "not found on \"" + pageName + "\".");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/exception/PageNoLoadException.java
// public class PageNoLoadException extends RuntimeException {
// public PageNoLoadException(String pageName) {
// super(format("Page \"%s\" not load", pageName));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
// Path: src/main/java/ru/colibri/ui/steps/general/PagesSteps.java
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.ElementNotFoundException;
import ru.colibri.ui.core.exception.PageNoLoadException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List;
package ru.colibri.ui.steps.general;
@Component
public class PagesSteps extends AbsSteps {
@Autowired
private PropertyUtils propertyUtils;
@Step
@Then("загружена страница \"$screenName\"")
public void pageLoaded(@Named("$screenName") String screenName) { | List<IElement> elements = pageProvider.getPageByName(screenName).getSpecificElements(); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/steps/general/PagesSteps.java | // Path: src/main/java/ru/colibri/ui/core/exception/ElementNotFoundException.java
// public class ElementNotFoundException extends RuntimeException {
// public ElementNotFoundException(String elementName, String pageName) {
// super("Element \"" + elementName + "not found on \"" + pageName + "\".");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/exception/PageNoLoadException.java
// public class PageNoLoadException extends RuntimeException {
// public PageNoLoadException(String pageName) {
// super(format("Page \"%s\" not load", pageName));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
| import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.ElementNotFoundException;
import ru.colibri.ui.core.exception.PageNoLoadException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List; | package ru.colibri.ui.steps.general;
@Component
public class PagesSteps extends AbsSteps {
@Autowired
private PropertyUtils propertyUtils;
@Step
@Then("загружена страница \"$screenName\"")
public void pageLoaded(@Named("$screenName") String screenName) {
List<IElement> elements = pageProvider.getPageByName(screenName).getSpecificElements();
for (IElement element : elements) {
WebElement webElement = finder.findWebElement(element);
if (webElement == null) | // Path: src/main/java/ru/colibri/ui/core/exception/ElementNotFoundException.java
// public class ElementNotFoundException extends RuntimeException {
// public ElementNotFoundException(String elementName, String pageName) {
// super("Element \"" + elementName + "not found on \"" + pageName + "\".");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/exception/PageNoLoadException.java
// public class PageNoLoadException extends RuntimeException {
// public PageNoLoadException(String pageName) {
// super(format("Page \"%s\" not load", pageName));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
// Path: src/main/java/ru/colibri/ui/steps/general/PagesSteps.java
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.ElementNotFoundException;
import ru.colibri.ui.core.exception.PageNoLoadException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List;
package ru.colibri.ui.steps.general;
@Component
public class PagesSteps extends AbsSteps {
@Autowired
private PropertyUtils propertyUtils;
@Step
@Then("загружена страница \"$screenName\"")
public void pageLoaded(@Named("$screenName") String screenName) {
List<IElement> elements = pageProvider.getPageByName(screenName).getSpecificElements();
for (IElement element : elements) {
WebElement webElement = finder.findWebElement(element);
if (webElement == null) | throw new PageNoLoadException(screenName); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/steps/general/PagesSteps.java | // Path: src/main/java/ru/colibri/ui/core/exception/ElementNotFoundException.java
// public class ElementNotFoundException extends RuntimeException {
// public ElementNotFoundException(String elementName, String pageName) {
// super("Element \"" + elementName + "not found on \"" + pageName + "\".");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/exception/PageNoLoadException.java
// public class PageNoLoadException extends RuntimeException {
// public PageNoLoadException(String pageName) {
// super(format("Page \"%s\" not load", pageName));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
| import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.ElementNotFoundException;
import ru.colibri.ui.core.exception.PageNoLoadException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List; | package ru.colibri.ui.steps.general;
@Component
public class PagesSteps extends AbsSteps {
@Autowired
private PropertyUtils propertyUtils;
@Step
@Then("загружена страница \"$screenName\"")
public void pageLoaded(@Named("$screenName") String screenName) {
List<IElement> elements = pageProvider.getPageByName(screenName).getSpecificElements();
for (IElement element : elements) {
WebElement webElement = finder.findWebElement(element);
if (webElement == null)
throw new PageNoLoadException(screenName);
}
testContext.setCurrentPageName(screenName);
}
@Step
@Then("(Optional) загружена страница \"$screenName\"")
public void optionalPageLoaded(@Named("$screenName") String screenName) {
try {
pageLoaded(screenName);
} catch (Exception ignored) {
}
}
@Step
@Then("на экране есть \"$elementName\"")
public void checkElement(@Named("$elementName") String elementName) {
WebElement webElement = getWebElementByName(elementName);
if (webElement == null) { | // Path: src/main/java/ru/colibri/ui/core/exception/ElementNotFoundException.java
// public class ElementNotFoundException extends RuntimeException {
// public ElementNotFoundException(String elementName, String pageName) {
// super("Element \"" + elementName + "not found on \"" + pageName + "\".");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/exception/PageNoLoadException.java
// public class PageNoLoadException extends RuntimeException {
// public PageNoLoadException(String pageName) {
// super(format("Page \"%s\" not load", pageName));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
// Path: src/main/java/ru/colibri/ui/steps/general/PagesSteps.java
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.exception.ElementNotFoundException;
import ru.colibri.ui.core.exception.PageNoLoadException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List;
package ru.colibri.ui.steps.general;
@Component
public class PagesSteps extends AbsSteps {
@Autowired
private PropertyUtils propertyUtils;
@Step
@Then("загружена страница \"$screenName\"")
public void pageLoaded(@Named("$screenName") String screenName) {
List<IElement> elements = pageProvider.getPageByName(screenName).getSpecificElements();
for (IElement element : elements) {
WebElement webElement = finder.findWebElement(element);
if (webElement == null)
throw new PageNoLoadException(screenName);
}
testContext.setCurrentPageName(screenName);
}
@Step
@Then("(Optional) загружена страница \"$screenName\"")
public void optionalPageLoaded(@Named("$screenName") String screenName) {
try {
pageLoaded(screenName);
} catch (Exception ignored) {
}
}
@Step
@Then("на экране есть \"$elementName\"")
public void checkElement(@Named("$elementName") String elementName) {
WebElement webElement = getWebElementByName(elementName);
if (webElement == null) { | throw new ElementNotFoundException(elementName, getCurrentPage().getName()); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/core/pages/IPage.java | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
| import ru.colibri.ui.core.fields.IElement;
import java.util.List; | package ru.colibri.ui.core.pages;
public interface IPage {
String getName();
String getSystemId();
| // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
import ru.colibri.ui.core.fields.IElement;
import java.util.List;
package ru.colibri.ui.core.pages;
public interface IPage {
String getName();
String getSystemId();
| List<IElement> getSpecificElements(); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/configurator/AbsDriverConfigurator.java | // Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/IDriverConfigurator.java
// public interface IDriverConfigurator {
// AppiumDriver createDriver(DriversSettings driversSettings, AppSettings appSettings);
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
| import io.appium.java_client.remote.MobileCapabilityType;
import lombok.extern.java.Log;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.springframework.beans.factory.annotation.Autowired;
import ru.colibri.ui.core.settings.DriversSettings;
import ru.colibri.ui.core.settings.IDriverConfigurator;
import ru.colibri.ui.core.utils.FileUtils;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level; | package ru.colibri.ui.settings.configurator;
@Log
public abstract class AbsDriverConfigurator implements IDriverConfigurator {
@Autowired | // Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/IDriverConfigurator.java
// public interface IDriverConfigurator {
// AppiumDriver createDriver(DriversSettings driversSettings, AppSettings appSettings);
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
// Path: src/main/java/ru/colibri/ui/settings/configurator/AbsDriverConfigurator.java
import io.appium.java_client.remote.MobileCapabilityType;
import lombok.extern.java.Log;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.springframework.beans.factory.annotation.Autowired;
import ru.colibri.ui.core.settings.DriversSettings;
import ru.colibri.ui.core.settings.IDriverConfigurator;
import ru.colibri.ui.core.utils.FileUtils;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
package ru.colibri.ui.settings.configurator;
@Log
public abstract class AbsDriverConfigurator implements IDriverConfigurator {
@Autowired | private FileUtils fileUtils; |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/configurator/AbsDriverConfigurator.java | // Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/IDriverConfigurator.java
// public interface IDriverConfigurator {
// AppiumDriver createDriver(DriversSettings driversSettings, AppSettings appSettings);
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
| import io.appium.java_client.remote.MobileCapabilityType;
import lombok.extern.java.Log;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.springframework.beans.factory.annotation.Autowired;
import ru.colibri.ui.core.settings.DriversSettings;
import ru.colibri.ui.core.settings.IDriverConfigurator;
import ru.colibri.ui.core.utils.FileUtils;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level; | package ru.colibri.ui.settings.configurator;
@Log
public abstract class AbsDriverConfigurator implements IDriverConfigurator {
@Autowired
private FileUtils fileUtils;
| // Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/IDriverConfigurator.java
// public interface IDriverConfigurator {
// AppiumDriver createDriver(DriversSettings driversSettings, AppSettings appSettings);
// }
//
// Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
// Path: src/main/java/ru/colibri/ui/settings/configurator/AbsDriverConfigurator.java
import io.appium.java_client.remote.MobileCapabilityType;
import lombok.extern.java.Log;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.springframework.beans.factory.annotation.Autowired;
import ru.colibri.ui.core.settings.DriversSettings;
import ru.colibri.ui.core.settings.IDriverConfigurator;
import ru.colibri.ui.core.utils.FileUtils;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
package ru.colibri.ui.settings.configurator;
@Log
public abstract class AbsDriverConfigurator implements IDriverConfigurator {
@Autowired
private FileUtils fileUtils;
| protected DesiredCapabilities createCapabilities(DriversSettings driversSettings) { |
alfa-laboratory/colibri-ui | src/test/java/ru/colibri/ui/settings/loaders/AbsSettingsLoaderTest.java | // Path: src/main/java/ru/colibri/ui/core/exception/PropertyNotFoundException.java
// public class PropertyNotFoundException extends IllegalArgumentException {
// public PropertyNotFoundException(String message) {
// super(message);
// }
//
// public PropertyNotFoundException(String propertyName, String propertyPath) {
// this(format("Property %s not found on file: %s", propertyName, propertyPath));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/TestSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class TestSettings {
// private List<String> flagsMetaFilters;
// }
| import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import ru.colibri.ui.core.exception.PropertyNotFoundException;
import ru.colibri.ui.core.settings.TestSettings;
import static java.lang.String.format; | package ru.colibri.ui.settings.loaders;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {SettingsLoaderConfig.class})
public class AbsSettingsLoaderTest {
private static final String TEST_TYPE_FILTER = "src/test/resources/planTestCycle/testCycle.properties";
@Autowired
private ISettingsLoader settingsLoader;
@Test(expected = IllegalArgumentException.class)
public void emptyTestType() {
try {
settingsLoader.loadTestSettings(""); | // Path: src/main/java/ru/colibri/ui/core/exception/PropertyNotFoundException.java
// public class PropertyNotFoundException extends IllegalArgumentException {
// public PropertyNotFoundException(String message) {
// super(message);
// }
//
// public PropertyNotFoundException(String propertyName, String propertyPath) {
// this(format("Property %s not found on file: %s", propertyName, propertyPath));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/TestSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class TestSettings {
// private List<String> flagsMetaFilters;
// }
// Path: src/test/java/ru/colibri/ui/settings/loaders/AbsSettingsLoaderTest.java
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import ru.colibri.ui.core.exception.PropertyNotFoundException;
import ru.colibri.ui.core.settings.TestSettings;
import static java.lang.String.format;
package ru.colibri.ui.settings.loaders;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {SettingsLoaderConfig.class})
public class AbsSettingsLoaderTest {
private static final String TEST_TYPE_FILTER = "src/test/resources/planTestCycle/testCycle.properties";
@Autowired
private ISettingsLoader settingsLoader;
@Test(expected = IllegalArgumentException.class)
public void emptyTestType() {
try {
settingsLoader.loadTestSettings(""); | } catch (PropertyNotFoundException e) { |
alfa-laboratory/colibri-ui | src/test/java/ru/colibri/ui/settings/loaders/AbsSettingsLoaderTest.java | // Path: src/main/java/ru/colibri/ui/core/exception/PropertyNotFoundException.java
// public class PropertyNotFoundException extends IllegalArgumentException {
// public PropertyNotFoundException(String message) {
// super(message);
// }
//
// public PropertyNotFoundException(String propertyName, String propertyPath) {
// this(format("Property %s not found on file: %s", propertyName, propertyPath));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/TestSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class TestSettings {
// private List<String> flagsMetaFilters;
// }
| import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import ru.colibri.ui.core.exception.PropertyNotFoundException;
import ru.colibri.ui.core.settings.TestSettings;
import static java.lang.String.format; | package ru.colibri.ui.settings.loaders;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {SettingsLoaderConfig.class})
public class AbsSettingsLoaderTest {
private static final String TEST_TYPE_FILTER = "src/test/resources/planTestCycle/testCycle.properties";
@Autowired
private ISettingsLoader settingsLoader;
@Test(expected = IllegalArgumentException.class)
public void emptyTestType() {
try {
settingsLoader.loadTestSettings("");
} catch (PropertyNotFoundException e) {
Assert.assertEquals(e.getMessage(), "Не задан тестовый цикл, проверьте данные");
}
}
@Test
public void loadTestSettingsFromProperty() throws Exception { | // Path: src/main/java/ru/colibri/ui/core/exception/PropertyNotFoundException.java
// public class PropertyNotFoundException extends IllegalArgumentException {
// public PropertyNotFoundException(String message) {
// super(message);
// }
//
// public PropertyNotFoundException(String propertyName, String propertyPath) {
// this(format("Property %s not found on file: %s", propertyName, propertyPath));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/TestSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class TestSettings {
// private List<String> flagsMetaFilters;
// }
// Path: src/test/java/ru/colibri/ui/settings/loaders/AbsSettingsLoaderTest.java
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import ru.colibri.ui.core.exception.PropertyNotFoundException;
import ru.colibri.ui.core.settings.TestSettings;
import static java.lang.String.format;
package ru.colibri.ui.settings.loaders;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {SettingsLoaderConfig.class})
public class AbsSettingsLoaderTest {
private static final String TEST_TYPE_FILTER = "src/test/resources/planTestCycle/testCycle.properties";
@Autowired
private ISettingsLoader settingsLoader;
@Test(expected = IllegalArgumentException.class)
public void emptyTestType() {
try {
settingsLoader.loadTestSettings("");
} catch (PropertyNotFoundException e) {
Assert.assertEquals(e.getMessage(), "Не задан тестовый цикл, проверьте данные");
}
}
@Test
public void loadTestSettingsFromProperty() throws Exception { | TestSettings testSettings = settingsLoader.loadTestSettings("actual.property"); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/android/AndroidByFactory.java | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/factories/ByFactory.java
// public abstract class ByFactory {
//
// public By byXpath(String xpath) {
// return By.xpath(xpath);
// }
//
// public By byId(String id) {
// return By.id(id);
// }
//
// public abstract By byElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
| import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.By;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.factories.ByFactory;
import ru.colibri.ui.core.settings.AppSettings;
import static java.lang.String.format; | package ru.colibri.ui.settings.android;
@Component
public class AndroidByFactory extends ByFactory {
@Autowired | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/factories/ByFactory.java
// public abstract class ByFactory {
//
// public By byXpath(String xpath) {
// return By.xpath(xpath);
// }
//
// public By byId(String id) {
// return By.id(id);
// }
//
// public abstract By byElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
// Path: src/main/java/ru/colibri/ui/settings/android/AndroidByFactory.java
import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.By;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.factories.ByFactory;
import ru.colibri.ui.core.settings.AppSettings;
import static java.lang.String.format;
package ru.colibri.ui.settings.android;
@Component
public class AndroidByFactory extends ByFactory {
@Autowired | private AppSettings appSettings; |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/android/AndroidByFactory.java | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/factories/ByFactory.java
// public abstract class ByFactory {
//
// public By byXpath(String xpath) {
// return By.xpath(xpath);
// }
//
// public By byId(String id) {
// return By.id(id);
// }
//
// public abstract By byElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
| import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.By;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.factories.ByFactory;
import ru.colibri.ui.core.settings.AppSettings;
import static java.lang.String.format; | package ru.colibri.ui.settings.android;
@Component
public class AndroidByFactory extends ByFactory {
@Autowired
private AppSettings appSettings;
private String scrollTemplate = "new UiScrollable(new UiSelector().scrollable(true).resourceId(\"%s\")).scrollIntoView(new UiSelector().%s)";
protected String getAndroidIdPrefix() {
return appSettings.getPackageName() + ":id/";
}
| // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/factories/ByFactory.java
// public abstract class ByFactory {
//
// public By byXpath(String xpath) {
// return By.xpath(xpath);
// }
//
// public By byId(String id) {
// return By.id(id);
// }
//
// public abstract By byElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
// Path: src/main/java/ru/colibri/ui/settings/android/AndroidByFactory.java
import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.By;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.factories.ByFactory;
import ru.colibri.ui.core.settings.AppSettings;
import static java.lang.String.format;
package ru.colibri.ui.settings.android;
@Component
public class AndroidByFactory extends ByFactory {
@Autowired
private AppSettings appSettings;
private String scrollTemplate = "new UiScrollable(new UiSelector().scrollable(true).resourceId(\"%s\")).scrollIntoView(new UiSelector().%s)";
protected String getAndroidIdPrefix() {
return appSettings.getPackageName() + ":id/";
}
| private String createSearchXpath(IElement element) { |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/steps/general/ListItemCheck.java | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
| import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List;
import static java.lang.String.format;
import static org.junit.Assert.assertTrue; | package ru.colibri.ui.steps.general;
@Component
public class ListItemCheck extends AbsSteps {
@Autowired | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
// Path: src/main/java/ru/colibri/ui/steps/general/ListItemCheck.java
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List;
import static java.lang.String.format;
import static org.junit.Assert.assertTrue;
package ru.colibri.ui.steps.general;
@Component
public class ListItemCheck extends AbsSteps {
@Autowired | private PropertyUtils propertyUtils; |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/steps/general/ListItemCheck.java | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
| import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List;
import static java.lang.String.format;
import static org.junit.Assert.assertTrue; | package ru.colibri.ui.steps.general;
@Component
public class ListItemCheck extends AbsSteps {
@Autowired
private PropertyUtils propertyUtils;
@Step
@Then("количество найденных элементов \"$fieldName\" равно \"$quantityExpectedValue\"")
public void listItemCheck(@Named("$fieldName") String fieldName, @Named("$quantityExpectedValue") String quantityExpectedValue) { | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
// Path: src/main/java/ru/colibri/ui/steps/general/ListItemCheck.java
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List;
import static java.lang.String.format;
import static org.junit.Assert.assertTrue;
package ru.colibri.ui.steps.general;
@Component
public class ListItemCheck extends AbsSteps {
@Autowired
private PropertyUtils propertyUtils;
@Step
@Then("количество найденных элементов \"$fieldName\" равно \"$quantityExpectedValue\"")
public void listItemCheck(@Named("$fieldName") String fieldName, @Named("$quantityExpectedValue") String quantityExpectedValue) { | IElement element = getCurrentPage().getElementByName(fieldName); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/ios/IOSByFactory.java | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/factories/ByFactory.java
// public abstract class ByFactory {
//
// public By byXpath(String xpath) {
// return By.xpath(xpath);
// }
//
// public By byId(String id) {
// return By.id(id);
// }
//
// public abstract By byElement(IElement element);
// }
| import io.appium.java_client.MobileBy;
import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.By;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.factories.ByFactory;
import static java.lang.String.format; | package ru.colibri.ui.settings.ios;
@Component
public class IOSByFactory extends ByFactory {
private static String IOSNSPREDICATE_TEMPLATE = "name contains '%1$s' or value contains '%1$s' or label contains '%1$s'";
private String XPATH_TEMPLATE = "//*[contains(@name,'%1$s') or contains(@value,'%1$s') or contains(@label,'%1$s')]";
public By byNameOrValueOrLabel(String label) {
return byIOSNSPredicate(createIOSNSPredicateByNameOrValueOrLabel(label));
}
private String createXPathByNameOrValueOrLabel(String label) {
return format(XPATH_TEMPLATE, label);
}
private String createIOSNSPredicateByNameOrValueOrLabel(String label) {
return format(IOSNSPREDICATE_TEMPLATE, label);
}
@Override | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/factories/ByFactory.java
// public abstract class ByFactory {
//
// public By byXpath(String xpath) {
// return By.xpath(xpath);
// }
//
// public By byId(String id) {
// return By.id(id);
// }
//
// public abstract By byElement(IElement element);
// }
// Path: src/main/java/ru/colibri/ui/settings/ios/IOSByFactory.java
import io.appium.java_client.MobileBy;
import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.By;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.factories.ByFactory;
import static java.lang.String.format;
package ru.colibri.ui.settings.ios;
@Component
public class IOSByFactory extends ByFactory {
private static String IOSNSPREDICATE_TEMPLATE = "name contains '%1$s' or value contains '%1$s' or label contains '%1$s'";
private String XPATH_TEMPLATE = "//*[contains(@name,'%1$s') or contains(@value,'%1$s') or contains(@label,'%1$s')]";
public By byNameOrValueOrLabel(String label) {
return byIOSNSPredicate(createIOSNSPredicateByNameOrValueOrLabel(label));
}
private String createXPathByNameOrValueOrLabel(String label) {
return format(XPATH_TEMPLATE, label);
}
private String createIOSNSPredicateByNameOrValueOrLabel(String label) {
return format(IOSNSPREDICATE_TEMPLATE, label);
}
@Override | public By byElement(IElement element) { |
alfa-laboratory/colibri-ui | src/test/java/ru/colibri/ui/settings/general/PagesLoaderTest.java | // Path: src/main/java/ru/colibri/ui/core/exception/PageDescriptionException.java
// public class PageDescriptionException extends RuntimeException {
// public PageDescriptionException(File file) {
// super(format("Ошибка в описании файла %s. %n " +
// "Проверьте файл на наличие пустых строк и корректность их заполнения", file.getAbsolutePath()));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
| import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import ru.colibri.ui.core.exception.PageDescriptionException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.pages.IPage;
import java.io.File;
import java.util.List;
import static org.junit.Assert.assertTrue; | package ru.colibri.ui.settings.general;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {UtilsTestConfig.class})
public class PagesLoaderTest {
private final static String FILE_PATH = "src/test/resources/loadFiles/goodPage.csv";
private final static String BAD_FILE_PATH = "src/test/resources/loadFiles/badPage.csv";
private final static String BAD_FILE_PATH2 = "src/test/resources/loadFiles/badPage2.csv";
private final static String BAD_FILE_PATH3 = "src/test/resources/loadFiles/badPage3.csv";
private final static String DIR_PATH = "src/test/resources/loadFiles/loadDir";
@Autowired
private PagesLoader pagesLoader;
@Test
public void loadPageFromFile() throws Exception { | // Path: src/main/java/ru/colibri/ui/core/exception/PageDescriptionException.java
// public class PageDescriptionException extends RuntimeException {
// public PageDescriptionException(File file) {
// super(format("Ошибка в описании файла %s. %n " +
// "Проверьте файл на наличие пустых строк и корректность их заполнения", file.getAbsolutePath()));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
// Path: src/test/java/ru/colibri/ui/settings/general/PagesLoaderTest.java
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import ru.colibri.ui.core.exception.PageDescriptionException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.pages.IPage;
import java.io.File;
import java.util.List;
import static org.junit.Assert.assertTrue;
package ru.colibri.ui.settings.general;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {UtilsTestConfig.class})
public class PagesLoaderTest {
private final static String FILE_PATH = "src/test/resources/loadFiles/goodPage.csv";
private final static String BAD_FILE_PATH = "src/test/resources/loadFiles/badPage.csv";
private final static String BAD_FILE_PATH2 = "src/test/resources/loadFiles/badPage2.csv";
private final static String BAD_FILE_PATH3 = "src/test/resources/loadFiles/badPage3.csv";
private final static String DIR_PATH = "src/test/resources/loadFiles/loadDir";
@Autowired
private PagesLoader pagesLoader;
@Test
public void loadPageFromFile() throws Exception { | IPage iPage = pagesLoader.loadPageFromFile(new File(FILE_PATH)); |
alfa-laboratory/colibri-ui | src/test/java/ru/colibri/ui/settings/general/PagesLoaderTest.java | // Path: src/main/java/ru/colibri/ui/core/exception/PageDescriptionException.java
// public class PageDescriptionException extends RuntimeException {
// public PageDescriptionException(File file) {
// super(format("Ошибка в описании файла %s. %n " +
// "Проверьте файл на наличие пустых строк и корректность их заполнения", file.getAbsolutePath()));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
| import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import ru.colibri.ui.core.exception.PageDescriptionException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.pages.IPage;
import java.io.File;
import java.util.List;
import static org.junit.Assert.assertTrue; | package ru.colibri.ui.settings.general;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {UtilsTestConfig.class})
public class PagesLoaderTest {
private final static String FILE_PATH = "src/test/resources/loadFiles/goodPage.csv";
private final static String BAD_FILE_PATH = "src/test/resources/loadFiles/badPage.csv";
private final static String BAD_FILE_PATH2 = "src/test/resources/loadFiles/badPage2.csv";
private final static String BAD_FILE_PATH3 = "src/test/resources/loadFiles/badPage3.csv";
private final static String DIR_PATH = "src/test/resources/loadFiles/loadDir";
@Autowired
private PagesLoader pagesLoader;
@Test
public void loadPageFromFile() throws Exception {
IPage iPage = pagesLoader.loadPageFromFile(new File(FILE_PATH)); | // Path: src/main/java/ru/colibri/ui/core/exception/PageDescriptionException.java
// public class PageDescriptionException extends RuntimeException {
// public PageDescriptionException(File file) {
// super(format("Ошибка в описании файла %s. %n " +
// "Проверьте файл на наличие пустых строк и корректность их заполнения", file.getAbsolutePath()));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
// Path: src/test/java/ru/colibri/ui/settings/general/PagesLoaderTest.java
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import ru.colibri.ui.core.exception.PageDescriptionException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.pages.IPage;
import java.io.File;
import java.util.List;
import static org.junit.Assert.assertTrue;
package ru.colibri.ui.settings.general;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {UtilsTestConfig.class})
public class PagesLoaderTest {
private final static String FILE_PATH = "src/test/resources/loadFiles/goodPage.csv";
private final static String BAD_FILE_PATH = "src/test/resources/loadFiles/badPage.csv";
private final static String BAD_FILE_PATH2 = "src/test/resources/loadFiles/badPage2.csv";
private final static String BAD_FILE_PATH3 = "src/test/resources/loadFiles/badPage3.csv";
private final static String DIR_PATH = "src/test/resources/loadFiles/loadDir";
@Autowired
private PagesLoader pagesLoader;
@Test
public void loadPageFromFile() throws Exception {
IPage iPage = pagesLoader.loadPageFromFile(new File(FILE_PATH)); | IElement element = iPage.getElementByName("Тарифный план"); |
alfa-laboratory/colibri-ui | src/test/java/ru/colibri/ui/settings/general/PagesLoaderTest.java | // Path: src/main/java/ru/colibri/ui/core/exception/PageDescriptionException.java
// public class PageDescriptionException extends RuntimeException {
// public PageDescriptionException(File file) {
// super(format("Ошибка в описании файла %s. %n " +
// "Проверьте файл на наличие пустых строк и корректность их заполнения", file.getAbsolutePath()));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
| import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import ru.colibri.ui.core.exception.PageDescriptionException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.pages.IPage;
import java.io.File;
import java.util.List;
import static org.junit.Assert.assertTrue; | package ru.colibri.ui.settings.general;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {UtilsTestConfig.class})
public class PagesLoaderTest {
private final static String FILE_PATH = "src/test/resources/loadFiles/goodPage.csv";
private final static String BAD_FILE_PATH = "src/test/resources/loadFiles/badPage.csv";
private final static String BAD_FILE_PATH2 = "src/test/resources/loadFiles/badPage2.csv";
private final static String BAD_FILE_PATH3 = "src/test/resources/loadFiles/badPage3.csv";
private final static String DIR_PATH = "src/test/resources/loadFiles/loadDir";
@Autowired
private PagesLoader pagesLoader;
@Test
public void loadPageFromFile() throws Exception {
IPage iPage = pagesLoader.loadPageFromFile(new File(FILE_PATH));
IElement element = iPage.getElementByName("Тарифный план");
Assert.assertTrue(element.isSpecific());
}
| // Path: src/main/java/ru/colibri/ui/core/exception/PageDescriptionException.java
// public class PageDescriptionException extends RuntimeException {
// public PageDescriptionException(File file) {
// super(format("Ошибка в описании файла %s. %n " +
// "Проверьте файл на наличие пустых строк и корректность их заполнения", file.getAbsolutePath()));
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
// Path: src/test/java/ru/colibri/ui/settings/general/PagesLoaderTest.java
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import ru.colibri.ui.core.exception.PageDescriptionException;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.pages.IPage;
import java.io.File;
import java.util.List;
import static org.junit.Assert.assertTrue;
package ru.colibri.ui.settings.general;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {UtilsTestConfig.class})
public class PagesLoaderTest {
private final static String FILE_PATH = "src/test/resources/loadFiles/goodPage.csv";
private final static String BAD_FILE_PATH = "src/test/resources/loadFiles/badPage.csv";
private final static String BAD_FILE_PATH2 = "src/test/resources/loadFiles/badPage2.csv";
private final static String BAD_FILE_PATH3 = "src/test/resources/loadFiles/badPage3.csv";
private final static String DIR_PATH = "src/test/resources/loadFiles/loadDir";
@Autowired
private PagesLoader pagesLoader;
@Test
public void loadPageFromFile() throws Exception {
IPage iPage = pagesLoader.loadPageFromFile(new File(FILE_PATH));
IElement element = iPage.getElementByName("Тарифный план");
Assert.assertTrue(element.isSpecific());
}
| @Test(expected = PageDescriptionException.class) |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/core/finder/AbsFinder.java | // Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
| import io.appium.java_client.AppiumDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Wait;
import org.openqa.selenium.support.ui.WebDriverWait;
import ru.colibri.ui.core.settings.DriversSettings; | package ru.colibri.ui.core.finder;
public abstract class AbsFinder<T extends AppiumDriver> implements IFinder {
protected abstract T getDriver();
| // Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
// Path: src/main/java/ru/colibri/ui/core/finder/AbsFinder.java
import io.appium.java_client.AppiumDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Wait;
import org.openqa.selenium.support.ui.WebDriverWait;
import ru.colibri.ui.core.settings.DriversSettings;
package ru.colibri.ui.core.finder;
public abstract class AbsFinder<T extends AppiumDriver> implements IFinder {
protected abstract T getDriver();
| protected abstract DriversSettings getDriversSettings(); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/general/JBConfiguratorImpl.java | // Path: src/main/java/ru/colibri/ui/core/reporters/AllureReporter.java
// @Component
// public class AllureReporter extends NullStoryReporter {
// private final Map<String, String> suites = new HashMap<>();
// @Autowired
// private ApplicationContext applicationContext;
// private Allure allure = Allure.LIFECYCLE;
// private String uid;
//
// @Override
// public void beforeStory(Story story, boolean givenStory) {
// uid = generateSuiteUid(story);
// String path = story.getPath();
// int secondIndex = StringUtils.ordinalIndexOf(path, "/", 2);
// String subPath = path.substring(secondIndex + 1);
// TestSuiteStartedEvent event = new TestSuiteStartedEvent(uid, story.getName());
// event.withLabels(AllureModelUtils.createTestFrameworkLabel("JBehave"));
// event.withTitle(subPath);
// allure.fire(event);
// }
//
// @Override
// public void afterStory(boolean givenStory) {
// allure.fire(new TestSuiteFinishedEvent(uid));
// }
//
// @Override
// public void beforeScenario(Scenario scenario) {
// allure.fire(new TestCaseStartedEvent(uid, scenario.getTitle()));
// allure.fire(new ClearStepStorageEvent());
// }
//
// @Override
// public void beforeStep(String step) {
// allure.fire(new StepStartedEvent(step).withTitle(step));
// }
//
// @Override
// public void successful(String step) {
// allure.fire(new StepFinishedEvent());
// }
//
// @Override
// public void ignorable(String step) {
// allure.fire(new StepCanceledEvent());
// }
//
// @Override
// public void notPerformed(String step) {
// allure.fire(new StepCanceledEvent());
// }
//
// @Override
// public void failed(String step, Throwable cause) {
// takeScreenshot(step);
// allure.fire(new StepFinishedEvent());
// allure.fire(new StepFailureEvent().withThrowable(cause.getCause()));
// allure.fire(new TestCaseFailureEvent().withThrowable(cause.getCause()));
//
// }
//
// @Override
// public void pending(String step) {
// allure.fire(new StepCanceledEvent());
// allure.fire(new TestCasePendingEvent().withMessage("PENDING"));
// }
//
// @Override
// public void afterScenario() {
// allure.fire(new TestCaseFinishedEvent());
// }
//
//
// /**
// * Generate suite uid.
// *
// * @param story the story
// * @return the string
// */
// public String generateSuiteUid(Story story) {
// String uId = UUID.randomUUID().toString();
// synchronized (getSuites()) {
// getSuites().put(story.getPath(), uId);
// }
// return uId;
// }
//
// public Map<String, String> getSuites() {
// return suites;
// }
//
// public void takeScreenshot(String step) {
// if (applicationContext.getBean(AppiumDriver.class) != null) {
// Allure.LIFECYCLE.fire(new MakeAttachmentEvent((applicationContext.getBean(AppiumDriver.class)).getScreenshotAs(OutputType.BYTES), step, "image/png"));
// }
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/IJBConfigurator.java
// public interface IJBConfigurator {
//
// Configuration createConfig();
//
// Configuration createConfig(ViewGenerator viewGenerator, Format... formats);
//
// void configure(EmbedderControls embedderControls, DriversSettings driversSettings);
// }
| import org.jbehave.core.configuration.Configuration;
import org.jbehave.core.configuration.MostUsefulConfiguration;
import org.jbehave.core.embedder.EmbedderControls;
import org.jbehave.core.embedder.StoryControls;
import org.jbehave.core.reporters.Format;
import org.jbehave.core.reporters.StoryReporterBuilder;
import org.jbehave.core.reporters.ViewGenerator;
import org.jbehave.core.steps.ParameterConverters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.reporters.AllureReporter;
import ru.colibri.ui.core.settings.DriversSettings;
import ru.colibri.ui.core.settings.IJBConfigurator; | package ru.colibri.ui.settings.general;
@Component
public class JBConfiguratorImpl implements IJBConfigurator {
@Autowired | // Path: src/main/java/ru/colibri/ui/core/reporters/AllureReporter.java
// @Component
// public class AllureReporter extends NullStoryReporter {
// private final Map<String, String> suites = new HashMap<>();
// @Autowired
// private ApplicationContext applicationContext;
// private Allure allure = Allure.LIFECYCLE;
// private String uid;
//
// @Override
// public void beforeStory(Story story, boolean givenStory) {
// uid = generateSuiteUid(story);
// String path = story.getPath();
// int secondIndex = StringUtils.ordinalIndexOf(path, "/", 2);
// String subPath = path.substring(secondIndex + 1);
// TestSuiteStartedEvent event = new TestSuiteStartedEvent(uid, story.getName());
// event.withLabels(AllureModelUtils.createTestFrameworkLabel("JBehave"));
// event.withTitle(subPath);
// allure.fire(event);
// }
//
// @Override
// public void afterStory(boolean givenStory) {
// allure.fire(new TestSuiteFinishedEvent(uid));
// }
//
// @Override
// public void beforeScenario(Scenario scenario) {
// allure.fire(new TestCaseStartedEvent(uid, scenario.getTitle()));
// allure.fire(new ClearStepStorageEvent());
// }
//
// @Override
// public void beforeStep(String step) {
// allure.fire(new StepStartedEvent(step).withTitle(step));
// }
//
// @Override
// public void successful(String step) {
// allure.fire(new StepFinishedEvent());
// }
//
// @Override
// public void ignorable(String step) {
// allure.fire(new StepCanceledEvent());
// }
//
// @Override
// public void notPerformed(String step) {
// allure.fire(new StepCanceledEvent());
// }
//
// @Override
// public void failed(String step, Throwable cause) {
// takeScreenshot(step);
// allure.fire(new StepFinishedEvent());
// allure.fire(new StepFailureEvent().withThrowable(cause.getCause()));
// allure.fire(new TestCaseFailureEvent().withThrowable(cause.getCause()));
//
// }
//
// @Override
// public void pending(String step) {
// allure.fire(new StepCanceledEvent());
// allure.fire(new TestCasePendingEvent().withMessage("PENDING"));
// }
//
// @Override
// public void afterScenario() {
// allure.fire(new TestCaseFinishedEvent());
// }
//
//
// /**
// * Generate suite uid.
// *
// * @param story the story
// * @return the string
// */
// public String generateSuiteUid(Story story) {
// String uId = UUID.randomUUID().toString();
// synchronized (getSuites()) {
// getSuites().put(story.getPath(), uId);
// }
// return uId;
// }
//
// public Map<String, String> getSuites() {
// return suites;
// }
//
// public void takeScreenshot(String step) {
// if (applicationContext.getBean(AppiumDriver.class) != null) {
// Allure.LIFECYCLE.fire(new MakeAttachmentEvent((applicationContext.getBean(AppiumDriver.class)).getScreenshotAs(OutputType.BYTES), step, "image/png"));
// }
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/IJBConfigurator.java
// public interface IJBConfigurator {
//
// Configuration createConfig();
//
// Configuration createConfig(ViewGenerator viewGenerator, Format... formats);
//
// void configure(EmbedderControls embedderControls, DriversSettings driversSettings);
// }
// Path: src/main/java/ru/colibri/ui/settings/general/JBConfiguratorImpl.java
import org.jbehave.core.configuration.Configuration;
import org.jbehave.core.configuration.MostUsefulConfiguration;
import org.jbehave.core.embedder.EmbedderControls;
import org.jbehave.core.embedder.StoryControls;
import org.jbehave.core.reporters.Format;
import org.jbehave.core.reporters.StoryReporterBuilder;
import org.jbehave.core.reporters.ViewGenerator;
import org.jbehave.core.steps.ParameterConverters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.reporters.AllureReporter;
import ru.colibri.ui.core.settings.DriversSettings;
import ru.colibri.ui.core.settings.IJBConfigurator;
package ru.colibri.ui.settings.general;
@Component
public class JBConfiguratorImpl implements IJBConfigurator {
@Autowired | private AllureReporter allureReporter; |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/general/JBConfiguratorImpl.java | // Path: src/main/java/ru/colibri/ui/core/reporters/AllureReporter.java
// @Component
// public class AllureReporter extends NullStoryReporter {
// private final Map<String, String> suites = new HashMap<>();
// @Autowired
// private ApplicationContext applicationContext;
// private Allure allure = Allure.LIFECYCLE;
// private String uid;
//
// @Override
// public void beforeStory(Story story, boolean givenStory) {
// uid = generateSuiteUid(story);
// String path = story.getPath();
// int secondIndex = StringUtils.ordinalIndexOf(path, "/", 2);
// String subPath = path.substring(secondIndex + 1);
// TestSuiteStartedEvent event = new TestSuiteStartedEvent(uid, story.getName());
// event.withLabels(AllureModelUtils.createTestFrameworkLabel("JBehave"));
// event.withTitle(subPath);
// allure.fire(event);
// }
//
// @Override
// public void afterStory(boolean givenStory) {
// allure.fire(new TestSuiteFinishedEvent(uid));
// }
//
// @Override
// public void beforeScenario(Scenario scenario) {
// allure.fire(new TestCaseStartedEvent(uid, scenario.getTitle()));
// allure.fire(new ClearStepStorageEvent());
// }
//
// @Override
// public void beforeStep(String step) {
// allure.fire(new StepStartedEvent(step).withTitle(step));
// }
//
// @Override
// public void successful(String step) {
// allure.fire(new StepFinishedEvent());
// }
//
// @Override
// public void ignorable(String step) {
// allure.fire(new StepCanceledEvent());
// }
//
// @Override
// public void notPerformed(String step) {
// allure.fire(new StepCanceledEvent());
// }
//
// @Override
// public void failed(String step, Throwable cause) {
// takeScreenshot(step);
// allure.fire(new StepFinishedEvent());
// allure.fire(new StepFailureEvent().withThrowable(cause.getCause()));
// allure.fire(new TestCaseFailureEvent().withThrowable(cause.getCause()));
//
// }
//
// @Override
// public void pending(String step) {
// allure.fire(new StepCanceledEvent());
// allure.fire(new TestCasePendingEvent().withMessage("PENDING"));
// }
//
// @Override
// public void afterScenario() {
// allure.fire(new TestCaseFinishedEvent());
// }
//
//
// /**
// * Generate suite uid.
// *
// * @param story the story
// * @return the string
// */
// public String generateSuiteUid(Story story) {
// String uId = UUID.randomUUID().toString();
// synchronized (getSuites()) {
// getSuites().put(story.getPath(), uId);
// }
// return uId;
// }
//
// public Map<String, String> getSuites() {
// return suites;
// }
//
// public void takeScreenshot(String step) {
// if (applicationContext.getBean(AppiumDriver.class) != null) {
// Allure.LIFECYCLE.fire(new MakeAttachmentEvent((applicationContext.getBean(AppiumDriver.class)).getScreenshotAs(OutputType.BYTES), step, "image/png"));
// }
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/IJBConfigurator.java
// public interface IJBConfigurator {
//
// Configuration createConfig();
//
// Configuration createConfig(ViewGenerator viewGenerator, Format... formats);
//
// void configure(EmbedderControls embedderControls, DriversSettings driversSettings);
// }
| import org.jbehave.core.configuration.Configuration;
import org.jbehave.core.configuration.MostUsefulConfiguration;
import org.jbehave.core.embedder.EmbedderControls;
import org.jbehave.core.embedder.StoryControls;
import org.jbehave.core.reporters.Format;
import org.jbehave.core.reporters.StoryReporterBuilder;
import org.jbehave.core.reporters.ViewGenerator;
import org.jbehave.core.steps.ParameterConverters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.reporters.AllureReporter;
import ru.colibri.ui.core.settings.DriversSettings;
import ru.colibri.ui.core.settings.IJBConfigurator; | package ru.colibri.ui.settings.general;
@Component
public class JBConfiguratorImpl implements IJBConfigurator {
@Autowired
private AllureReporter allureReporter;
@Override | // Path: src/main/java/ru/colibri/ui/core/reporters/AllureReporter.java
// @Component
// public class AllureReporter extends NullStoryReporter {
// private final Map<String, String> suites = new HashMap<>();
// @Autowired
// private ApplicationContext applicationContext;
// private Allure allure = Allure.LIFECYCLE;
// private String uid;
//
// @Override
// public void beforeStory(Story story, boolean givenStory) {
// uid = generateSuiteUid(story);
// String path = story.getPath();
// int secondIndex = StringUtils.ordinalIndexOf(path, "/", 2);
// String subPath = path.substring(secondIndex + 1);
// TestSuiteStartedEvent event = new TestSuiteStartedEvent(uid, story.getName());
// event.withLabels(AllureModelUtils.createTestFrameworkLabel("JBehave"));
// event.withTitle(subPath);
// allure.fire(event);
// }
//
// @Override
// public void afterStory(boolean givenStory) {
// allure.fire(new TestSuiteFinishedEvent(uid));
// }
//
// @Override
// public void beforeScenario(Scenario scenario) {
// allure.fire(new TestCaseStartedEvent(uid, scenario.getTitle()));
// allure.fire(new ClearStepStorageEvent());
// }
//
// @Override
// public void beforeStep(String step) {
// allure.fire(new StepStartedEvent(step).withTitle(step));
// }
//
// @Override
// public void successful(String step) {
// allure.fire(new StepFinishedEvent());
// }
//
// @Override
// public void ignorable(String step) {
// allure.fire(new StepCanceledEvent());
// }
//
// @Override
// public void notPerformed(String step) {
// allure.fire(new StepCanceledEvent());
// }
//
// @Override
// public void failed(String step, Throwable cause) {
// takeScreenshot(step);
// allure.fire(new StepFinishedEvent());
// allure.fire(new StepFailureEvent().withThrowable(cause.getCause()));
// allure.fire(new TestCaseFailureEvent().withThrowable(cause.getCause()));
//
// }
//
// @Override
// public void pending(String step) {
// allure.fire(new StepCanceledEvent());
// allure.fire(new TestCasePendingEvent().withMessage("PENDING"));
// }
//
// @Override
// public void afterScenario() {
// allure.fire(new TestCaseFinishedEvent());
// }
//
//
// /**
// * Generate suite uid.
// *
// * @param story the story
// * @return the string
// */
// public String generateSuiteUid(Story story) {
// String uId = UUID.randomUUID().toString();
// synchronized (getSuites()) {
// getSuites().put(story.getPath(), uId);
// }
// return uId;
// }
//
// public Map<String, String> getSuites() {
// return suites;
// }
//
// public void takeScreenshot(String step) {
// if (applicationContext.getBean(AppiumDriver.class) != null) {
// Allure.LIFECYCLE.fire(new MakeAttachmentEvent((applicationContext.getBean(AppiumDriver.class)).getScreenshotAs(OutputType.BYTES), step, "image/png"));
// }
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/IJBConfigurator.java
// public interface IJBConfigurator {
//
// Configuration createConfig();
//
// Configuration createConfig(ViewGenerator viewGenerator, Format... formats);
//
// void configure(EmbedderControls embedderControls, DriversSettings driversSettings);
// }
// Path: src/main/java/ru/colibri/ui/settings/general/JBConfiguratorImpl.java
import org.jbehave.core.configuration.Configuration;
import org.jbehave.core.configuration.MostUsefulConfiguration;
import org.jbehave.core.embedder.EmbedderControls;
import org.jbehave.core.embedder.StoryControls;
import org.jbehave.core.reporters.Format;
import org.jbehave.core.reporters.StoryReporterBuilder;
import org.jbehave.core.reporters.ViewGenerator;
import org.jbehave.core.steps.ParameterConverters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.reporters.AllureReporter;
import ru.colibri.ui.core.settings.DriversSettings;
import ru.colibri.ui.core.settings.IJBConfigurator;
package ru.colibri.ui.settings.general;
@Component
public class JBConfiguratorImpl implements IJBConfigurator {
@Autowired
private AllureReporter allureReporter;
@Override | public void configure(EmbedderControls embedderControls, DriversSettings driversSettings) { |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/ios/IOSFinder.java | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/AbsFinder.java
// public abstract class AbsFinder<T extends AppiumDriver> implements IFinder {
// protected abstract T getDriver();
//
// protected abstract DriversSettings getDriversSettings();
//
// @Override
// public WebElement waitClickable(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.elementToBeClickable(by));
// }
//
// @Override
// public WebElement waitVisible(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.visibilityOfElementLocated(by));
// }
//
// @Override
// public WebElement findWebElement(By by) {
// return getDriver().findElement(by);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
| import io.appium.java_client.ios.IOSDriver;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.AbsFinder;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.List; | package ru.colibri.ui.settings.ios;
@Component
@Qualifier("ios") | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/AbsFinder.java
// public abstract class AbsFinder<T extends AppiumDriver> implements IFinder {
// protected abstract T getDriver();
//
// protected abstract DriversSettings getDriversSettings();
//
// @Override
// public WebElement waitClickable(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.elementToBeClickable(by));
// }
//
// @Override
// public WebElement waitVisible(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.visibilityOfElementLocated(by));
// }
//
// @Override
// public WebElement findWebElement(By by) {
// return getDriver().findElement(by);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
// Path: src/main/java/ru/colibri/ui/settings/ios/IOSFinder.java
import io.appium.java_client.ios.IOSDriver;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.AbsFinder;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.List;
package ru.colibri.ui.settings.ios;
@Component
@Qualifier("ios") | public class IOSFinder extends AbsFinder<IOSDriver> { |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/ios/IOSFinder.java | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/AbsFinder.java
// public abstract class AbsFinder<T extends AppiumDriver> implements IFinder {
// protected abstract T getDriver();
//
// protected abstract DriversSettings getDriversSettings();
//
// @Override
// public WebElement waitClickable(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.elementToBeClickable(by));
// }
//
// @Override
// public WebElement waitVisible(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.visibilityOfElementLocated(by));
// }
//
// @Override
// public WebElement findWebElement(By by) {
// return getDriver().findElement(by);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
| import io.appium.java_client.ios.IOSDriver;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.AbsFinder;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.List; | package ru.colibri.ui.settings.ios;
@Component
@Qualifier("ios")
public class IOSFinder extends AbsFinder<IOSDriver> {
@Autowired
protected IOSByFactory byFactory;
@Autowired(required = false)
@Qualifier("ios") | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/AbsFinder.java
// public abstract class AbsFinder<T extends AppiumDriver> implements IFinder {
// protected abstract T getDriver();
//
// protected abstract DriversSettings getDriversSettings();
//
// @Override
// public WebElement waitClickable(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.elementToBeClickable(by));
// }
//
// @Override
// public WebElement waitVisible(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.visibilityOfElementLocated(by));
// }
//
// @Override
// public WebElement findWebElement(By by) {
// return getDriver().findElement(by);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
// Path: src/main/java/ru/colibri/ui/settings/ios/IOSFinder.java
import io.appium.java_client.ios.IOSDriver;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.AbsFinder;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.List;
package ru.colibri.ui.settings.ios;
@Component
@Qualifier("ios")
public class IOSFinder extends AbsFinder<IOSDriver> {
@Autowired
protected IOSByFactory byFactory;
@Autowired(required = false)
@Qualifier("ios") | private DriversSettings driversSettings; |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/ios/IOSFinder.java | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/AbsFinder.java
// public abstract class AbsFinder<T extends AppiumDriver> implements IFinder {
// protected abstract T getDriver();
//
// protected abstract DriversSettings getDriversSettings();
//
// @Override
// public WebElement waitClickable(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.elementToBeClickable(by));
// }
//
// @Override
// public WebElement waitVisible(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.visibilityOfElementLocated(by));
// }
//
// @Override
// public WebElement findWebElement(By by) {
// return getDriver().findElement(by);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
| import io.appium.java_client.ios.IOSDriver;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.AbsFinder;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.List; | package ru.colibri.ui.settings.ios;
@Component
@Qualifier("ios")
public class IOSFinder extends AbsFinder<IOSDriver> {
@Autowired
protected IOSByFactory byFactory;
@Autowired(required = false)
@Qualifier("ios")
private DriversSettings driversSettings;
@Autowired(required = false)
@Qualifier("ios")
private IOSDriver driver;
@Override | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/AbsFinder.java
// public abstract class AbsFinder<T extends AppiumDriver> implements IFinder {
// protected abstract T getDriver();
//
// protected abstract DriversSettings getDriversSettings();
//
// @Override
// public WebElement waitClickable(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.elementToBeClickable(by));
// }
//
// @Override
// public WebElement waitVisible(By by) {
// Wait<WebDriver> wait = new WebDriverWait(getDriver(), getDriversSettings().getFindingTimeOutInSeconds());
// return wait.until(ExpectedConditions.visibilityOfElementLocated(by));
// }
//
// @Override
// public WebElement findWebElement(By by) {
// return getDriver().findElement(by);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
// Path: src/main/java/ru/colibri/ui/settings/ios/IOSFinder.java
import io.appium.java_client.ios.IOSDriver;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.AbsFinder;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.List;
package ru.colibri.ui.settings.ios;
@Component
@Qualifier("ios")
public class IOSFinder extends AbsFinder<IOSDriver> {
@Autowired
protected IOSByFactory byFactory;
@Autowired(required = false)
@Qualifier("ios")
private DriversSettings driversSettings;
@Autowired(required = false)
@Qualifier("ios")
private IOSDriver driver;
@Override | public WebElement findWebElement(IElement element) { |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/loaders/ISettingsLoader.java | // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/TestSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class TestSettings {
// private List<String> flagsMetaFilters;
// }
| import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.settings.DriversSettings;
import ru.colibri.ui.core.settings.TestSettings; | package ru.colibri.ui.settings.loaders;
public interface ISettingsLoader {
AppSettings loadAppSettings(String userName);
| // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/TestSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class TestSettings {
// private List<String> flagsMetaFilters;
// }
// Path: src/main/java/ru/colibri/ui/settings/loaders/ISettingsLoader.java
import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.settings.DriversSettings;
import ru.colibri.ui.core.settings.TestSettings;
package ru.colibri.ui.settings.loaders;
public interface ISettingsLoader {
AppSettings loadAppSettings(String userName);
| DriversSettings loadDriverSettings(String platformName); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/loaders/ISettingsLoader.java | // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/TestSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class TestSettings {
// private List<String> flagsMetaFilters;
// }
| import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.settings.DriversSettings;
import ru.colibri.ui.core.settings.TestSettings; | package ru.colibri.ui.settings.loaders;
public interface ISettingsLoader {
AppSettings loadAppSettings(String userName);
DriversSettings loadDriverSettings(String platformName);
| // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/TestSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class TestSettings {
// private List<String> flagsMetaFilters;
// }
// Path: src/main/java/ru/colibri/ui/settings/loaders/ISettingsLoader.java
import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.settings.DriversSettings;
import ru.colibri.ui.core.settings.TestSettings;
package ru.colibri.ui.settings.loaders;
public interface ISettingsLoader {
AppSettings loadAppSettings(String userName);
DriversSettings loadDriverSettings(String platformName);
| TestSettings loadTestSettings(String testType); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/core/finder/factories/ByFactory.java | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
| import org.openqa.selenium.By;
import ru.colibri.ui.core.fields.IElement; | package ru.colibri.ui.core.finder.factories;
public abstract class ByFactory {
public By byXpath(String xpath) {
return By.xpath(xpath);
}
public By byId(String id) {
return By.id(id);
}
| // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
// Path: src/main/java/ru/colibri/ui/core/finder/factories/ByFactory.java
import org.openqa.selenium.By;
import ru.colibri.ui.core.fields.IElement;
package ru.colibri.ui.core.finder.factories;
public abstract class ByFactory {
public By byXpath(String xpath) {
return By.xpath(xpath);
}
public By byId(String id) {
return By.id(id);
}
| public abstract By byElement(IElement element); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/ios/base/BaseIOSDriverConfigurator.java | // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
//
// Path: src/main/java/ru/colibri/ui/settings/configurator/AbsDriverConfigurator.java
// @Log
// public abstract class AbsDriverConfigurator implements IDriverConfigurator {
// @Autowired
// private FileUtils fileUtils;
//
// protected DesiredCapabilities createCapabilities(DriversSettings driversSettings) {
// DesiredCapabilities capabilities = new DesiredCapabilities();
// capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, driversSettings.getDeviceName());
// capabilities.setCapability(MobileCapabilityType.UDID, driversSettings.getUDID());
// String absolutePath = fileUtils.relativeToAbsolutePath(driversSettings.getFilePath());
// capabilities.setCapability(MobileCapabilityType.APP, absolutePath);
// capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, driversSettings.getNewCommandTimeoutInSeconds());
// capabilities.setCapability(MobileCapabilityType.CLEAR_SYSTEM_FILES, true);
// return capabilities;
// }
//
// protected URL getRemoteAddress(String remoteUrl) {
// try {
// return new URL(remoteUrl);
// } catch (MalformedURLException e) {
// log.log(Level.SEVERE, e.getMessage(), e);
// throw new RuntimeException(e);
// }
// }
//
// }
| import io.appium.java_client.AppiumDriver;
import io.appium.java_client.ios.IOSDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.settings.DriversSettings;
import ru.colibri.ui.settings.configurator.AbsDriverConfigurator;
import java.util.concurrent.TimeUnit; | package ru.colibri.ui.settings.ios.base;
public abstract class BaseIOSDriverConfigurator extends AbsDriverConfigurator {
@Override | // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
//
// Path: src/main/java/ru/colibri/ui/settings/configurator/AbsDriverConfigurator.java
// @Log
// public abstract class AbsDriverConfigurator implements IDriverConfigurator {
// @Autowired
// private FileUtils fileUtils;
//
// protected DesiredCapabilities createCapabilities(DriversSettings driversSettings) {
// DesiredCapabilities capabilities = new DesiredCapabilities();
// capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, driversSettings.getDeviceName());
// capabilities.setCapability(MobileCapabilityType.UDID, driversSettings.getUDID());
// String absolutePath = fileUtils.relativeToAbsolutePath(driversSettings.getFilePath());
// capabilities.setCapability(MobileCapabilityType.APP, absolutePath);
// capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, driversSettings.getNewCommandTimeoutInSeconds());
// capabilities.setCapability(MobileCapabilityType.CLEAR_SYSTEM_FILES, true);
// return capabilities;
// }
//
// protected URL getRemoteAddress(String remoteUrl) {
// try {
// return new URL(remoteUrl);
// } catch (MalformedURLException e) {
// log.log(Level.SEVERE, e.getMessage(), e);
// throw new RuntimeException(e);
// }
// }
//
// }
// Path: src/main/java/ru/colibri/ui/settings/ios/base/BaseIOSDriverConfigurator.java
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.ios.IOSDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.settings.DriversSettings;
import ru.colibri.ui.settings.configurator.AbsDriverConfigurator;
import java.util.concurrent.TimeUnit;
package ru.colibri.ui.settings.ios.base;
public abstract class BaseIOSDriverConfigurator extends AbsDriverConfigurator {
@Override | public AppiumDriver createDriver(DriversSettings driversSettings, AppSettings appSettings) { |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/ios/base/BaseIOSDriverConfigurator.java | // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
//
// Path: src/main/java/ru/colibri/ui/settings/configurator/AbsDriverConfigurator.java
// @Log
// public abstract class AbsDriverConfigurator implements IDriverConfigurator {
// @Autowired
// private FileUtils fileUtils;
//
// protected DesiredCapabilities createCapabilities(DriversSettings driversSettings) {
// DesiredCapabilities capabilities = new DesiredCapabilities();
// capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, driversSettings.getDeviceName());
// capabilities.setCapability(MobileCapabilityType.UDID, driversSettings.getUDID());
// String absolutePath = fileUtils.relativeToAbsolutePath(driversSettings.getFilePath());
// capabilities.setCapability(MobileCapabilityType.APP, absolutePath);
// capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, driversSettings.getNewCommandTimeoutInSeconds());
// capabilities.setCapability(MobileCapabilityType.CLEAR_SYSTEM_FILES, true);
// return capabilities;
// }
//
// protected URL getRemoteAddress(String remoteUrl) {
// try {
// return new URL(remoteUrl);
// } catch (MalformedURLException e) {
// log.log(Level.SEVERE, e.getMessage(), e);
// throw new RuntimeException(e);
// }
// }
//
// }
| import io.appium.java_client.AppiumDriver;
import io.appium.java_client.ios.IOSDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.settings.DriversSettings;
import ru.colibri.ui.settings.configurator.AbsDriverConfigurator;
import java.util.concurrent.TimeUnit; | package ru.colibri.ui.settings.ios.base;
public abstract class BaseIOSDriverConfigurator extends AbsDriverConfigurator {
@Override | // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
//
// Path: src/main/java/ru/colibri/ui/settings/configurator/AbsDriverConfigurator.java
// @Log
// public abstract class AbsDriverConfigurator implements IDriverConfigurator {
// @Autowired
// private FileUtils fileUtils;
//
// protected DesiredCapabilities createCapabilities(DriversSettings driversSettings) {
// DesiredCapabilities capabilities = new DesiredCapabilities();
// capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, driversSettings.getDeviceName());
// capabilities.setCapability(MobileCapabilityType.UDID, driversSettings.getUDID());
// String absolutePath = fileUtils.relativeToAbsolutePath(driversSettings.getFilePath());
// capabilities.setCapability(MobileCapabilityType.APP, absolutePath);
// capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, driversSettings.getNewCommandTimeoutInSeconds());
// capabilities.setCapability(MobileCapabilityType.CLEAR_SYSTEM_FILES, true);
// return capabilities;
// }
//
// protected URL getRemoteAddress(String remoteUrl) {
// try {
// return new URL(remoteUrl);
// } catch (MalformedURLException e) {
// log.log(Level.SEVERE, e.getMessage(), e);
// throw new RuntimeException(e);
// }
// }
//
// }
// Path: src/main/java/ru/colibri/ui/settings/ios/base/BaseIOSDriverConfigurator.java
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.ios.IOSDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.settings.DriversSettings;
import ru.colibri.ui.settings.configurator.AbsDriverConfigurator;
import java.util.concurrent.TimeUnit;
package ru.colibri.ui.settings.ios.base;
public abstract class BaseIOSDriverConfigurator extends AbsDriverConfigurator {
@Override | public AppiumDriver createDriver(DriversSettings driversSettings, AppSettings appSettings) { |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/steps/android/BaseAndroidSystemButtonsSteps.java | // Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/steps/general/ISystemButtonsClick.java
// public interface ISystemButtonsClick {
// void systemBackClick();
// }
| import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;
import org.jbehave.core.annotations.When;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.steps.general.ISystemButtonsClick;
import ru.yandex.qatools.allure.annotations.Step; | package ru.colibri.ui.steps.android;
@Component
@Qualifier("android") | // Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/steps/general/ISystemButtonsClick.java
// public interface ISystemButtonsClick {
// void systemBackClick();
// }
// Path: src/main/java/ru/colibri/ui/steps/android/BaseAndroidSystemButtonsSteps.java
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;
import org.jbehave.core.annotations.When;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.steps.general.ISystemButtonsClick;
import ru.yandex.qatools.allure.annotations.Step;
package ru.colibri.ui.steps.android;
@Component
@Qualifier("android") | public class BaseAndroidSystemButtonsSteps extends AbsSteps implements ISystemButtonsClick { |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/steps/android/BaseAndroidSystemButtonsSteps.java | // Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/steps/general/ISystemButtonsClick.java
// public interface ISystemButtonsClick {
// void systemBackClick();
// }
| import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;
import org.jbehave.core.annotations.When;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.steps.general.ISystemButtonsClick;
import ru.yandex.qatools.allure.annotations.Step; | package ru.colibri.ui.steps.android;
@Component
@Qualifier("android") | // Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/steps/general/ISystemButtonsClick.java
// public interface ISystemButtonsClick {
// void systemBackClick();
// }
// Path: src/main/java/ru/colibri/ui/steps/android/BaseAndroidSystemButtonsSteps.java
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;
import org.jbehave.core.annotations.When;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.steps.general.ISystemButtonsClick;
import ru.yandex.qatools.allure.annotations.Step;
package ru.colibri.ui.steps.android;
@Component
@Qualifier("android") | public class BaseAndroidSystemButtonsSteps extends AbsSteps implements ISystemButtonsClick { |
alfa-laboratory/colibri-ui | src/test/java/ru/colibri/ui/settings/android/AndroidByFactoryTests.java | // Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// @Component
// public class ElementBuilders {
//
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
| import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.By;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import ru.colibri.ui.core.builders.ElementBuilders;
import ru.colibri.ui.core.fields.IElement;
import static java.lang.String.format;
import static org.junit.Assert.assertEquals; | package ru.colibri.ui.settings.android;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AndroidTestConfig.class})
public class AndroidByFactoryTests {
@Autowired
private AndroidByFactory byFactory;
@Test
public void shouldFindElementById() { | // Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// @Component
// public class ElementBuilders {
//
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
// Path: src/test/java/ru/colibri/ui/settings/android/AndroidByFactoryTests.java
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.By;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import ru.colibri.ui.core.builders.ElementBuilders;
import ru.colibri.ui.core.fields.IElement;
import static java.lang.String.format;
import static org.junit.Assert.assertEquals;
package ru.colibri.ui.settings.android;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AndroidTestConfig.class})
public class AndroidByFactoryTests {
@Autowired
private AndroidByFactory byFactory;
@Test
public void shouldFindElementById() { | IElement element = ElementBuilders.element() |
alfa-laboratory/colibri-ui | src/test/java/ru/colibri/ui/settings/android/AndroidByFactoryTests.java | // Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// @Component
// public class ElementBuilders {
//
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
| import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.By;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import ru.colibri.ui.core.builders.ElementBuilders;
import ru.colibri.ui.core.fields.IElement;
import static java.lang.String.format;
import static org.junit.Assert.assertEquals; | package ru.colibri.ui.settings.android;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AndroidTestConfig.class})
public class AndroidByFactoryTests {
@Autowired
private AndroidByFactory byFactory;
@Test
public void shouldFindElementById() { | // Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// @Component
// public class ElementBuilders {
//
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
// Path: src/test/java/ru/colibri/ui/settings/android/AndroidByFactoryTests.java
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.By;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import ru.colibri.ui.core.builders.ElementBuilders;
import ru.colibri.ui.core.fields.IElement;
import static java.lang.String.format;
import static org.junit.Assert.assertEquals;
package ru.colibri.ui.settings.android;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AndroidTestConfig.class})
public class AndroidByFactoryTests {
@Autowired
private AndroidByFactory byFactory;
@Test
public void shouldFindElementById() { | IElement element = ElementBuilders.element() |
alfa-laboratory/colibri-ui | src/test/java/ru/colibri/ui/settings/ios/TestIOSByFactory.java | // Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// @Component
// public class ElementBuilders {
//
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
| import io.appium.java_client.MobileBy;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import ru.colibri.ui.core.builders.ElementBuilders;
import ru.colibri.ui.core.fields.IElement;
import static java.lang.String.format; | package ru.colibri.ui.settings.ios;
public class TestIOSByFactory {
private IOSByFactory byFactory = new IOSByFactory();
private String XPATH_TEMPLATE = "//*[contains(@name,'%1$s') or contains(@value,'%1$s') or contains(@label,'%1$s')]";
private String IOSNSPREDICATE_TEMPLATE = "name contains '%1$s' or value contains '%1$s' or label contains '%1$s'";
@Test
public void testByID() { | // Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// @Component
// public class ElementBuilders {
//
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
// Path: src/test/java/ru/colibri/ui/settings/ios/TestIOSByFactory.java
import io.appium.java_client.MobileBy;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import ru.colibri.ui.core.builders.ElementBuilders;
import ru.colibri.ui.core.fields.IElement;
import static java.lang.String.format;
package ru.colibri.ui.settings.ios;
public class TestIOSByFactory {
private IOSByFactory byFactory = new IOSByFactory();
private String XPATH_TEMPLATE = "//*[contains(@name,'%1$s') or contains(@value,'%1$s') or contains(@label,'%1$s')]";
private String IOSNSPREDICATE_TEMPLATE = "name contains '%1$s' or value contains '%1$s' or label contains '%1$s'";
@Test
public void testByID() { | IElement element = ElementBuilders.element() |
alfa-laboratory/colibri-ui | src/test/java/ru/colibri/ui/settings/ios/TestIOSByFactory.java | // Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// @Component
// public class ElementBuilders {
//
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
| import io.appium.java_client.MobileBy;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import ru.colibri.ui.core.builders.ElementBuilders;
import ru.colibri.ui.core.fields.IElement;
import static java.lang.String.format; | package ru.colibri.ui.settings.ios;
public class TestIOSByFactory {
private IOSByFactory byFactory = new IOSByFactory();
private String XPATH_TEMPLATE = "//*[contains(@name,'%1$s') or contains(@value,'%1$s') or contains(@label,'%1$s')]";
private String IOSNSPREDICATE_TEMPLATE = "name contains '%1$s' or value contains '%1$s' or label contains '%1$s'";
@Test
public void testByID() { | // Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilders.java
// @Component
// public class ElementBuilders {
//
// public static ElementBuilder element() {
// return new ElementBuilder();
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
// Path: src/test/java/ru/colibri/ui/settings/ios/TestIOSByFactory.java
import io.appium.java_client.MobileBy;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import ru.colibri.ui.core.builders.ElementBuilders;
import ru.colibri.ui.core.fields.IElement;
import static java.lang.String.format;
package ru.colibri.ui.settings.ios;
public class TestIOSByFactory {
private IOSByFactory byFactory = new IOSByFactory();
private String XPATH_TEMPLATE = "//*[contains(@name,'%1$s') or contains(@value,'%1$s') or contains(@label,'%1$s')]";
private String IOSNSPREDICATE_TEMPLATE = "name contains '%1$s' or value contains '%1$s' or label contains '%1$s'";
@Test
public void testByID() { | IElement element = ElementBuilders.element() |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/steps/android/AndroidPageSteps.java | // Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
| import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.openqa.selenium.By;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import static java.lang.String.format; | package ru.colibri.ui.steps.android;
@Component
public class AndroidPageSteps extends AbsSteps {
private static final String LOWER_CASE_ABC = "abcdefghijklmnopqrstuvwxyzабвгдеёжзийклмнопрстуфхцчшщъыьэюя";
private static final String UPPER_CASE_ABC = LOWER_CASE_ABC.toUpperCase();
@Autowired | // Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
// Path: src/main/java/ru/colibri/ui/steps/android/AndroidPageSteps.java
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.openqa.selenium.By;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import static java.lang.String.format;
package ru.colibri.ui.steps.android;
@Component
public class AndroidPageSteps extends AbsSteps {
private static final String LOWER_CASE_ABC = "abcdefghijklmnopqrstuvwxyzабвгдеёжзийклмнопрстуфхцчшщъыьэюя";
private static final String UPPER_CASE_ABC = LOWER_CASE_ABC.toUpperCase();
@Autowired | private PropertyUtils propertyUtils; |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/core/steps/AbsSteps.java | // Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/IFinder.java
// public interface IFinder {
// WebElement findWebElement(IElement element);
//
// List<WebElement> findWebElements(IElement element);
//
// WebElement findNestedWebElement(IElement parent, IElement nested);
//
// WebElement waitClickable(By by);
//
// WebElement waitVisible(By by);
//
// WebElement findWebElement(By by);
//
// void scrollTo(IElement targetListName, IElement toElementName);
//
// List<WebElement> findNestedWebElements(IElement parent, IElement nested);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPageProvider.java
// public interface IPageProvider {
// void addPageObject(IPage pageObject);
//
// void addPagesObject(List<IPage> pages);
//
// IPage getPageByName(String pageName);
//
// IPage getPageById(String pageId);
//
// IPage getCurrentPage();
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
| import io.appium.java_client.AppiumDriver;
import lombok.extern.java.Log;
import org.jbehave.core.steps.Steps;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.IFinder;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.IPageProvider;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.concurrent.TimeUnit; | package ru.colibri.ui.core.steps;
@Log
public abstract class AbsSteps extends Steps implements InitializingBean {
private static final int TIMEOUT = 7;
private int currentTimeout;
@Autowired | // Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/IFinder.java
// public interface IFinder {
// WebElement findWebElement(IElement element);
//
// List<WebElement> findWebElements(IElement element);
//
// WebElement findNestedWebElement(IElement parent, IElement nested);
//
// WebElement waitClickable(By by);
//
// WebElement waitVisible(By by);
//
// WebElement findWebElement(By by);
//
// void scrollTo(IElement targetListName, IElement toElementName);
//
// List<WebElement> findNestedWebElements(IElement parent, IElement nested);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPageProvider.java
// public interface IPageProvider {
// void addPageObject(IPage pageObject);
//
// void addPagesObject(List<IPage> pages);
//
// IPage getPageByName(String pageName);
//
// IPage getPageById(String pageId);
//
// IPage getCurrentPage();
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
import io.appium.java_client.AppiumDriver;
import lombok.extern.java.Log;
import org.jbehave.core.steps.Steps;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.IFinder;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.IPageProvider;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.concurrent.TimeUnit;
package ru.colibri.ui.core.steps;
@Log
public abstract class AbsSteps extends Steps implements InitializingBean {
private static final int TIMEOUT = 7;
private int currentTimeout;
@Autowired | protected TestContext testContext; |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/core/steps/AbsSteps.java | // Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/IFinder.java
// public interface IFinder {
// WebElement findWebElement(IElement element);
//
// List<WebElement> findWebElements(IElement element);
//
// WebElement findNestedWebElement(IElement parent, IElement nested);
//
// WebElement waitClickable(By by);
//
// WebElement waitVisible(By by);
//
// WebElement findWebElement(By by);
//
// void scrollTo(IElement targetListName, IElement toElementName);
//
// List<WebElement> findNestedWebElements(IElement parent, IElement nested);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPageProvider.java
// public interface IPageProvider {
// void addPageObject(IPage pageObject);
//
// void addPagesObject(List<IPage> pages);
//
// IPage getPageByName(String pageName);
//
// IPage getPageById(String pageId);
//
// IPage getCurrentPage();
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
| import io.appium.java_client.AppiumDriver;
import lombok.extern.java.Log;
import org.jbehave.core.steps.Steps;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.IFinder;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.IPageProvider;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.concurrent.TimeUnit; | package ru.colibri.ui.core.steps;
@Log
public abstract class AbsSteps extends Steps implements InitializingBean {
private static final int TIMEOUT = 7;
private int currentTimeout;
@Autowired
protected TestContext testContext;
@Autowired
protected AppiumDriver driver;
@Autowired(required = false) | // Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/IFinder.java
// public interface IFinder {
// WebElement findWebElement(IElement element);
//
// List<WebElement> findWebElements(IElement element);
//
// WebElement findNestedWebElement(IElement parent, IElement nested);
//
// WebElement waitClickable(By by);
//
// WebElement waitVisible(By by);
//
// WebElement findWebElement(By by);
//
// void scrollTo(IElement targetListName, IElement toElementName);
//
// List<WebElement> findNestedWebElements(IElement parent, IElement nested);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPageProvider.java
// public interface IPageProvider {
// void addPageObject(IPage pageObject);
//
// void addPagesObject(List<IPage> pages);
//
// IPage getPageByName(String pageName);
//
// IPage getPageById(String pageId);
//
// IPage getCurrentPage();
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
import io.appium.java_client.AppiumDriver;
import lombok.extern.java.Log;
import org.jbehave.core.steps.Steps;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.IFinder;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.IPageProvider;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.concurrent.TimeUnit;
package ru.colibri.ui.core.steps;
@Log
public abstract class AbsSteps extends Steps implements InitializingBean {
private static final int TIMEOUT = 7;
private int currentTimeout;
@Autowired
protected TestContext testContext;
@Autowired
protected AppiumDriver driver;
@Autowired(required = false) | protected IFinder finder; |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/core/steps/AbsSteps.java | // Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/IFinder.java
// public interface IFinder {
// WebElement findWebElement(IElement element);
//
// List<WebElement> findWebElements(IElement element);
//
// WebElement findNestedWebElement(IElement parent, IElement nested);
//
// WebElement waitClickable(By by);
//
// WebElement waitVisible(By by);
//
// WebElement findWebElement(By by);
//
// void scrollTo(IElement targetListName, IElement toElementName);
//
// List<WebElement> findNestedWebElements(IElement parent, IElement nested);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPageProvider.java
// public interface IPageProvider {
// void addPageObject(IPage pageObject);
//
// void addPagesObject(List<IPage> pages);
//
// IPage getPageByName(String pageName);
//
// IPage getPageById(String pageId);
//
// IPage getCurrentPage();
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
| import io.appium.java_client.AppiumDriver;
import lombok.extern.java.Log;
import org.jbehave.core.steps.Steps;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.IFinder;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.IPageProvider;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.concurrent.TimeUnit; | package ru.colibri.ui.core.steps;
@Log
public abstract class AbsSteps extends Steps implements InitializingBean {
private static final int TIMEOUT = 7;
private int currentTimeout;
@Autowired
protected TestContext testContext;
@Autowired
protected AppiumDriver driver;
@Autowired(required = false)
protected IFinder finder;
@Autowired | // Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/IFinder.java
// public interface IFinder {
// WebElement findWebElement(IElement element);
//
// List<WebElement> findWebElements(IElement element);
//
// WebElement findNestedWebElement(IElement parent, IElement nested);
//
// WebElement waitClickable(By by);
//
// WebElement waitVisible(By by);
//
// WebElement findWebElement(By by);
//
// void scrollTo(IElement targetListName, IElement toElementName);
//
// List<WebElement> findNestedWebElements(IElement parent, IElement nested);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPageProvider.java
// public interface IPageProvider {
// void addPageObject(IPage pageObject);
//
// void addPagesObject(List<IPage> pages);
//
// IPage getPageByName(String pageName);
//
// IPage getPageById(String pageId);
//
// IPage getCurrentPage();
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
import io.appium.java_client.AppiumDriver;
import lombok.extern.java.Log;
import org.jbehave.core.steps.Steps;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.IFinder;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.IPageProvider;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.concurrent.TimeUnit;
package ru.colibri.ui.core.steps;
@Log
public abstract class AbsSteps extends Steps implements InitializingBean {
private static final int TIMEOUT = 7;
private int currentTimeout;
@Autowired
protected TestContext testContext;
@Autowired
protected AppiumDriver driver;
@Autowired(required = false)
protected IFinder finder;
@Autowired | protected IPageProvider pageProvider; |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/core/steps/AbsSteps.java | // Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/IFinder.java
// public interface IFinder {
// WebElement findWebElement(IElement element);
//
// List<WebElement> findWebElements(IElement element);
//
// WebElement findNestedWebElement(IElement parent, IElement nested);
//
// WebElement waitClickable(By by);
//
// WebElement waitVisible(By by);
//
// WebElement findWebElement(By by);
//
// void scrollTo(IElement targetListName, IElement toElementName);
//
// List<WebElement> findNestedWebElements(IElement parent, IElement nested);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPageProvider.java
// public interface IPageProvider {
// void addPageObject(IPage pageObject);
//
// void addPagesObject(List<IPage> pages);
//
// IPage getPageByName(String pageName);
//
// IPage getPageById(String pageId);
//
// IPage getCurrentPage();
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
| import io.appium.java_client.AppiumDriver;
import lombok.extern.java.Log;
import org.jbehave.core.steps.Steps;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.IFinder;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.IPageProvider;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.concurrent.TimeUnit; | package ru.colibri.ui.core.steps;
@Log
public abstract class AbsSteps extends Steps implements InitializingBean {
private static final int TIMEOUT = 7;
private int currentTimeout;
@Autowired
protected TestContext testContext;
@Autowired
protected AppiumDriver driver;
@Autowired(required = false)
protected IFinder finder;
@Autowired
protected IPageProvider pageProvider;
@Autowired | // Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/IFinder.java
// public interface IFinder {
// WebElement findWebElement(IElement element);
//
// List<WebElement> findWebElements(IElement element);
//
// WebElement findNestedWebElement(IElement parent, IElement nested);
//
// WebElement waitClickable(By by);
//
// WebElement waitVisible(By by);
//
// WebElement findWebElement(By by);
//
// void scrollTo(IElement targetListName, IElement toElementName);
//
// List<WebElement> findNestedWebElements(IElement parent, IElement nested);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPageProvider.java
// public interface IPageProvider {
// void addPageObject(IPage pageObject);
//
// void addPagesObject(List<IPage> pages);
//
// IPage getPageByName(String pageName);
//
// IPage getPageById(String pageId);
//
// IPage getCurrentPage();
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
import io.appium.java_client.AppiumDriver;
import lombok.extern.java.Log;
import org.jbehave.core.steps.Steps;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.IFinder;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.IPageProvider;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.concurrent.TimeUnit;
package ru.colibri.ui.core.steps;
@Log
public abstract class AbsSteps extends Steps implements InitializingBean {
private static final int TIMEOUT = 7;
private int currentTimeout;
@Autowired
protected TestContext testContext;
@Autowired
protected AppiumDriver driver;
@Autowired(required = false)
protected IFinder finder;
@Autowired
protected IPageProvider pageProvider;
@Autowired | protected DriversSettings driverSettings; |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/core/steps/AbsSteps.java | // Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/IFinder.java
// public interface IFinder {
// WebElement findWebElement(IElement element);
//
// List<WebElement> findWebElements(IElement element);
//
// WebElement findNestedWebElement(IElement parent, IElement nested);
//
// WebElement waitClickable(By by);
//
// WebElement waitVisible(By by);
//
// WebElement findWebElement(By by);
//
// void scrollTo(IElement targetListName, IElement toElementName);
//
// List<WebElement> findNestedWebElements(IElement parent, IElement nested);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPageProvider.java
// public interface IPageProvider {
// void addPageObject(IPage pageObject);
//
// void addPagesObject(List<IPage> pages);
//
// IPage getPageByName(String pageName);
//
// IPage getPageById(String pageId);
//
// IPage getCurrentPage();
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
| import io.appium.java_client.AppiumDriver;
import lombok.extern.java.Log;
import org.jbehave.core.steps.Steps;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.IFinder;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.IPageProvider;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.concurrent.TimeUnit; | package ru.colibri.ui.core.steps;
@Log
public abstract class AbsSteps extends Steps implements InitializingBean {
private static final int TIMEOUT = 7;
private int currentTimeout;
@Autowired
protected TestContext testContext;
@Autowired
protected AppiumDriver driver;
@Autowired(required = false)
protected IFinder finder;
@Autowired
protected IPageProvider pageProvider;
@Autowired
protected DriversSettings driverSettings;
| // Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/IFinder.java
// public interface IFinder {
// WebElement findWebElement(IElement element);
//
// List<WebElement> findWebElements(IElement element);
//
// WebElement findNestedWebElement(IElement parent, IElement nested);
//
// WebElement waitClickable(By by);
//
// WebElement waitVisible(By by);
//
// WebElement findWebElement(By by);
//
// void scrollTo(IElement targetListName, IElement toElementName);
//
// List<WebElement> findNestedWebElements(IElement parent, IElement nested);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPageProvider.java
// public interface IPageProvider {
// void addPageObject(IPage pageObject);
//
// void addPagesObject(List<IPage> pages);
//
// IPage getPageByName(String pageName);
//
// IPage getPageById(String pageId);
//
// IPage getCurrentPage();
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
import io.appium.java_client.AppiumDriver;
import lombok.extern.java.Log;
import org.jbehave.core.steps.Steps;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.IFinder;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.IPageProvider;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.concurrent.TimeUnit;
package ru.colibri.ui.core.steps;
@Log
public abstract class AbsSteps extends Steps implements InitializingBean {
private static final int TIMEOUT = 7;
private int currentTimeout;
@Autowired
protected TestContext testContext;
@Autowired
protected AppiumDriver driver;
@Autowired(required = false)
protected IFinder finder;
@Autowired
protected IPageProvider pageProvider;
@Autowired
protected DriversSettings driverSettings;
| protected IPage getCurrentPage() { |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/core/steps/AbsSteps.java | // Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/IFinder.java
// public interface IFinder {
// WebElement findWebElement(IElement element);
//
// List<WebElement> findWebElements(IElement element);
//
// WebElement findNestedWebElement(IElement parent, IElement nested);
//
// WebElement waitClickable(By by);
//
// WebElement waitVisible(By by);
//
// WebElement findWebElement(By by);
//
// void scrollTo(IElement targetListName, IElement toElementName);
//
// List<WebElement> findNestedWebElements(IElement parent, IElement nested);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPageProvider.java
// public interface IPageProvider {
// void addPageObject(IPage pageObject);
//
// void addPagesObject(List<IPage> pages);
//
// IPage getPageByName(String pageName);
//
// IPage getPageById(String pageId);
//
// IPage getCurrentPage();
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
| import io.appium.java_client.AppiumDriver;
import lombok.extern.java.Log;
import org.jbehave.core.steps.Steps;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.IFinder;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.IPageProvider;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.concurrent.TimeUnit; | package ru.colibri.ui.core.steps;
@Log
public abstract class AbsSteps extends Steps implements InitializingBean {
private static final int TIMEOUT = 7;
private int currentTimeout;
@Autowired
protected TestContext testContext;
@Autowired
protected AppiumDriver driver;
@Autowired(required = false)
protected IFinder finder;
@Autowired
protected IPageProvider pageProvider;
@Autowired
protected DriversSettings driverSettings;
protected IPage getCurrentPage() {
return pageProvider.getCurrentPage();
}
@Override
public void afterPropertiesSet() throws Exception {
log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
}
protected DriversSettings getDriversSettings() {
return driverSettings;
}
protected WebElement getWebElementByName(String elementName) { | // Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/finder/IFinder.java
// public interface IFinder {
// WebElement findWebElement(IElement element);
//
// List<WebElement> findWebElements(IElement element);
//
// WebElement findNestedWebElement(IElement parent, IElement nested);
//
// WebElement waitClickable(By by);
//
// WebElement waitVisible(By by);
//
// WebElement findWebElement(By by);
//
// void scrollTo(IElement targetListName, IElement toElementName);
//
// List<WebElement> findNestedWebElements(IElement parent, IElement nested);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPageProvider.java
// public interface IPageProvider {
// void addPageObject(IPage pageObject);
//
// void addPagesObject(List<IPage> pages);
//
// IPage getPageByName(String pageName);
//
// IPage getPageById(String pageId);
//
// IPage getCurrentPage();
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
import io.appium.java_client.AppiumDriver;
import lombok.extern.java.Log;
import org.jbehave.core.steps.Steps;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.finder.IFinder;
import ru.colibri.ui.core.pages.IPage;
import ru.colibri.ui.core.pages.IPageProvider;
import ru.colibri.ui.core.settings.DriversSettings;
import java.util.concurrent.TimeUnit;
package ru.colibri.ui.core.steps;
@Log
public abstract class AbsSteps extends Steps implements InitializingBean {
private static final int TIMEOUT = 7;
private int currentTimeout;
@Autowired
protected TestContext testContext;
@Autowired
protected AppiumDriver driver;
@Autowired(required = false)
protected IFinder finder;
@Autowired
protected IPageProvider pageProvider;
@Autowired
protected DriversSettings driverSettings;
protected IPage getCurrentPage() {
return pageProvider.getCurrentPage();
}
@Override
public void afterPropertiesSet() throws Exception {
log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
}
protected DriversSettings getDriversSettings() {
return driverSettings;
}
protected WebElement getWebElementByName(String elementName) { | IElement element = getCurrentPage().getElementByName(elementName); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/ios/IOSPageProvider.java | // Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/AbsPageProvider.java
// @ToString
// public abstract class AbsPageProvider implements IPageProvider {
//
// @Autowired
// protected AppiumDriver driver;
//
// protected HashMap<String, IPage> pagesByName;
// protected HashMap<String, IPage> pagesByID;
//
// public AbsPageProvider() {
// pagesByName = new HashMap<>();
// pagesByID = new HashMap<>();
// }
//
// public void addPageObject(IPage pageObject) throws PageNameAlreadyUsedException {
// String systemId = pageObject.getSystemId().toLowerCase();
// if (!systemId.isEmpty() && pagesByID.containsKey(systemId)) {
// throw new PageNameAlreadyUsedException(systemId);
// }
// String name = pageObject.getName().toLowerCase();
// if (!name.isEmpty() && pagesByName.containsKey(name)) {
// throw new PageNameAlreadyUsedException(name);
// }
// pagesByName.put(name, pageObject);
// pagesByID.put(systemId, pageObject);
// }
//
// public IPage getPageByName(String pageName) {
// return getIPage(pagesByName, pageName);
// }
//
// public IPage getPageById(String pageId) {
// return getIPage(pagesByID, pageId);
// }
//
// private IPage getIPage(HashMap<String, IPage> pages, String pageName) {
// IPage result = pages.get(pageName.toLowerCase());
// if (result == null) {
// throw new NoPageFoundException(pageName);
// }
// return result;
// }
//
// @Override
// public void addPagesObject(List<IPage> pages) {
// pages.forEach(this::addPageObject);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
| import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.pages.AbsPageProvider;
import ru.colibri.ui.core.pages.IPage; | package ru.colibri.ui.settings.ios;
@Log
@Component
@Qualifier("ios") | // Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/AbsPageProvider.java
// @ToString
// public abstract class AbsPageProvider implements IPageProvider {
//
// @Autowired
// protected AppiumDriver driver;
//
// protected HashMap<String, IPage> pagesByName;
// protected HashMap<String, IPage> pagesByID;
//
// public AbsPageProvider() {
// pagesByName = new HashMap<>();
// pagesByID = new HashMap<>();
// }
//
// public void addPageObject(IPage pageObject) throws PageNameAlreadyUsedException {
// String systemId = pageObject.getSystemId().toLowerCase();
// if (!systemId.isEmpty() && pagesByID.containsKey(systemId)) {
// throw new PageNameAlreadyUsedException(systemId);
// }
// String name = pageObject.getName().toLowerCase();
// if (!name.isEmpty() && pagesByName.containsKey(name)) {
// throw new PageNameAlreadyUsedException(name);
// }
// pagesByName.put(name, pageObject);
// pagesByID.put(systemId, pageObject);
// }
//
// public IPage getPageByName(String pageName) {
// return getIPage(pagesByName, pageName);
// }
//
// public IPage getPageById(String pageId) {
// return getIPage(pagesByID, pageId);
// }
//
// private IPage getIPage(HashMap<String, IPage> pages, String pageName) {
// IPage result = pages.get(pageName.toLowerCase());
// if (result == null) {
// throw new NoPageFoundException(pageName);
// }
// return result;
// }
//
// @Override
// public void addPagesObject(List<IPage> pages) {
// pages.forEach(this::addPageObject);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
// Path: src/main/java/ru/colibri/ui/settings/ios/IOSPageProvider.java
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.pages.AbsPageProvider;
import ru.colibri.ui.core.pages.IPage;
package ru.colibri.ui.settings.ios;
@Log
@Component
@Qualifier("ios") | public class IOSPageProvider extends AbsPageProvider { |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/ios/IOSPageProvider.java | // Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/AbsPageProvider.java
// @ToString
// public abstract class AbsPageProvider implements IPageProvider {
//
// @Autowired
// protected AppiumDriver driver;
//
// protected HashMap<String, IPage> pagesByName;
// protected HashMap<String, IPage> pagesByID;
//
// public AbsPageProvider() {
// pagesByName = new HashMap<>();
// pagesByID = new HashMap<>();
// }
//
// public void addPageObject(IPage pageObject) throws PageNameAlreadyUsedException {
// String systemId = pageObject.getSystemId().toLowerCase();
// if (!systemId.isEmpty() && pagesByID.containsKey(systemId)) {
// throw new PageNameAlreadyUsedException(systemId);
// }
// String name = pageObject.getName().toLowerCase();
// if (!name.isEmpty() && pagesByName.containsKey(name)) {
// throw new PageNameAlreadyUsedException(name);
// }
// pagesByName.put(name, pageObject);
// pagesByID.put(systemId, pageObject);
// }
//
// public IPage getPageByName(String pageName) {
// return getIPage(pagesByName, pageName);
// }
//
// public IPage getPageById(String pageId) {
// return getIPage(pagesByID, pageId);
// }
//
// private IPage getIPage(HashMap<String, IPage> pages, String pageName) {
// IPage result = pages.get(pageName.toLowerCase());
// if (result == null) {
// throw new NoPageFoundException(pageName);
// }
// return result;
// }
//
// @Override
// public void addPagesObject(List<IPage> pages) {
// pages.forEach(this::addPageObject);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
| import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.pages.AbsPageProvider;
import ru.colibri.ui.core.pages.IPage; | package ru.colibri.ui.settings.ios;
@Log
@Component
@Qualifier("ios")
public class IOSPageProvider extends AbsPageProvider {
@Autowired | // Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/AbsPageProvider.java
// @ToString
// public abstract class AbsPageProvider implements IPageProvider {
//
// @Autowired
// protected AppiumDriver driver;
//
// protected HashMap<String, IPage> pagesByName;
// protected HashMap<String, IPage> pagesByID;
//
// public AbsPageProvider() {
// pagesByName = new HashMap<>();
// pagesByID = new HashMap<>();
// }
//
// public void addPageObject(IPage pageObject) throws PageNameAlreadyUsedException {
// String systemId = pageObject.getSystemId().toLowerCase();
// if (!systemId.isEmpty() && pagesByID.containsKey(systemId)) {
// throw new PageNameAlreadyUsedException(systemId);
// }
// String name = pageObject.getName().toLowerCase();
// if (!name.isEmpty() && pagesByName.containsKey(name)) {
// throw new PageNameAlreadyUsedException(name);
// }
// pagesByName.put(name, pageObject);
// pagesByID.put(systemId, pageObject);
// }
//
// public IPage getPageByName(String pageName) {
// return getIPage(pagesByName, pageName);
// }
//
// public IPage getPageById(String pageId) {
// return getIPage(pagesByID, pageId);
// }
//
// private IPage getIPage(HashMap<String, IPage> pages, String pageName) {
// IPage result = pages.get(pageName.toLowerCase());
// if (result == null) {
// throw new NoPageFoundException(pageName);
// }
// return result;
// }
//
// @Override
// public void addPagesObject(List<IPage> pages) {
// pages.forEach(this::addPageObject);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
// Path: src/main/java/ru/colibri/ui/settings/ios/IOSPageProvider.java
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.pages.AbsPageProvider;
import ru.colibri.ui.core.pages.IPage;
package ru.colibri.ui.settings.ios;
@Log
@Component
@Qualifier("ios")
public class IOSPageProvider extends AbsPageProvider {
@Autowired | private TestContext testContext; |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/ios/IOSPageProvider.java | // Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/AbsPageProvider.java
// @ToString
// public abstract class AbsPageProvider implements IPageProvider {
//
// @Autowired
// protected AppiumDriver driver;
//
// protected HashMap<String, IPage> pagesByName;
// protected HashMap<String, IPage> pagesByID;
//
// public AbsPageProvider() {
// pagesByName = new HashMap<>();
// pagesByID = new HashMap<>();
// }
//
// public void addPageObject(IPage pageObject) throws PageNameAlreadyUsedException {
// String systemId = pageObject.getSystemId().toLowerCase();
// if (!systemId.isEmpty() && pagesByID.containsKey(systemId)) {
// throw new PageNameAlreadyUsedException(systemId);
// }
// String name = pageObject.getName().toLowerCase();
// if (!name.isEmpty() && pagesByName.containsKey(name)) {
// throw new PageNameAlreadyUsedException(name);
// }
// pagesByName.put(name, pageObject);
// pagesByID.put(systemId, pageObject);
// }
//
// public IPage getPageByName(String pageName) {
// return getIPage(pagesByName, pageName);
// }
//
// public IPage getPageById(String pageId) {
// return getIPage(pagesByID, pageId);
// }
//
// private IPage getIPage(HashMap<String, IPage> pages, String pageName) {
// IPage result = pages.get(pageName.toLowerCase());
// if (result == null) {
// throw new NoPageFoundException(pageName);
// }
// return result;
// }
//
// @Override
// public void addPagesObject(List<IPage> pages) {
// pages.forEach(this::addPageObject);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
| import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.pages.AbsPageProvider;
import ru.colibri.ui.core.pages.IPage; | package ru.colibri.ui.settings.ios;
@Log
@Component
@Qualifier("ios")
public class IOSPageProvider extends AbsPageProvider {
@Autowired
private TestContext testContext;
@Override | // Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java
// @Component
// @Getter
// @Setter
// public class TestContext {
// private String currentPageName;
// private Map<String, String> context = new HashMap<>();
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/AbsPageProvider.java
// @ToString
// public abstract class AbsPageProvider implements IPageProvider {
//
// @Autowired
// protected AppiumDriver driver;
//
// protected HashMap<String, IPage> pagesByName;
// protected HashMap<String, IPage> pagesByID;
//
// public AbsPageProvider() {
// pagesByName = new HashMap<>();
// pagesByID = new HashMap<>();
// }
//
// public void addPageObject(IPage pageObject) throws PageNameAlreadyUsedException {
// String systemId = pageObject.getSystemId().toLowerCase();
// if (!systemId.isEmpty() && pagesByID.containsKey(systemId)) {
// throw new PageNameAlreadyUsedException(systemId);
// }
// String name = pageObject.getName().toLowerCase();
// if (!name.isEmpty() && pagesByName.containsKey(name)) {
// throw new PageNameAlreadyUsedException(name);
// }
// pagesByName.put(name, pageObject);
// pagesByID.put(systemId, pageObject);
// }
//
// public IPage getPageByName(String pageName) {
// return getIPage(pagesByName, pageName);
// }
//
// public IPage getPageById(String pageId) {
// return getIPage(pagesByID, pageId);
// }
//
// private IPage getIPage(HashMap<String, IPage> pages, String pageName) {
// IPage result = pages.get(pageName.toLowerCase());
// if (result == null) {
// throw new NoPageFoundException(pageName);
// }
// return result;
// }
//
// @Override
// public void addPagesObject(List<IPage> pages) {
// pages.forEach(this::addPageObject);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/pages/IPage.java
// public interface IPage {
// String getName();
//
// String getSystemId();
//
// List<IElement> getSpecificElements();
//
// IElement getElementByName(String name);
//
// void addElement(IElement element);
// }
// Path: src/main/java/ru/colibri/ui/settings/ios/IOSPageProvider.java
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.contexts.TestContext;
import ru.colibri.ui.core.pages.AbsPageProvider;
import ru.colibri.ui.core.pages.IPage;
package ru.colibri.ui.settings.ios;
@Log
@Component
@Qualifier("ios")
public class IOSPageProvider extends AbsPageProvider {
@Autowired
private TestContext testContext;
@Override | public IPage getCurrentPage() { |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/steps/general/ListItemSteps.java | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
| import org.jbehave.core.annotations.When;
import org.openqa.selenium.WebElement;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List; | package ru.colibri.ui.steps.general;
@Component
public class ListItemSteps extends AbsSteps {
@Step
@When("выполнено нажатие на элемент \"$fieldName\" с индексом \"$index\"")
public void listItemClick(String fieldName, int index) { | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
// Path: src/main/java/ru/colibri/ui/steps/general/ListItemSteps.java
import org.jbehave.core.annotations.When;
import org.openqa.selenium.WebElement;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List;
package ru.colibri.ui.steps.general;
@Component
public class ListItemSteps extends AbsSteps {
@Step
@When("выполнено нажатие на элемент \"$fieldName\" с индексом \"$index\"")
public void listItemClick(String fieldName, int index) { | IElement element = getCurrentPage().getElementByName(fieldName); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/steps/general/CheckSteps.java | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
| import org.hamcrest.CoreMatchers;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List;
import static java.lang.String.format;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.*; | package ru.colibri.ui.steps.general;
@Component
public class CheckSteps extends AbsSteps {
@Autowired | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
// Path: src/main/java/ru/colibri/ui/steps/general/CheckSteps.java
import org.hamcrest.CoreMatchers;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List;
import static java.lang.String.format;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.*;
package ru.colibri.ui.steps.general;
@Component
public class CheckSteps extends AbsSteps {
@Autowired | private PropertyUtils propertyUtils; |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/steps/general/CheckSteps.java | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
| import org.hamcrest.CoreMatchers;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List;
import static java.lang.String.format;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.*; | package ru.colibri.ui.steps.general;
@Component
public class CheckSteps extends AbsSteps {
@Autowired
private PropertyUtils propertyUtils;
@Step
@Then("каждый элемент \"$elementName\" содержит значение \"$template\" без учета регистра")
public void eachElementContainsValue(@Named("$elementName") String elementName, @Named("$template") String template) { | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
//
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
// @Slf4j
// @Service
// public class PropertyUtils {
// private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
//
// @Autowired
// private AppSettings appSettings;
//
// public static Properties readProperty(String... filePaths) {
// Properties props = new Properties();
// for (String path : filePaths) {
// try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
// props.load(inputStreamReader);
// } catch (IOException e) {
// throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
// }
// }
// return props;
// }
//
// public String injectProperties(String text) {
// Map<String, String> userProfile = appSettings.getUserProfile();
// Matcher matcher = propertyPattern.matcher(text);
// if (!matcher.find()) {
// return text;
// }
// String propertyKey = matcher.group(2);
// String propertyValue = userProfile.get(propertyKey);
// if (propertyValue == null) {
// log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined"));
// return text;
// }
// return matcher.replaceAll(propertyValue);
// }
// }
// Path: src/main/java/ru/colibri/ui/steps/general/CheckSteps.java
import org.hamcrest.CoreMatchers;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.colibri.ui.settings.general.PropertyUtils;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List;
import static java.lang.String.format;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.*;
package ru.colibri.ui.steps.general;
@Component
public class CheckSteps extends AbsSteps {
@Autowired
private PropertyUtils propertyUtils;
@Step
@Then("каждый элемент \"$elementName\" содержит значение \"$template\" без учета регистра")
public void eachElementContainsValue(@Named("$elementName") String elementName, @Named("$template") String template) { | IElement element = getCurrentPage().getElementByName(elementName); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/android/base/BaseAndroidDriverConfigurator.java | // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
//
// Path: src/main/java/ru/colibri/ui/settings/configurator/AbsDriverConfigurator.java
// @Log
// public abstract class AbsDriverConfigurator implements IDriverConfigurator {
// @Autowired
// private FileUtils fileUtils;
//
// protected DesiredCapabilities createCapabilities(DriversSettings driversSettings) {
// DesiredCapabilities capabilities = new DesiredCapabilities();
// capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, driversSettings.getDeviceName());
// capabilities.setCapability(MobileCapabilityType.UDID, driversSettings.getUDID());
// String absolutePath = fileUtils.relativeToAbsolutePath(driversSettings.getFilePath());
// capabilities.setCapability(MobileCapabilityType.APP, absolutePath);
// capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, driversSettings.getNewCommandTimeoutInSeconds());
// capabilities.setCapability(MobileCapabilityType.CLEAR_SYSTEM_FILES, true);
// return capabilities;
// }
//
// protected URL getRemoteAddress(String remoteUrl) {
// try {
// return new URL(remoteUrl);
// } catch (MalformedURLException e) {
// log.log(Level.SEVERE, e.getMessage(), e);
// throw new RuntimeException(e);
// }
// }
//
// }
| import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.settings.DriversSettings;
import ru.colibri.ui.settings.configurator.AbsDriverConfigurator;
import java.util.concurrent.TimeUnit; | package ru.colibri.ui.settings.android.base;
public abstract class BaseAndroidDriverConfigurator extends AbsDriverConfigurator {
@Override | // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
//
// Path: src/main/java/ru/colibri/ui/settings/configurator/AbsDriverConfigurator.java
// @Log
// public abstract class AbsDriverConfigurator implements IDriverConfigurator {
// @Autowired
// private FileUtils fileUtils;
//
// protected DesiredCapabilities createCapabilities(DriversSettings driversSettings) {
// DesiredCapabilities capabilities = new DesiredCapabilities();
// capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, driversSettings.getDeviceName());
// capabilities.setCapability(MobileCapabilityType.UDID, driversSettings.getUDID());
// String absolutePath = fileUtils.relativeToAbsolutePath(driversSettings.getFilePath());
// capabilities.setCapability(MobileCapabilityType.APP, absolutePath);
// capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, driversSettings.getNewCommandTimeoutInSeconds());
// capabilities.setCapability(MobileCapabilityType.CLEAR_SYSTEM_FILES, true);
// return capabilities;
// }
//
// protected URL getRemoteAddress(String remoteUrl) {
// try {
// return new URL(remoteUrl);
// } catch (MalformedURLException e) {
// log.log(Level.SEVERE, e.getMessage(), e);
// throw new RuntimeException(e);
// }
// }
//
// }
// Path: src/main/java/ru/colibri/ui/settings/android/base/BaseAndroidDriverConfigurator.java
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.settings.DriversSettings;
import ru.colibri.ui.settings.configurator.AbsDriverConfigurator;
import java.util.concurrent.TimeUnit;
package ru.colibri.ui.settings.android.base;
public abstract class BaseAndroidDriverConfigurator extends AbsDriverConfigurator {
@Override | public AppiumDriver createDriver(DriversSettings driversSettings, AppSettings appSettings) { |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/android/base/BaseAndroidDriverConfigurator.java | // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
//
// Path: src/main/java/ru/colibri/ui/settings/configurator/AbsDriverConfigurator.java
// @Log
// public abstract class AbsDriverConfigurator implements IDriverConfigurator {
// @Autowired
// private FileUtils fileUtils;
//
// protected DesiredCapabilities createCapabilities(DriversSettings driversSettings) {
// DesiredCapabilities capabilities = new DesiredCapabilities();
// capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, driversSettings.getDeviceName());
// capabilities.setCapability(MobileCapabilityType.UDID, driversSettings.getUDID());
// String absolutePath = fileUtils.relativeToAbsolutePath(driversSettings.getFilePath());
// capabilities.setCapability(MobileCapabilityType.APP, absolutePath);
// capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, driversSettings.getNewCommandTimeoutInSeconds());
// capabilities.setCapability(MobileCapabilityType.CLEAR_SYSTEM_FILES, true);
// return capabilities;
// }
//
// protected URL getRemoteAddress(String remoteUrl) {
// try {
// return new URL(remoteUrl);
// } catch (MalformedURLException e) {
// log.log(Level.SEVERE, e.getMessage(), e);
// throw new RuntimeException(e);
// }
// }
//
// }
| import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.settings.DriversSettings;
import ru.colibri.ui.settings.configurator.AbsDriverConfigurator;
import java.util.concurrent.TimeUnit; | package ru.colibri.ui.settings.android.base;
public abstract class BaseAndroidDriverConfigurator extends AbsDriverConfigurator {
@Override | // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
//
// Path: src/main/java/ru/colibri/ui/settings/configurator/AbsDriverConfigurator.java
// @Log
// public abstract class AbsDriverConfigurator implements IDriverConfigurator {
// @Autowired
// private FileUtils fileUtils;
//
// protected DesiredCapabilities createCapabilities(DriversSettings driversSettings) {
// DesiredCapabilities capabilities = new DesiredCapabilities();
// capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, driversSettings.getDeviceName());
// capabilities.setCapability(MobileCapabilityType.UDID, driversSettings.getUDID());
// String absolutePath = fileUtils.relativeToAbsolutePath(driversSettings.getFilePath());
// capabilities.setCapability(MobileCapabilityType.APP, absolutePath);
// capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, driversSettings.getNewCommandTimeoutInSeconds());
// capabilities.setCapability(MobileCapabilityType.CLEAR_SYSTEM_FILES, true);
// return capabilities;
// }
//
// protected URL getRemoteAddress(String remoteUrl) {
// try {
// return new URL(remoteUrl);
// } catch (MalformedURLException e) {
// log.log(Level.SEVERE, e.getMessage(), e);
// throw new RuntimeException(e);
// }
// }
//
// }
// Path: src/main/java/ru/colibri/ui/settings/android/base/BaseAndroidDriverConfigurator.java
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.settings.DriversSettings;
import ru.colibri.ui.settings.configurator.AbsDriverConfigurator;
import java.util.concurrent.TimeUnit;
package ru.colibri.ui.settings.android.base;
public abstract class BaseAndroidDriverConfigurator extends AbsDriverConfigurator {
@Override | public AppiumDriver createDriver(DriversSettings driversSettings, AppSettings appSettings) { |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/core/pages/Page.java | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
| import lombok.EqualsAndHashCode;
import lombok.ToString;
import ru.colibri.ui.core.fields.IElement;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; | package ru.colibri.ui.core.pages;
@ToString
@EqualsAndHashCode
public class Page implements IPage {
private String systemId;
private String name; | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
// Path: src/main/java/ru/colibri/ui/core/pages/Page.java
import lombok.EqualsAndHashCode;
import lombok.ToString;
import ru.colibri.ui.core.fields.IElement;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
package ru.colibri.ui.core.pages;
@ToString
@EqualsAndHashCode
public class Page implements IPage {
private String systemId;
private String name; | private Map<String, IElement> elements = new HashMap<>(); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/core/builders/ElementBuilder.java | // Path: src/main/java/ru/colibri/ui/core/fields/Element.java
// @AllArgsConstructor
// @ToString
// @EqualsAndHashCode
// public class Element implements IElement {
// private String name;
// private String contentDesc;
// private String id;
// private String text;
// private String xpath;
// private String nsPredicate;
// private boolean specific;
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public String getContentDesc() {
// return contentDesc;
// }
//
// @Override
// public String getId() {
// return id;
// }
//
// @Override
// public boolean isSpecific() {
// return specific;
// }
//
// @Override
// public String getText() {
// return text;
// }
//
// @Override
// public String getXpath() {
// return xpath;
// }
//
// @Override
// public String getNSPredicate() {
// return nsPredicate;
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
| import ru.colibri.ui.core.fields.Element;
import ru.colibri.ui.core.fields.IElement; | public ElementBuilder withSpecific(boolean specific) {
this.specific = specific;
return this;
}
public ElementBuilder withId(String id) {
this.id = id;
return this;
}
public ElementBuilder withContentDesc(String contentDesc) {
this.contentDesc = contentDesc;
return this;
}
public ElementBuilder withText(String text) {
this.text = text;
return this;
}
public ElementBuilder withXPath(String xpath) {
this.xpath = xpath;
return this;
}
public ElementBuilder withNSPredicate(String nsPredicate) {
this.nsPredicate = nsPredicate;
return this;
}
| // Path: src/main/java/ru/colibri/ui/core/fields/Element.java
// @AllArgsConstructor
// @ToString
// @EqualsAndHashCode
// public class Element implements IElement {
// private String name;
// private String contentDesc;
// private String id;
// private String text;
// private String xpath;
// private String nsPredicate;
// private boolean specific;
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public String getContentDesc() {
// return contentDesc;
// }
//
// @Override
// public String getId() {
// return id;
// }
//
// @Override
// public boolean isSpecific() {
// return specific;
// }
//
// @Override
// public String getText() {
// return text;
// }
//
// @Override
// public String getXpath() {
// return xpath;
// }
//
// @Override
// public String getNSPredicate() {
// return nsPredicate;
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
// Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilder.java
import ru.colibri.ui.core.fields.Element;
import ru.colibri.ui.core.fields.IElement;
public ElementBuilder withSpecific(boolean specific) {
this.specific = specific;
return this;
}
public ElementBuilder withId(String id) {
this.id = id;
return this;
}
public ElementBuilder withContentDesc(String contentDesc) {
this.contentDesc = contentDesc;
return this;
}
public ElementBuilder withText(String text) {
this.text = text;
return this;
}
public ElementBuilder withXPath(String xpath) {
this.xpath = xpath;
return this;
}
public ElementBuilder withNSPredicate(String nsPredicate) {
this.nsPredicate = nsPredicate;
return this;
}
| public IElement please() { |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/core/builders/ElementBuilder.java | // Path: src/main/java/ru/colibri/ui/core/fields/Element.java
// @AllArgsConstructor
// @ToString
// @EqualsAndHashCode
// public class Element implements IElement {
// private String name;
// private String contentDesc;
// private String id;
// private String text;
// private String xpath;
// private String nsPredicate;
// private boolean specific;
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public String getContentDesc() {
// return contentDesc;
// }
//
// @Override
// public String getId() {
// return id;
// }
//
// @Override
// public boolean isSpecific() {
// return specific;
// }
//
// @Override
// public String getText() {
// return text;
// }
//
// @Override
// public String getXpath() {
// return xpath;
// }
//
// @Override
// public String getNSPredicate() {
// return nsPredicate;
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
| import ru.colibri.ui.core.fields.Element;
import ru.colibri.ui.core.fields.IElement; | this.specific = specific;
return this;
}
public ElementBuilder withId(String id) {
this.id = id;
return this;
}
public ElementBuilder withContentDesc(String contentDesc) {
this.contentDesc = contentDesc;
return this;
}
public ElementBuilder withText(String text) {
this.text = text;
return this;
}
public ElementBuilder withXPath(String xpath) {
this.xpath = xpath;
return this;
}
public ElementBuilder withNSPredicate(String nsPredicate) {
this.nsPredicate = nsPredicate;
return this;
}
public IElement please() { | // Path: src/main/java/ru/colibri/ui/core/fields/Element.java
// @AllArgsConstructor
// @ToString
// @EqualsAndHashCode
// public class Element implements IElement {
// private String name;
// private String contentDesc;
// private String id;
// private String text;
// private String xpath;
// private String nsPredicate;
// private boolean specific;
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public String getContentDesc() {
// return contentDesc;
// }
//
// @Override
// public String getId() {
// return id;
// }
//
// @Override
// public boolean isSpecific() {
// return specific;
// }
//
// @Override
// public String getText() {
// return text;
// }
//
// @Override
// public String getXpath() {
// return xpath;
// }
//
// @Override
// public String getNSPredicate() {
// return nsPredicate;
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
// Path: src/main/java/ru/colibri/ui/core/builders/ElementBuilder.java
import ru.colibri.ui.core.fields.Element;
import ru.colibri.ui.core.fields.IElement;
this.specific = specific;
return this;
}
public ElementBuilder withId(String id) {
this.id = id;
return this;
}
public ElementBuilder withContentDesc(String contentDesc) {
this.contentDesc = contentDesc;
return this;
}
public ElementBuilder withText(String text) {
this.text = text;
return this;
}
public ElementBuilder withXPath(String xpath) {
this.xpath = xpath;
return this;
}
public ElementBuilder withNSPredicate(String nsPredicate) {
this.nsPredicate = nsPredicate;
return this;
}
public IElement please() { | return new Element(name, contentDesc, id, text, xpath, nsPredicate, specific); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/steps/general/ButtonsSteps.java | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
| import io.appium.java_client.TouchAction;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.When;
import org.openqa.selenium.WebElement;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List;
import static io.appium.java_client.touch.offset.ElementOption.element; | package ru.colibri.ui.steps.general;
@Component
public class ButtonsSteps extends AbsSteps {
@Step
@When("выполнено нажатие на \"$button\"")
public void buttonClick(@Named("$button") String button) {
getWebElementByName(button).click();
}
@Step
@When("(Optional) выполнено нажатие на \"$button\"")
public void optionalButtonClick(@Named("$button") String button) {
try {
buttonClick(button);
} catch (Exception ignored) {
System.out.println("Не нажато");
}
}
@Step
@When("выполнен лонгтап на \"$button\"")
public void buttonLongtap(@Named("$button") String button) {
new TouchAction(driver).longPress(element(getWebElementByName(button))).release().perform();
}
@Step
@When("выполнен лонгтап на элемент \"$fieldName\" с индексом \"$index\"")
public void listItemLongtap(String fieldName, int index) { | // Path: src/main/java/ru/colibri/ui/core/fields/IElement.java
// public interface IElement {
// String getName();
//
// String getContentDesc();
//
// String getId();
//
// String getText();
//
// String getXpath();
//
// String getNSPredicate();
//
// boolean isSpecific();
// }
//
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java
// @Log
// public abstract class AbsSteps extends Steps implements InitializingBean {
//
// private static final int TIMEOUT = 7;
// private int currentTimeout;
//
// @Autowired
// protected TestContext testContext;
//
// @Autowired
// protected AppiumDriver driver;
//
// @Autowired(required = false)
// protected IFinder finder;
//
// @Autowired
// protected IPageProvider pageProvider;
//
// @Autowired
// protected DriversSettings driverSettings;
//
// protected IPage getCurrentPage() {
// return pageProvider.getCurrentPage();
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// log.info(String.format("Bean %s loaded", this.getClass().getSimpleName()));
// }
//
// protected DriversSettings getDriversSettings() {
// return driverSettings;
// }
//
// protected WebElement getWebElementByName(String elementName) {
// IElement element = getCurrentPage().getElementByName(elementName);
// return finder.findWebElement(element);
// }
//
// protected void decreaseImplicitlyWait() {
// decreaseImplicitlyWait(TIMEOUT);
// }
//
// protected void decreaseImplicitlyWait(int timeout) {
// currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds();
// driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// }
//
// protected void increaseImplicitlyWait() {
// driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS);
// }
// }
// Path: src/main/java/ru/colibri/ui/steps/general/ButtonsSteps.java
import io.appium.java_client.TouchAction;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.When;
import org.openqa.selenium.WebElement;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.fields.IElement;
import ru.colibri.ui.core.steps.AbsSteps;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List;
import static io.appium.java_client.touch.offset.ElementOption.element;
package ru.colibri.ui.steps.general;
@Component
public class ButtonsSteps extends AbsSteps {
@Step
@When("выполнено нажатие на \"$button\"")
public void buttonClick(@Named("$button") String button) {
getWebElementByName(button).click();
}
@Step
@When("(Optional) выполнено нажатие на \"$button\"")
public void optionalButtonClick(@Named("$button") String button) {
try {
buttonClick(button);
} catch (Exception ignored) {
System.out.println("Не нажато");
}
}
@Step
@When("выполнен лонгтап на \"$button\"")
public void buttonLongtap(@Named("$button") String button) {
new TouchAction(driver).longPress(element(getWebElementByName(button))).release().perform();
}
@Step
@When("выполнен лонгтап на элемент \"$fieldName\" с индексом \"$index\"")
public void listItemLongtap(String fieldName, int index) { | IElement element = getCurrentPage().getElementByName(fieldName); |
alfa-laboratory/colibri-ui | src/test/java/ru/colibri/ui/core/pages/AbsPageProviderTest.java | // Path: src/main/java/ru/colibri/ui/core/exception/NoPageFoundException.java
// public class NoPageFoundException extends RuntimeException {
// public NoPageFoundException(String pageName) {
// super("No page found \"" + pageName + "\"");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/exception/PageNameAlreadyUsedException.java
// public class PageNameAlreadyUsedException extends RuntimeException {
// public PageNameAlreadyUsedException(String pageName) {
// super("Page name already used \"" + pageName + "\"");
// }
// }
//
// Path: src/test/java/ru/colibri/ui/settings/general/UtilsTestConfig.java
// @Configuration
// public class UtilsTestConfig {
//
// @Bean
// public PropertyUtils getPropertyUtils() {
// return new PropertyUtils();
// }
//
// @Bean
// public AppSettings getFakeAppSettings() {
// return AppSettings.builder().packageName("ru.company.android").userProfile(createFakeUser()).build();
// }
//
// @Bean
// public AppiumDriver getAppiumDriver() {
// return mock(AppiumDriver.class);
// }
//
// @Bean
// public TestContext getTestContext() {
// return mock(TestContext.class);
// }
//
// @Bean
// public PagesLoader getPagesLoader() {
// return new PagesLoader();
// }
//
// @Bean
// public FileUtils getFileUtils() {
// return new FileUtils();
// }
//
// @Bean
// public ElementBuilders getElementBuilders() {
// return new ElementBuilders();
// }
//
// private Map<String, String> createFakeUser() {
// Map<String, String> map = new HashMap<>();
// map.put("name", "Иииигорь");
// return map;
// }
//
//
// }
| import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import ru.colibri.ui.core.exception.NoPageFoundException;
import ru.colibri.ui.core.exception.PageNameAlreadyUsedException;
import ru.colibri.ui.settings.general.UtilsTestConfig;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals; | @Before
public void generateTestData() {
pageProvider = new AbsPageProvider() {
@Override
public IPage getCurrentPage() {
return null;
}
};
fillPageProvider();
}
@Test
public void addPageObject() throws Exception {
Map<String, IPage> testMapName = new HashMap<>();
testMapName.put(fullPage.getName().toLowerCase(), fullPage);
testMapName.put(pageWithName.getName().toLowerCase(), pageWithName);
testMapName.put(pageWithId.getName().toLowerCase(), pageWithId);
testMapName.put(emptyPage.getName().toLowerCase(), emptyPage);
Map<String, IPage> testMapID = new HashMap<>();
testMapID.put(fullPage.getSystemId().toLowerCase(), fullPage);
testMapID.put(pageWithName.getSystemId().toLowerCase(), pageWithName);
testMapID.put(pageWithId.getSystemId().toLowerCase(), pageWithId);
testMapID.put(emptyPage.getSystemId().toLowerCase(), emptyPage);
assertEquals(pageProvider.pagesByName, testMapName);
assertEquals(pageProvider.pagesByID, testMapID);
}
| // Path: src/main/java/ru/colibri/ui/core/exception/NoPageFoundException.java
// public class NoPageFoundException extends RuntimeException {
// public NoPageFoundException(String pageName) {
// super("No page found \"" + pageName + "\"");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/exception/PageNameAlreadyUsedException.java
// public class PageNameAlreadyUsedException extends RuntimeException {
// public PageNameAlreadyUsedException(String pageName) {
// super("Page name already used \"" + pageName + "\"");
// }
// }
//
// Path: src/test/java/ru/colibri/ui/settings/general/UtilsTestConfig.java
// @Configuration
// public class UtilsTestConfig {
//
// @Bean
// public PropertyUtils getPropertyUtils() {
// return new PropertyUtils();
// }
//
// @Bean
// public AppSettings getFakeAppSettings() {
// return AppSettings.builder().packageName("ru.company.android").userProfile(createFakeUser()).build();
// }
//
// @Bean
// public AppiumDriver getAppiumDriver() {
// return mock(AppiumDriver.class);
// }
//
// @Bean
// public TestContext getTestContext() {
// return mock(TestContext.class);
// }
//
// @Bean
// public PagesLoader getPagesLoader() {
// return new PagesLoader();
// }
//
// @Bean
// public FileUtils getFileUtils() {
// return new FileUtils();
// }
//
// @Bean
// public ElementBuilders getElementBuilders() {
// return new ElementBuilders();
// }
//
// private Map<String, String> createFakeUser() {
// Map<String, String> map = new HashMap<>();
// map.put("name", "Иииигорь");
// return map;
// }
//
//
// }
// Path: src/test/java/ru/colibri/ui/core/pages/AbsPageProviderTest.java
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import ru.colibri.ui.core.exception.NoPageFoundException;
import ru.colibri.ui.core.exception.PageNameAlreadyUsedException;
import ru.colibri.ui.settings.general.UtilsTestConfig;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals;
@Before
public void generateTestData() {
pageProvider = new AbsPageProvider() {
@Override
public IPage getCurrentPage() {
return null;
}
};
fillPageProvider();
}
@Test
public void addPageObject() throws Exception {
Map<String, IPage> testMapName = new HashMap<>();
testMapName.put(fullPage.getName().toLowerCase(), fullPage);
testMapName.put(pageWithName.getName().toLowerCase(), pageWithName);
testMapName.put(pageWithId.getName().toLowerCase(), pageWithId);
testMapName.put(emptyPage.getName().toLowerCase(), emptyPage);
Map<String, IPage> testMapID = new HashMap<>();
testMapID.put(fullPage.getSystemId().toLowerCase(), fullPage);
testMapID.put(pageWithName.getSystemId().toLowerCase(), pageWithName);
testMapID.put(pageWithId.getSystemId().toLowerCase(), pageWithId);
testMapID.put(emptyPage.getSystemId().toLowerCase(), emptyPage);
assertEquals(pageProvider.pagesByName, testMapName);
assertEquals(pageProvider.pagesByID, testMapID);
}
| @Test(expected = PageNameAlreadyUsedException.class) |
alfa-laboratory/colibri-ui | src/test/java/ru/colibri/ui/core/pages/AbsPageProviderTest.java | // Path: src/main/java/ru/colibri/ui/core/exception/NoPageFoundException.java
// public class NoPageFoundException extends RuntimeException {
// public NoPageFoundException(String pageName) {
// super("No page found \"" + pageName + "\"");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/exception/PageNameAlreadyUsedException.java
// public class PageNameAlreadyUsedException extends RuntimeException {
// public PageNameAlreadyUsedException(String pageName) {
// super("Page name already used \"" + pageName + "\"");
// }
// }
//
// Path: src/test/java/ru/colibri/ui/settings/general/UtilsTestConfig.java
// @Configuration
// public class UtilsTestConfig {
//
// @Bean
// public PropertyUtils getPropertyUtils() {
// return new PropertyUtils();
// }
//
// @Bean
// public AppSettings getFakeAppSettings() {
// return AppSettings.builder().packageName("ru.company.android").userProfile(createFakeUser()).build();
// }
//
// @Bean
// public AppiumDriver getAppiumDriver() {
// return mock(AppiumDriver.class);
// }
//
// @Bean
// public TestContext getTestContext() {
// return mock(TestContext.class);
// }
//
// @Bean
// public PagesLoader getPagesLoader() {
// return new PagesLoader();
// }
//
// @Bean
// public FileUtils getFileUtils() {
// return new FileUtils();
// }
//
// @Bean
// public ElementBuilders getElementBuilders() {
// return new ElementBuilders();
// }
//
// private Map<String, String> createFakeUser() {
// Map<String, String> map = new HashMap<>();
// map.put("name", "Иииигорь");
// return map;
// }
//
//
// }
| import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import ru.colibri.ui.core.exception.NoPageFoundException;
import ru.colibri.ui.core.exception.PageNameAlreadyUsedException;
import ru.colibri.ui.settings.general.UtilsTestConfig;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals; |
@Test(expected = PageNameAlreadyUsedException.class)
public void addNotUniqueNamePageObject() throws Exception {
pageProvider.addPageObject(pageWithName);
}
@Test(expected = PageNameAlreadyUsedException.class)
public void addNotUniqueIDPageObject() throws Exception {
pageProvider.addPageObject(pageWithId);
}
@Test
public void addEmptyPageObject() throws Exception {
pageProvider.addPageObject(emptyPage);
pageProvider.addPageObject(emptyPage);
}
@Test
public void getPageByName() throws Exception {
IPage testPage = pageProvider.getPageByName(pageWithName.getName().toLowerCase());
assertEquals(testPage, pageWithName);
}
@Test
public void getPageById() throws Exception {
IPage testPage = pageProvider.getPageById(pageWithId.getSystemId().toLowerCase());
assertEquals(testPage, pageWithId);
}
| // Path: src/main/java/ru/colibri/ui/core/exception/NoPageFoundException.java
// public class NoPageFoundException extends RuntimeException {
// public NoPageFoundException(String pageName) {
// super("No page found \"" + pageName + "\"");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/exception/PageNameAlreadyUsedException.java
// public class PageNameAlreadyUsedException extends RuntimeException {
// public PageNameAlreadyUsedException(String pageName) {
// super("Page name already used \"" + pageName + "\"");
// }
// }
//
// Path: src/test/java/ru/colibri/ui/settings/general/UtilsTestConfig.java
// @Configuration
// public class UtilsTestConfig {
//
// @Bean
// public PropertyUtils getPropertyUtils() {
// return new PropertyUtils();
// }
//
// @Bean
// public AppSettings getFakeAppSettings() {
// return AppSettings.builder().packageName("ru.company.android").userProfile(createFakeUser()).build();
// }
//
// @Bean
// public AppiumDriver getAppiumDriver() {
// return mock(AppiumDriver.class);
// }
//
// @Bean
// public TestContext getTestContext() {
// return mock(TestContext.class);
// }
//
// @Bean
// public PagesLoader getPagesLoader() {
// return new PagesLoader();
// }
//
// @Bean
// public FileUtils getFileUtils() {
// return new FileUtils();
// }
//
// @Bean
// public ElementBuilders getElementBuilders() {
// return new ElementBuilders();
// }
//
// private Map<String, String> createFakeUser() {
// Map<String, String> map = new HashMap<>();
// map.put("name", "Иииигорь");
// return map;
// }
//
//
// }
// Path: src/test/java/ru/colibri/ui/core/pages/AbsPageProviderTest.java
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import ru.colibri.ui.core.exception.NoPageFoundException;
import ru.colibri.ui.core.exception.PageNameAlreadyUsedException;
import ru.colibri.ui.settings.general.UtilsTestConfig;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals;
@Test(expected = PageNameAlreadyUsedException.class)
public void addNotUniqueNamePageObject() throws Exception {
pageProvider.addPageObject(pageWithName);
}
@Test(expected = PageNameAlreadyUsedException.class)
public void addNotUniqueIDPageObject() throws Exception {
pageProvider.addPageObject(pageWithId);
}
@Test
public void addEmptyPageObject() throws Exception {
pageProvider.addPageObject(emptyPage);
pageProvider.addPageObject(emptyPage);
}
@Test
public void getPageByName() throws Exception {
IPage testPage = pageProvider.getPageByName(pageWithName.getName().toLowerCase());
assertEquals(testPage, pageWithName);
}
@Test
public void getPageById() throws Exception {
IPage testPage = pageProvider.getPageById(pageWithId.getSystemId().toLowerCase());
assertEquals(testPage, pageWithId);
}
| @Test(expected = NoPageFoundException.class) |
alfa-laboratory/colibri-ui | src/test/java/ru/colibri/ui/settings/FileUtilsTests.java | // Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
| import org.junit.Test;
import ru.colibri.ui.core.utils.FileUtils;
import static org.junit.Assert.assertEquals; | package ru.colibri.ui.settings;
public class FileUtilsTests {
@Test
public void winPath() { | // Path: src/main/java/ru/colibri/ui/core/utils/FileUtils.java
// @Component
// public class FileUtils {
// public String relativeToAbsolutePath(String relativePath) {
// String path = new File(relativePath).toURI().getPath();
// return transformPath(path);
// }
//
// public String transformPath(String path) {
// if (path.contains(":")) { //windows
// StringBuilder builder = new StringBuilder(path);
// builder.deleteCharAt(0);
// path = builder.toString();
// }
// return path;
// }
//
// public List<File> getAllFilesAtDirectory(File directory) {
// List<File> result = new ArrayList<>();
// if (!directory.isDirectory()) {
// result.add(directory);
// } else {
// File[] files = directory.listFiles();
// if (files != null && files.length > 0) {
// Collections.addAll(result, files);
// }
// }
// return result;
// }
//
// public File getFileByPath(String path) {
// ClassLoader classLoader = FileUtils.class.getClassLoader();
// String fileUrl = classLoader.getResource(path).getFile();
// return new File(fileUrl);
// }
// }
// Path: src/test/java/ru/colibri/ui/settings/FileUtilsTests.java
import org.junit.Test;
import ru.colibri.ui.core.utils.FileUtils;
import static org.junit.Assert.assertEquals;
package ru.colibri.ui.settings;
public class FileUtilsTests {
@Test
public void winPath() { | FileUtils fileUtils = new FileUtils(); |
alfa-laboratory/colibri-ui | src/test/java/ru/colibri/ui/settings/loaders/AbsSettingsLoaderFake.java | // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
| import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.settings.DriversSettings; | package ru.colibri.ui.settings.loaders;
public class AbsSettingsLoaderFake extends AbsSettingsLoader {
@Override | // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
// Path: src/test/java/ru/colibri/ui/settings/loaders/AbsSettingsLoaderFake.java
import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.settings.DriversSettings;
package ru.colibri.ui.settings.loaders;
public class AbsSettingsLoaderFake extends AbsSettingsLoader {
@Override | public AppSettings loadAppSettings(String userName) { |
alfa-laboratory/colibri-ui | src/test/java/ru/colibri/ui/settings/loaders/AbsSettingsLoaderFake.java | // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
| import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.settings.DriversSettings; | package ru.colibri.ui.settings.loaders;
public class AbsSettingsLoaderFake extends AbsSettingsLoader {
@Override
public AppSettings loadAppSettings(String userName) {
return null;
}
@Override | // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/DriversSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class DriversSettings {
// private String appiumRemoteUrl;
// private String deviceName;
// private String filePath;
// private int findingTimeOutInSeconds;
// private int newCommandTimeoutInSeconds;
// private int implicitlyWaitInSeconds;
// private String storyTimeoutsInSeconds;
// private List<String> stepsPackages;
// private String storyPath;
// private String storyToInclude;
// private String storyToExclude;
// private String pagesPath;
// private String UDID;
// private int wdaLocalPort;
// private int systemPort;
// private String platformVersion;
// }
// Path: src/test/java/ru/colibri/ui/settings/loaders/AbsSettingsLoaderFake.java
import ru.colibri.ui.core.settings.AppSettings;
import ru.colibri.ui.core.settings.DriversSettings;
package ru.colibri.ui.settings.loaders;
public class AbsSettingsLoaderFake extends AbsSettingsLoader {
@Override
public AppSettings loadAppSettings(String userName) {
return null;
}
@Override | public DriversSettings loadDriverSettings(String platformName) { |
alfa-laboratory/colibri-ui | src/test/java/ru/colibri/ui/settings/android/AndroidTestConfig.java | // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
| import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import ru.colibri.ui.core.settings.AppSettings; | package ru.colibri.ui.settings.android;
@Configuration
public class AndroidTestConfig {
@Bean | // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
// Path: src/test/java/ru/colibri/ui/settings/android/AndroidTestConfig.java
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import ru.colibri.ui.core.settings.AppSettings;
package ru.colibri.ui.settings.android;
@Configuration
public class AndroidTestConfig {
@Bean | public AppSettings getFakeAppSettings() { |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java | // Path: src/main/java/ru/colibri/ui/core/names/ColibriStartFlags.java
// public class ColibriStartFlags {
// public static final String PLATFORM = "platform";
// public static final String USER = "user";
// public static final String TEST_TYPE = "testType";
// public static final String BUILD_VERSION = "buildVersion";
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
| import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ru.colibri.ui.core.names.ColibriStartFlags;
import ru.colibri.ui.core.settings.AppSettings;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.regex.Pattern.compile; | package ru.colibri.ui.settings.general;
@Slf4j
@Service
public class PropertyUtils {
private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
@Autowired | // Path: src/main/java/ru/colibri/ui/core/names/ColibriStartFlags.java
// public class ColibriStartFlags {
// public static final String PLATFORM = "platform";
// public static final String USER = "user";
// public static final String TEST_TYPE = "testType";
// public static final String BUILD_VERSION = "buildVersion";
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ru.colibri.ui.core.names.ColibriStartFlags;
import ru.colibri.ui.core.settings.AppSettings;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.regex.Pattern.compile;
package ru.colibri.ui.settings.general;
@Slf4j
@Service
public class PropertyUtils {
private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
@Autowired | private AppSettings appSettings; |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java | // Path: src/main/java/ru/colibri/ui/core/names/ColibriStartFlags.java
// public class ColibriStartFlags {
// public static final String PLATFORM = "platform";
// public static final String USER = "user";
// public static final String TEST_TYPE = "testType";
// public static final String BUILD_VERSION = "buildVersion";
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
| import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ru.colibri.ui.core.names.ColibriStartFlags;
import ru.colibri.ui.core.settings.AppSettings;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.regex.Pattern.compile; | package ru.colibri.ui.settings.general;
@Slf4j
@Service
public class PropertyUtils {
private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
@Autowired
private AppSettings appSettings;
public static Properties readProperty(String... filePaths) {
Properties props = new Properties();
for (String path : filePaths) {
try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
props.load(inputStreamReader);
} catch (IOException e) {
throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
}
}
return props;
}
public String injectProperties(String text) {
Map<String, String> userProfile = appSettings.getUserProfile();
Matcher matcher = propertyPattern.matcher(text);
if (!matcher.find()) {
return text;
}
String propertyKey = matcher.group(2);
String propertyValue = userProfile.get(propertyKey);
if (propertyValue == null) { | // Path: src/main/java/ru/colibri/ui/core/names/ColibriStartFlags.java
// public class ColibriStartFlags {
// public static final String PLATFORM = "platform";
// public static final String USER = "user";
// public static final String TEST_TYPE = "testType";
// public static final String BUILD_VERSION = "buildVersion";
// }
//
// Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java
// @Getter
// @Builder
// @ToString
// @EqualsAndHashCode
// public class AppSettings {
// private final String packageName;
// private final String startPageId;
// private final boolean activityUse;
// private final Map<String, String> userProfile;
// }
// Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ru.colibri.ui.core.names.ColibriStartFlags;
import ru.colibri.ui.core.settings.AppSettings;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.regex.Pattern.compile;
package ru.colibri.ui.settings.general;
@Slf4j
@Service
public class PropertyUtils {
private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)");
@Autowired
private AppSettings appSettings;
public static Properties readProperty(String... filePaths) {
Properties props = new Properties();
for (String path : filePaths) {
try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) {
props.load(inputStreamReader);
} catch (IOException e) {
throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e);
}
}
return props;
}
public String injectProperties(String text) {
Map<String, String> userProfile = appSettings.getUserProfile();
Matcher matcher = propertyPattern.matcher(text);
if (!matcher.find()) {
return text;
}
String propertyKey = matcher.group(2);
String propertyValue = userProfile.get(propertyKey);
if (propertyValue == null) { | log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined")); |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/core/pages/AbsPageProvider.java | // Path: src/main/java/ru/colibri/ui/core/exception/NoPageFoundException.java
// public class NoPageFoundException extends RuntimeException {
// public NoPageFoundException(String pageName) {
// super("No page found \"" + pageName + "\"");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/exception/PageNameAlreadyUsedException.java
// public class PageNameAlreadyUsedException extends RuntimeException {
// public PageNameAlreadyUsedException(String pageName) {
// super("Page name already used \"" + pageName + "\"");
// }
// }
| import io.appium.java_client.AppiumDriver;
import lombok.ToString;
import org.springframework.beans.factory.annotation.Autowired;
import ru.colibri.ui.core.exception.NoPageFoundException;
import ru.colibri.ui.core.exception.PageNameAlreadyUsedException;
import java.util.HashMap;
import java.util.List; | package ru.colibri.ui.core.pages;
@ToString
public abstract class AbsPageProvider implements IPageProvider {
@Autowired
protected AppiumDriver driver;
protected HashMap<String, IPage> pagesByName;
protected HashMap<String, IPage> pagesByID;
public AbsPageProvider() {
pagesByName = new HashMap<>();
pagesByID = new HashMap<>();
}
| // Path: src/main/java/ru/colibri/ui/core/exception/NoPageFoundException.java
// public class NoPageFoundException extends RuntimeException {
// public NoPageFoundException(String pageName) {
// super("No page found \"" + pageName + "\"");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/exception/PageNameAlreadyUsedException.java
// public class PageNameAlreadyUsedException extends RuntimeException {
// public PageNameAlreadyUsedException(String pageName) {
// super("Page name already used \"" + pageName + "\"");
// }
// }
// Path: src/main/java/ru/colibri/ui/core/pages/AbsPageProvider.java
import io.appium.java_client.AppiumDriver;
import lombok.ToString;
import org.springframework.beans.factory.annotation.Autowired;
import ru.colibri.ui.core.exception.NoPageFoundException;
import ru.colibri.ui.core.exception.PageNameAlreadyUsedException;
import java.util.HashMap;
import java.util.List;
package ru.colibri.ui.core.pages;
@ToString
public abstract class AbsPageProvider implements IPageProvider {
@Autowired
protected AppiumDriver driver;
protected HashMap<String, IPage> pagesByName;
protected HashMap<String, IPage> pagesByID;
public AbsPageProvider() {
pagesByName = new HashMap<>();
pagesByID = new HashMap<>();
}
| public void addPageObject(IPage pageObject) throws PageNameAlreadyUsedException { |
alfa-laboratory/colibri-ui | src/main/java/ru/colibri/ui/core/pages/AbsPageProvider.java | // Path: src/main/java/ru/colibri/ui/core/exception/NoPageFoundException.java
// public class NoPageFoundException extends RuntimeException {
// public NoPageFoundException(String pageName) {
// super("No page found \"" + pageName + "\"");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/exception/PageNameAlreadyUsedException.java
// public class PageNameAlreadyUsedException extends RuntimeException {
// public PageNameAlreadyUsedException(String pageName) {
// super("Page name already used \"" + pageName + "\"");
// }
// }
| import io.appium.java_client.AppiumDriver;
import lombok.ToString;
import org.springframework.beans.factory.annotation.Autowired;
import ru.colibri.ui.core.exception.NoPageFoundException;
import ru.colibri.ui.core.exception.PageNameAlreadyUsedException;
import java.util.HashMap;
import java.util.List; |
public AbsPageProvider() {
pagesByName = new HashMap<>();
pagesByID = new HashMap<>();
}
public void addPageObject(IPage pageObject) throws PageNameAlreadyUsedException {
String systemId = pageObject.getSystemId().toLowerCase();
if (!systemId.isEmpty() && pagesByID.containsKey(systemId)) {
throw new PageNameAlreadyUsedException(systemId);
}
String name = pageObject.getName().toLowerCase();
if (!name.isEmpty() && pagesByName.containsKey(name)) {
throw new PageNameAlreadyUsedException(name);
}
pagesByName.put(name, pageObject);
pagesByID.put(systemId, pageObject);
}
public IPage getPageByName(String pageName) {
return getIPage(pagesByName, pageName);
}
public IPage getPageById(String pageId) {
return getIPage(pagesByID, pageId);
}
private IPage getIPage(HashMap<String, IPage> pages, String pageName) {
IPage result = pages.get(pageName.toLowerCase());
if (result == null) { | // Path: src/main/java/ru/colibri/ui/core/exception/NoPageFoundException.java
// public class NoPageFoundException extends RuntimeException {
// public NoPageFoundException(String pageName) {
// super("No page found \"" + pageName + "\"");
// }
// }
//
// Path: src/main/java/ru/colibri/ui/core/exception/PageNameAlreadyUsedException.java
// public class PageNameAlreadyUsedException extends RuntimeException {
// public PageNameAlreadyUsedException(String pageName) {
// super("Page name already used \"" + pageName + "\"");
// }
// }
// Path: src/main/java/ru/colibri/ui/core/pages/AbsPageProvider.java
import io.appium.java_client.AppiumDriver;
import lombok.ToString;
import org.springframework.beans.factory.annotation.Autowired;
import ru.colibri.ui.core.exception.NoPageFoundException;
import ru.colibri.ui.core.exception.PageNameAlreadyUsedException;
import java.util.HashMap;
import java.util.List;
public AbsPageProvider() {
pagesByName = new HashMap<>();
pagesByID = new HashMap<>();
}
public void addPageObject(IPage pageObject) throws PageNameAlreadyUsedException {
String systemId = pageObject.getSystemId().toLowerCase();
if (!systemId.isEmpty() && pagesByID.containsKey(systemId)) {
throw new PageNameAlreadyUsedException(systemId);
}
String name = pageObject.getName().toLowerCase();
if (!name.isEmpty() && pagesByName.containsKey(name)) {
throw new PageNameAlreadyUsedException(name);
}
pagesByName.put(name, pageObject);
pagesByID.put(systemId, pageObject);
}
public IPage getPageByName(String pageName) {
return getIPage(pagesByName, pageName);
}
public IPage getPageById(String pageId) {
return getIPage(pagesByID, pageId);
}
private IPage getIPage(HashMap<String, IPage> pages, String pageName) {
IPage result = pages.get(pageName.toLowerCase());
if (result == null) { | throw new NoPageFoundException(pageName); |
hortonworks/templeton | src/test/org/apache/hcatalog/templeton/test/mock/MockExecService.java | // Path: src/java/org/apache/hcatalog/templeton/ExecBean.java
// public class ExecBean {
// public String stdout;
// public String stderr;
// public int exitcode;
//
// public ExecBean() {}
//
// /**
// * Create a new ExecBean.
// *
// * @param stdout standard output of the the program.
// * @param stderr error output of the the program.
// * @param exitcode exit code of the program.
// */
// public ExecBean(String stdout, String stderr, int exitcode) {
// this.stdout = stdout;
// this.stderr = stderr;
// this.exitcode = exitcode;
// }
//
// public String toString() {
// return String.format("ExecBean(stdout=%s, stderr=%s, exitcode=%s)",
// stdout, stderr, exitcode);
// }
// }
//
// Path: src/java/org/apache/hcatalog/templeton/ExecService.java
// public interface ExecService {
// public ExecBean run(String program, List<String> args,
// Map<String, String> env)
// throws NotAuthorizedException, BusyException, ExecuteException, IOException;
//
// public ExecBean runUnlimited(String program, List<String> args,
// Map<String, String> env)
// throws NotAuthorizedException, ExecuteException, IOException;
// }
//
// Path: src/java/org/apache/hcatalog/templeton/NotAuthorizedException.java
// public class NotAuthorizedException extends SimpleWebException {
// public NotAuthorizedException(String msg) {
// super(401, msg);
// }
// }
| import java.io.IOException;
import java.util.List;
import java.util.Map;
import org.apache.commons.exec.ExecuteException;
import org.apache.hcatalog.templeton.ExecBean;
import org.apache.hcatalog.templeton.ExecService;
import org.apache.hcatalog.templeton.NotAuthorizedException; | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hcatalog.templeton.test.mock;
public class MockExecService implements ExecService {
public ExecBean run(String program, List<String> args,
Map<String, String> env) {
ExecBean bean = new ExecBean();
bean.stdout = program;
bean.stderr = args.toString();
return bean;
}
@Override
public ExecBean runUnlimited(String program,
List<String> args, Map<String, String> env) | // Path: src/java/org/apache/hcatalog/templeton/ExecBean.java
// public class ExecBean {
// public String stdout;
// public String stderr;
// public int exitcode;
//
// public ExecBean() {}
//
// /**
// * Create a new ExecBean.
// *
// * @param stdout standard output of the the program.
// * @param stderr error output of the the program.
// * @param exitcode exit code of the program.
// */
// public ExecBean(String stdout, String stderr, int exitcode) {
// this.stdout = stdout;
// this.stderr = stderr;
// this.exitcode = exitcode;
// }
//
// public String toString() {
// return String.format("ExecBean(stdout=%s, stderr=%s, exitcode=%s)",
// stdout, stderr, exitcode);
// }
// }
//
// Path: src/java/org/apache/hcatalog/templeton/ExecService.java
// public interface ExecService {
// public ExecBean run(String program, List<String> args,
// Map<String, String> env)
// throws NotAuthorizedException, BusyException, ExecuteException, IOException;
//
// public ExecBean runUnlimited(String program, List<String> args,
// Map<String, String> env)
// throws NotAuthorizedException, ExecuteException, IOException;
// }
//
// Path: src/java/org/apache/hcatalog/templeton/NotAuthorizedException.java
// public class NotAuthorizedException extends SimpleWebException {
// public NotAuthorizedException(String msg) {
// super(401, msg);
// }
// }
// Path: src/test/org/apache/hcatalog/templeton/test/mock/MockExecService.java
import java.io.IOException;
import java.util.List;
import java.util.Map;
import org.apache.commons.exec.ExecuteException;
import org.apache.hcatalog.templeton.ExecBean;
import org.apache.hcatalog.templeton.ExecService;
import org.apache.hcatalog.templeton.NotAuthorizedException;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hcatalog.templeton.test.mock;
public class MockExecService implements ExecService {
public ExecBean run(String program, List<String> args,
Map<String, String> env) {
ExecBean bean = new ExecBean();
bean.stdout = program;
bean.stderr = args.toString();
return bean;
}
@Override
public ExecBean runUnlimited(String program,
List<String> args, Map<String, String> env) | throws NotAuthorizedException, ExecuteException, IOException { |
hortonworks/templeton | src/test/org/apache/hcatalog/templeton/test/tool/TrivialExecServiceTest.java | // Path: src/java/org/apache/hcatalog/templeton/tool/TrivialExecService.java
// public class TrivialExecService {
// private static volatile TrivialExecService theSingleton;
//
// /**
// * Retrieve the singleton.
// */
// public static synchronized TrivialExecService getInstance() {
// if (theSingleton == null)
// theSingleton = new TrivialExecService();
// return theSingleton;
// }
//
// public Process run(List<String> cmd, List<String> removeEnv,
// Map<String, String> environmentVariables)
// throws IOException
// {
// System.err.println("templeton: starting " + cmd);
// System.err.print("With environment variables: " );
// for(Map.Entry<String, String> keyVal : environmentVariables.entrySet()){
// System.err.println(keyVal.getKey() + "=" + keyVal.getValue());
// }
// ProcessBuilder pb = new ProcessBuilder(cmd);
// for (String key : removeEnv)
// pb.environment().remove(key);
// pb.environment().putAll(environmentVariables);
// return pb.start();
// }
//
// }
| import static org.junit.Assert.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import org.apache.hcatalog.templeton.tool.TrivialExecService;
import org.junit.Test; | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hcatalog.templeton.test.tool;
public class TrivialExecServiceTest {
@Test
public void test() {
ArrayList<String> list = new ArrayList<String>();
list.add("echo");
list.add("success");
BufferedReader out = null;
BufferedReader err = null;
try { | // Path: src/java/org/apache/hcatalog/templeton/tool/TrivialExecService.java
// public class TrivialExecService {
// private static volatile TrivialExecService theSingleton;
//
// /**
// * Retrieve the singleton.
// */
// public static synchronized TrivialExecService getInstance() {
// if (theSingleton == null)
// theSingleton = new TrivialExecService();
// return theSingleton;
// }
//
// public Process run(List<String> cmd, List<String> removeEnv,
// Map<String, String> environmentVariables)
// throws IOException
// {
// System.err.println("templeton: starting " + cmd);
// System.err.print("With environment variables: " );
// for(Map.Entry<String, String> keyVal : environmentVariables.entrySet()){
// System.err.println(keyVal.getKey() + "=" + keyVal.getValue());
// }
// ProcessBuilder pb = new ProcessBuilder(cmd);
// for (String key : removeEnv)
// pb.environment().remove(key);
// pb.environment().putAll(environmentVariables);
// return pb.start();
// }
//
// }
// Path: src/test/org/apache/hcatalog/templeton/test/tool/TrivialExecServiceTest.java
import static org.junit.Assert.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import org.apache.hcatalog.templeton.tool.TrivialExecService;
import org.junit.Test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hcatalog.templeton.test.tool;
public class TrivialExecServiceTest {
@Test
public void test() {
ArrayList<String> list = new ArrayList<String>();
list.add("echo");
list.add("success");
BufferedReader out = null;
BufferedReader err = null;
try { | Process process = TrivialExecService.getInstance() |
hortonworks/templeton | src/java/org/apache/hcatalog/templeton/tool/HDFSCleanup.java | // Path: src/java/org/apache/hcatalog/templeton/tool/TempletonStorage.java
// public enum Type {
// UNKNOWN, JOB, JOBTRACKING, TEMPLETONOVERHEAD
// }
| import java.io.IOException;
import java.util.Date;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hcatalog.templeton.tool.TempletonStorage.Type;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; | fs = FileSystem.get(appConf);
}
checkFiles(fs);
} catch (Exception e) {
LOG.error("Cleanup cycle failed: " + e.getMessage());
}
long sleepMillis = (long) (Math.random() * interval);
LOG.info("Next execution: " + new Date(new Date().getTime()
+ sleepMillis));
Thread.sleep(sleepMillis);
} catch (Exception e) {
// If sleep fails, we should exit now before things get worse.
isRunning = false;
LOG.error("Cleanup failed: " + e.getMessage(), e);
}
}
isRunning = false;
}
/**
* Loop through all the files, deleting any that are older than
* maxage.
*
* @param fs
* @throws IOException
*/
private void checkFiles(FileSystem fs) throws IOException {
long now = new Date().getTime(); | // Path: src/java/org/apache/hcatalog/templeton/tool/TempletonStorage.java
// public enum Type {
// UNKNOWN, JOB, JOBTRACKING, TEMPLETONOVERHEAD
// }
// Path: src/java/org/apache/hcatalog/templeton/tool/HDFSCleanup.java
import java.io.IOException;
import java.util.Date;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hcatalog.templeton.tool.TempletonStorage.Type;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
fs = FileSystem.get(appConf);
}
checkFiles(fs);
} catch (Exception e) {
LOG.error("Cleanup cycle failed: " + e.getMessage());
}
long sleepMillis = (long) (Math.random() * interval);
LOG.info("Next execution: " + new Date(new Date().getTime()
+ sleepMillis));
Thread.sleep(sleepMillis);
} catch (Exception e) {
// If sleep fails, we should exit now before things get worse.
isRunning = false;
LOG.error("Cleanup failed: " + e.getMessage(), e);
}
}
isRunning = false;
}
/**
* Loop through all the files, deleting any that are older than
* maxage.
*
* @param fs
* @throws IOException
*/
private void checkFiles(FileSystem fs) throws IOException {
long now = new Date().getTime(); | for (Type type : Type.values()) { |
flaxsearch/hackday | ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/resources/EntityExtractor.java | // Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/api/StanfordData.java
// public class StanfordData {
//
// @JsonProperty("entities")
// private final Map<String, List<String>> entities;
// @JsonProperty("sentiment")
// private final Sentiment sentiment;
//
// public StanfordData(Map<String, List<String>> entities, Sentiment sentiment) {
// this.entities = entities;
// this.sentiment = sentiment;
// }
//
// /**
// * @return the entities
// */
// public Map<String, List<String>> getEntities() {
// return entities;
// }
//
// /**
// * @return the sentiment
// */
// public Sentiment getSentiment() {
// return sentiment;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/api/StanfordRequest.java
// public class StanfordRequest {
//
// @JsonProperty("text")
// private String text;
//
// public void setText(String t) {
// this.text = t;
// }
//
// public String getText() {
// return text;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/services/EntityExtractionService.java
// public class EntityExtractionService {
//
// /**
// * Regular expression for recognising entities. These are XML, of the form
// * <EntityType>value</EntityType>.
// */
// private static final Pattern ENTITY_REGEX = Pattern.compile("<(\\w+)>([^<]+)</.*?>");
//
// /**
// * The maximum number of words that should make an entity. Stanford sometimes matches
// * large strings, and this should be restricted.
// */
// private static final int MAX_ENTITY_WORDS = 4;
//
// private final CRFClassifier<CoreLabel> classifier;
//
// public EntityExtractionService(StanfordConfiguration config) {
// // Create a Stanford classifier
// this.classifier = new CRFClassifier<CoreLabel>(config.getJavaEntityProperties());
//
// String classifierPath = config.getEntityProperties().get("loadClassifier");
// // Load the classifier explicitly from the jar file... this is not done by default,
// // and the loadClassifier property above doesn't appear to do anything.
// classifier.loadJarClassifier(classifierPath, config.getJavaEntityProperties());
// }
//
// /**
// * Extract a map of entities from an incoming text string.
// * @param text the text to be analysed.
// * @return a map of entity type -> the list of entities, extracted from the
// * given text.
// */
// public Map<String, List<String>> getEntities(String text) {
// Map<String, List<String>> retMap = new HashMap<String, List<String>>();
// Set<Entity> entities = extractEntities(text);
//
// for (Entity entity : entities) {
// String field = entity.getFieldName();
// if (!retMap.containsKey(field)) {
// retMap.put(field, new ArrayList<String>());
// }
// retMap.get(field).add(entity.getValue());
// }
//
// return retMap;
// }
//
// /**
// * Extract the entities from a text block and return them.
// * @param text the text to be processed.
// * @return a set of entities in the text. Never <code>null</code>.
// */
// private Set<Entity> extractEntities(String text) {
// Set<Entity> entityList = new HashSet<Entity>();
//
// if (StringUtils.isNotBlank(text)) {
// // Classify with inline XML - this will group multi-word entities, such
// // as people's names
// String classified = classifier.classifyWithInlineXML(text);
//
// // Use a regex to extract the entities from the classifed XML - nasty, but quicker
// // than transforming to an actual XML document.
// Matcher m = ENTITY_REGEX.matcher(classified);
// while (m.find()) {
// String type = m.group(1);
// String value = m.group(2);
//
// // Restrict the number of words that can make up an entity value
// if (value.split("\\s+").length <= MAX_ENTITY_WORDS) {
// Entity entity = new Entity(type, value);
// entityList.add(entity);
// }
// }
// }
//
// return entityList;
// }
//
// }
| import java.util.List;
import java.util.Map;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import uk.co.flax.ukmp.api.StanfordData;
import uk.co.flax.ukmp.api.StanfordRequest;
import uk.co.flax.ukmp.services.EntityExtractionService; | /**
* Copyright (c) 2013 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp.resources;
/**
* Resource handling entity extraction - pass in text, returns a list of
* entities.
*/
@Path("/entityExtractor")
public class EntityExtractor {
| // Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/api/StanfordData.java
// public class StanfordData {
//
// @JsonProperty("entities")
// private final Map<String, List<String>> entities;
// @JsonProperty("sentiment")
// private final Sentiment sentiment;
//
// public StanfordData(Map<String, List<String>> entities, Sentiment sentiment) {
// this.entities = entities;
// this.sentiment = sentiment;
// }
//
// /**
// * @return the entities
// */
// public Map<String, List<String>> getEntities() {
// return entities;
// }
//
// /**
// * @return the sentiment
// */
// public Sentiment getSentiment() {
// return sentiment;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/api/StanfordRequest.java
// public class StanfordRequest {
//
// @JsonProperty("text")
// private String text;
//
// public void setText(String t) {
// this.text = t;
// }
//
// public String getText() {
// return text;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/services/EntityExtractionService.java
// public class EntityExtractionService {
//
// /**
// * Regular expression for recognising entities. These are XML, of the form
// * <EntityType>value</EntityType>.
// */
// private static final Pattern ENTITY_REGEX = Pattern.compile("<(\\w+)>([^<]+)</.*?>");
//
// /**
// * The maximum number of words that should make an entity. Stanford sometimes matches
// * large strings, and this should be restricted.
// */
// private static final int MAX_ENTITY_WORDS = 4;
//
// private final CRFClassifier<CoreLabel> classifier;
//
// public EntityExtractionService(StanfordConfiguration config) {
// // Create a Stanford classifier
// this.classifier = new CRFClassifier<CoreLabel>(config.getJavaEntityProperties());
//
// String classifierPath = config.getEntityProperties().get("loadClassifier");
// // Load the classifier explicitly from the jar file... this is not done by default,
// // and the loadClassifier property above doesn't appear to do anything.
// classifier.loadJarClassifier(classifierPath, config.getJavaEntityProperties());
// }
//
// /**
// * Extract a map of entities from an incoming text string.
// * @param text the text to be analysed.
// * @return a map of entity type -> the list of entities, extracted from the
// * given text.
// */
// public Map<String, List<String>> getEntities(String text) {
// Map<String, List<String>> retMap = new HashMap<String, List<String>>();
// Set<Entity> entities = extractEntities(text);
//
// for (Entity entity : entities) {
// String field = entity.getFieldName();
// if (!retMap.containsKey(field)) {
// retMap.put(field, new ArrayList<String>());
// }
// retMap.get(field).add(entity.getValue());
// }
//
// return retMap;
// }
//
// /**
// * Extract the entities from a text block and return them.
// * @param text the text to be processed.
// * @return a set of entities in the text. Never <code>null</code>.
// */
// private Set<Entity> extractEntities(String text) {
// Set<Entity> entityList = new HashSet<Entity>();
//
// if (StringUtils.isNotBlank(text)) {
// // Classify with inline XML - this will group multi-word entities, such
// // as people's names
// String classified = classifier.classifyWithInlineXML(text);
//
// // Use a regex to extract the entities from the classifed XML - nasty, but quicker
// // than transforming to an actual XML document.
// Matcher m = ENTITY_REGEX.matcher(classified);
// while (m.find()) {
// String type = m.group(1);
// String value = m.group(2);
//
// // Restrict the number of words that can make up an entity value
// if (value.split("\\s+").length <= MAX_ENTITY_WORDS) {
// Entity entity = new Entity(type, value);
// entityList.add(entity);
// }
// }
// }
//
// return entityList;
// }
//
// }
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/resources/EntityExtractor.java
import java.util.List;
import java.util.Map;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import uk.co.flax.ukmp.api.StanfordData;
import uk.co.flax.ukmp.api.StanfordRequest;
import uk.co.flax.ukmp.services.EntityExtractionService;
/**
* Copyright (c) 2013 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp.resources;
/**
* Resource handling entity extraction - pass in text, returns a list of
* entities.
*/
@Path("/entityExtractor")
public class EntityExtractor {
| private final EntityExtractionService entityService; |
flaxsearch/hackday | ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/resources/EntityExtractor.java | // Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/api/StanfordData.java
// public class StanfordData {
//
// @JsonProperty("entities")
// private final Map<String, List<String>> entities;
// @JsonProperty("sentiment")
// private final Sentiment sentiment;
//
// public StanfordData(Map<String, List<String>> entities, Sentiment sentiment) {
// this.entities = entities;
// this.sentiment = sentiment;
// }
//
// /**
// * @return the entities
// */
// public Map<String, List<String>> getEntities() {
// return entities;
// }
//
// /**
// * @return the sentiment
// */
// public Sentiment getSentiment() {
// return sentiment;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/api/StanfordRequest.java
// public class StanfordRequest {
//
// @JsonProperty("text")
// private String text;
//
// public void setText(String t) {
// this.text = t;
// }
//
// public String getText() {
// return text;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/services/EntityExtractionService.java
// public class EntityExtractionService {
//
// /**
// * Regular expression for recognising entities. These are XML, of the form
// * <EntityType>value</EntityType>.
// */
// private static final Pattern ENTITY_REGEX = Pattern.compile("<(\\w+)>([^<]+)</.*?>");
//
// /**
// * The maximum number of words that should make an entity. Stanford sometimes matches
// * large strings, and this should be restricted.
// */
// private static final int MAX_ENTITY_WORDS = 4;
//
// private final CRFClassifier<CoreLabel> classifier;
//
// public EntityExtractionService(StanfordConfiguration config) {
// // Create a Stanford classifier
// this.classifier = new CRFClassifier<CoreLabel>(config.getJavaEntityProperties());
//
// String classifierPath = config.getEntityProperties().get("loadClassifier");
// // Load the classifier explicitly from the jar file... this is not done by default,
// // and the loadClassifier property above doesn't appear to do anything.
// classifier.loadJarClassifier(classifierPath, config.getJavaEntityProperties());
// }
//
// /**
// * Extract a map of entities from an incoming text string.
// * @param text the text to be analysed.
// * @return a map of entity type -> the list of entities, extracted from the
// * given text.
// */
// public Map<String, List<String>> getEntities(String text) {
// Map<String, List<String>> retMap = new HashMap<String, List<String>>();
// Set<Entity> entities = extractEntities(text);
//
// for (Entity entity : entities) {
// String field = entity.getFieldName();
// if (!retMap.containsKey(field)) {
// retMap.put(field, new ArrayList<String>());
// }
// retMap.get(field).add(entity.getValue());
// }
//
// return retMap;
// }
//
// /**
// * Extract the entities from a text block and return them.
// * @param text the text to be processed.
// * @return a set of entities in the text. Never <code>null</code>.
// */
// private Set<Entity> extractEntities(String text) {
// Set<Entity> entityList = new HashSet<Entity>();
//
// if (StringUtils.isNotBlank(text)) {
// // Classify with inline XML - this will group multi-word entities, such
// // as people's names
// String classified = classifier.classifyWithInlineXML(text);
//
// // Use a regex to extract the entities from the classifed XML - nasty, but quicker
// // than transforming to an actual XML document.
// Matcher m = ENTITY_REGEX.matcher(classified);
// while (m.find()) {
// String type = m.group(1);
// String value = m.group(2);
//
// // Restrict the number of words that can make up an entity value
// if (value.split("\\s+").length <= MAX_ENTITY_WORDS) {
// Entity entity = new Entity(type, value);
// entityList.add(entity);
// }
// }
// }
//
// return entityList;
// }
//
// }
| import java.util.List;
import java.util.Map;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import uk.co.flax.ukmp.api.StanfordData;
import uk.co.flax.ukmp.api.StanfordRequest;
import uk.co.flax.ukmp.services.EntityExtractionService; | /**
* Copyright (c) 2013 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp.resources;
/**
* Resource handling entity extraction - pass in text, returns a list of
* entities.
*/
@Path("/entityExtractor")
public class EntityExtractor {
private final EntityExtractionService entityService;
public EntityExtractor(EntityExtractionService entityService) {
this.entityService = entityService;
}
@POST
@Produces(MediaType.APPLICATION_JSON) | // Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/api/StanfordData.java
// public class StanfordData {
//
// @JsonProperty("entities")
// private final Map<String, List<String>> entities;
// @JsonProperty("sentiment")
// private final Sentiment sentiment;
//
// public StanfordData(Map<String, List<String>> entities, Sentiment sentiment) {
// this.entities = entities;
// this.sentiment = sentiment;
// }
//
// /**
// * @return the entities
// */
// public Map<String, List<String>> getEntities() {
// return entities;
// }
//
// /**
// * @return the sentiment
// */
// public Sentiment getSentiment() {
// return sentiment;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/api/StanfordRequest.java
// public class StanfordRequest {
//
// @JsonProperty("text")
// private String text;
//
// public void setText(String t) {
// this.text = t;
// }
//
// public String getText() {
// return text;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/services/EntityExtractionService.java
// public class EntityExtractionService {
//
// /**
// * Regular expression for recognising entities. These are XML, of the form
// * <EntityType>value</EntityType>.
// */
// private static final Pattern ENTITY_REGEX = Pattern.compile("<(\\w+)>([^<]+)</.*?>");
//
// /**
// * The maximum number of words that should make an entity. Stanford sometimes matches
// * large strings, and this should be restricted.
// */
// private static final int MAX_ENTITY_WORDS = 4;
//
// private final CRFClassifier<CoreLabel> classifier;
//
// public EntityExtractionService(StanfordConfiguration config) {
// // Create a Stanford classifier
// this.classifier = new CRFClassifier<CoreLabel>(config.getJavaEntityProperties());
//
// String classifierPath = config.getEntityProperties().get("loadClassifier");
// // Load the classifier explicitly from the jar file... this is not done by default,
// // and the loadClassifier property above doesn't appear to do anything.
// classifier.loadJarClassifier(classifierPath, config.getJavaEntityProperties());
// }
//
// /**
// * Extract a map of entities from an incoming text string.
// * @param text the text to be analysed.
// * @return a map of entity type -> the list of entities, extracted from the
// * given text.
// */
// public Map<String, List<String>> getEntities(String text) {
// Map<String, List<String>> retMap = new HashMap<String, List<String>>();
// Set<Entity> entities = extractEntities(text);
//
// for (Entity entity : entities) {
// String field = entity.getFieldName();
// if (!retMap.containsKey(field)) {
// retMap.put(field, new ArrayList<String>());
// }
// retMap.get(field).add(entity.getValue());
// }
//
// return retMap;
// }
//
// /**
// * Extract the entities from a text block and return them.
// * @param text the text to be processed.
// * @return a set of entities in the text. Never <code>null</code>.
// */
// private Set<Entity> extractEntities(String text) {
// Set<Entity> entityList = new HashSet<Entity>();
//
// if (StringUtils.isNotBlank(text)) {
// // Classify with inline XML - this will group multi-word entities, such
// // as people's names
// String classified = classifier.classifyWithInlineXML(text);
//
// // Use a regex to extract the entities from the classifed XML - nasty, but quicker
// // than transforming to an actual XML document.
// Matcher m = ENTITY_REGEX.matcher(classified);
// while (m.find()) {
// String type = m.group(1);
// String value = m.group(2);
//
// // Restrict the number of words that can make up an entity value
// if (value.split("\\s+").length <= MAX_ENTITY_WORDS) {
// Entity entity = new Entity(type, value);
// entityList.add(entity);
// }
// }
// }
//
// return entityList;
// }
//
// }
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/resources/EntityExtractor.java
import java.util.List;
import java.util.Map;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import uk.co.flax.ukmp.api.StanfordData;
import uk.co.flax.ukmp.api.StanfordRequest;
import uk.co.flax.ukmp.services.EntityExtractionService;
/**
* Copyright (c) 2013 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp.resources;
/**
* Resource handling entity extraction - pass in text, returns a list of
* entities.
*/
@Path("/entityExtractor")
public class EntityExtractor {
private final EntityExtractionService entityService;
public EntityExtractor(EntityExtractionService entityService) {
this.entityService = entityService;
}
@POST
@Produces(MediaType.APPLICATION_JSON) | public StanfordData handlePost(StanfordRequest req) { |
flaxsearch/hackday | ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/resources/EntityExtractor.java | // Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/api/StanfordData.java
// public class StanfordData {
//
// @JsonProperty("entities")
// private final Map<String, List<String>> entities;
// @JsonProperty("sentiment")
// private final Sentiment sentiment;
//
// public StanfordData(Map<String, List<String>> entities, Sentiment sentiment) {
// this.entities = entities;
// this.sentiment = sentiment;
// }
//
// /**
// * @return the entities
// */
// public Map<String, List<String>> getEntities() {
// return entities;
// }
//
// /**
// * @return the sentiment
// */
// public Sentiment getSentiment() {
// return sentiment;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/api/StanfordRequest.java
// public class StanfordRequest {
//
// @JsonProperty("text")
// private String text;
//
// public void setText(String t) {
// this.text = t;
// }
//
// public String getText() {
// return text;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/services/EntityExtractionService.java
// public class EntityExtractionService {
//
// /**
// * Regular expression for recognising entities. These are XML, of the form
// * <EntityType>value</EntityType>.
// */
// private static final Pattern ENTITY_REGEX = Pattern.compile("<(\\w+)>([^<]+)</.*?>");
//
// /**
// * The maximum number of words that should make an entity. Stanford sometimes matches
// * large strings, and this should be restricted.
// */
// private static final int MAX_ENTITY_WORDS = 4;
//
// private final CRFClassifier<CoreLabel> classifier;
//
// public EntityExtractionService(StanfordConfiguration config) {
// // Create a Stanford classifier
// this.classifier = new CRFClassifier<CoreLabel>(config.getJavaEntityProperties());
//
// String classifierPath = config.getEntityProperties().get("loadClassifier");
// // Load the classifier explicitly from the jar file... this is not done by default,
// // and the loadClassifier property above doesn't appear to do anything.
// classifier.loadJarClassifier(classifierPath, config.getJavaEntityProperties());
// }
//
// /**
// * Extract a map of entities from an incoming text string.
// * @param text the text to be analysed.
// * @return a map of entity type -> the list of entities, extracted from the
// * given text.
// */
// public Map<String, List<String>> getEntities(String text) {
// Map<String, List<String>> retMap = new HashMap<String, List<String>>();
// Set<Entity> entities = extractEntities(text);
//
// for (Entity entity : entities) {
// String field = entity.getFieldName();
// if (!retMap.containsKey(field)) {
// retMap.put(field, new ArrayList<String>());
// }
// retMap.get(field).add(entity.getValue());
// }
//
// return retMap;
// }
//
// /**
// * Extract the entities from a text block and return them.
// * @param text the text to be processed.
// * @return a set of entities in the text. Never <code>null</code>.
// */
// private Set<Entity> extractEntities(String text) {
// Set<Entity> entityList = new HashSet<Entity>();
//
// if (StringUtils.isNotBlank(text)) {
// // Classify with inline XML - this will group multi-word entities, such
// // as people's names
// String classified = classifier.classifyWithInlineXML(text);
//
// // Use a regex to extract the entities from the classifed XML - nasty, but quicker
// // than transforming to an actual XML document.
// Matcher m = ENTITY_REGEX.matcher(classified);
// while (m.find()) {
// String type = m.group(1);
// String value = m.group(2);
//
// // Restrict the number of words that can make up an entity value
// if (value.split("\\s+").length <= MAX_ENTITY_WORDS) {
// Entity entity = new Entity(type, value);
// entityList.add(entity);
// }
// }
// }
//
// return entityList;
// }
//
// }
| import java.util.List;
import java.util.Map;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import uk.co.flax.ukmp.api.StanfordData;
import uk.co.flax.ukmp.api.StanfordRequest;
import uk.co.flax.ukmp.services.EntityExtractionService; | /**
* Copyright (c) 2013 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp.resources;
/**
* Resource handling entity extraction - pass in text, returns a list of
* entities.
*/
@Path("/entityExtractor")
public class EntityExtractor {
private final EntityExtractionService entityService;
public EntityExtractor(EntityExtractionService entityService) {
this.entityService = entityService;
}
@POST
@Produces(MediaType.APPLICATION_JSON) | // Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/api/StanfordData.java
// public class StanfordData {
//
// @JsonProperty("entities")
// private final Map<String, List<String>> entities;
// @JsonProperty("sentiment")
// private final Sentiment sentiment;
//
// public StanfordData(Map<String, List<String>> entities, Sentiment sentiment) {
// this.entities = entities;
// this.sentiment = sentiment;
// }
//
// /**
// * @return the entities
// */
// public Map<String, List<String>> getEntities() {
// return entities;
// }
//
// /**
// * @return the sentiment
// */
// public Sentiment getSentiment() {
// return sentiment;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/api/StanfordRequest.java
// public class StanfordRequest {
//
// @JsonProperty("text")
// private String text;
//
// public void setText(String t) {
// this.text = t;
// }
//
// public String getText() {
// return text;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/services/EntityExtractionService.java
// public class EntityExtractionService {
//
// /**
// * Regular expression for recognising entities. These are XML, of the form
// * <EntityType>value</EntityType>.
// */
// private static final Pattern ENTITY_REGEX = Pattern.compile("<(\\w+)>([^<]+)</.*?>");
//
// /**
// * The maximum number of words that should make an entity. Stanford sometimes matches
// * large strings, and this should be restricted.
// */
// private static final int MAX_ENTITY_WORDS = 4;
//
// private final CRFClassifier<CoreLabel> classifier;
//
// public EntityExtractionService(StanfordConfiguration config) {
// // Create a Stanford classifier
// this.classifier = new CRFClassifier<CoreLabel>(config.getJavaEntityProperties());
//
// String classifierPath = config.getEntityProperties().get("loadClassifier");
// // Load the classifier explicitly from the jar file... this is not done by default,
// // and the loadClassifier property above doesn't appear to do anything.
// classifier.loadJarClassifier(classifierPath, config.getJavaEntityProperties());
// }
//
// /**
// * Extract a map of entities from an incoming text string.
// * @param text the text to be analysed.
// * @return a map of entity type -> the list of entities, extracted from the
// * given text.
// */
// public Map<String, List<String>> getEntities(String text) {
// Map<String, List<String>> retMap = new HashMap<String, List<String>>();
// Set<Entity> entities = extractEntities(text);
//
// for (Entity entity : entities) {
// String field = entity.getFieldName();
// if (!retMap.containsKey(field)) {
// retMap.put(field, new ArrayList<String>());
// }
// retMap.get(field).add(entity.getValue());
// }
//
// return retMap;
// }
//
// /**
// * Extract the entities from a text block and return them.
// * @param text the text to be processed.
// * @return a set of entities in the text. Never <code>null</code>.
// */
// private Set<Entity> extractEntities(String text) {
// Set<Entity> entityList = new HashSet<Entity>();
//
// if (StringUtils.isNotBlank(text)) {
// // Classify with inline XML - this will group multi-word entities, such
// // as people's names
// String classified = classifier.classifyWithInlineXML(text);
//
// // Use a regex to extract the entities from the classifed XML - nasty, but quicker
// // than transforming to an actual XML document.
// Matcher m = ENTITY_REGEX.matcher(classified);
// while (m.find()) {
// String type = m.group(1);
// String value = m.group(2);
//
// // Restrict the number of words that can make up an entity value
// if (value.split("\\s+").length <= MAX_ENTITY_WORDS) {
// Entity entity = new Entity(type, value);
// entityList.add(entity);
// }
// }
// }
//
// return entityList;
// }
//
// }
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/resources/EntityExtractor.java
import java.util.List;
import java.util.Map;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import uk.co.flax.ukmp.api.StanfordData;
import uk.co.flax.ukmp.api.StanfordRequest;
import uk.co.flax.ukmp.services.EntityExtractionService;
/**
* Copyright (c) 2013 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp.resources;
/**
* Resource handling entity extraction - pass in text, returns a list of
* entities.
*/
@Path("/entityExtractor")
public class EntityExtractor {
private final EntityExtractionService entityService;
public EntityExtractor(EntityExtractionService entityService) {
this.entityService = entityService;
}
@POST
@Produces(MediaType.APPLICATION_JSON) | public StanfordData handlePost(StanfordRequest req) { |
flaxsearch/hackday | ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/twitter/TwitterListManager.java | // Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/TwitterConfiguration.java
// public class TwitterConfiguration {
//
// private String authConfigFile;
//
// private int deletionBatchSize = 50;
//
// private int statusBatchSize = 100;
//
// private boolean enabled;
//
// private List<TwitterListConfiguration> lists;
//
// private int updateCheckHours;
//
// @NotNull
// private String dataDirectory;
//
// public boolean isEnabled() {
// return enabled;
// }
//
// public String getAuthConfigFile() {
// return authConfigFile;
// }
//
// public int getDeletionBatchSize() {
// return deletionBatchSize;
// }
//
// public int getStatusBatchSize() {
// return statusBatchSize;
// }
//
// public List<TwitterListConfiguration> getLists() {
// return lists;
// }
//
// public int getUpdateCheckHours() {
// return updateCheckHours;
// }
//
// /**
// * @return the dataDirectory
// */
// public String getDataDirectory() {
// return dataDirectory;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/TwitterListConfiguration.java
// public class TwitterListConfiguration {
//
// private String screenName;
//
// private String slug;
//
// private String displayName;
//
// public String getScreenName() {
// return screenName;
// }
//
// public String getSlug() {
// return slug;
// }
//
// /**
// * @return the displayName
// */
// public String getDisplayName() {
// return displayName;
// }
//
// }
| import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.User;
import twitter4j.conf.Configuration;
import uk.co.flax.ukmp.config.TwitterConfiguration;
import uk.co.flax.ukmp.config.TwitterListConfiguration;
import io.dropwizard.lifecycle.Managed;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import twitter4j.PagableResponseList;
import twitter4j.Twitter; | /**
* Copyright (c) 2015 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp.twitter;
/**
* Manager class for keeping track of twitter lists.
*
* @author Matt Pearce
*/
public class TwitterListManager extends AbstractTwitterClient implements Managed {
private static final Logger LOGGER = LoggerFactory.getLogger(TwitterListManager.class);
| // Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/TwitterConfiguration.java
// public class TwitterConfiguration {
//
// private String authConfigFile;
//
// private int deletionBatchSize = 50;
//
// private int statusBatchSize = 100;
//
// private boolean enabled;
//
// private List<TwitterListConfiguration> lists;
//
// private int updateCheckHours;
//
// @NotNull
// private String dataDirectory;
//
// public boolean isEnabled() {
// return enabled;
// }
//
// public String getAuthConfigFile() {
// return authConfigFile;
// }
//
// public int getDeletionBatchSize() {
// return deletionBatchSize;
// }
//
// public int getStatusBatchSize() {
// return statusBatchSize;
// }
//
// public List<TwitterListConfiguration> getLists() {
// return lists;
// }
//
// public int getUpdateCheckHours() {
// return updateCheckHours;
// }
//
// /**
// * @return the dataDirectory
// */
// public String getDataDirectory() {
// return dataDirectory;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/TwitterListConfiguration.java
// public class TwitterListConfiguration {
//
// private String screenName;
//
// private String slug;
//
// private String displayName;
//
// public String getScreenName() {
// return screenName;
// }
//
// public String getSlug() {
// return slug;
// }
//
// /**
// * @return the displayName
// */
// public String getDisplayName() {
// return displayName;
// }
//
// }
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/twitter/TwitterListManager.java
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.User;
import twitter4j.conf.Configuration;
import uk.co.flax.ukmp.config.TwitterConfiguration;
import uk.co.flax.ukmp.config.TwitterListConfiguration;
import io.dropwizard.lifecycle.Managed;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import twitter4j.PagableResponseList;
import twitter4j.Twitter;
/**
* Copyright (c) 2015 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp.twitter;
/**
* Manager class for keeping track of twitter lists.
*
* @author Matt Pearce
*/
public class TwitterListManager extends AbstractTwitterClient implements Managed {
private static final Logger LOGGER = LoggerFactory.getLogger(TwitterListManager.class);
| private final TwitterConfiguration config; |
flaxsearch/hackday | ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/twitter/TwitterListManager.java | // Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/TwitterConfiguration.java
// public class TwitterConfiguration {
//
// private String authConfigFile;
//
// private int deletionBatchSize = 50;
//
// private int statusBatchSize = 100;
//
// private boolean enabled;
//
// private List<TwitterListConfiguration> lists;
//
// private int updateCheckHours;
//
// @NotNull
// private String dataDirectory;
//
// public boolean isEnabled() {
// return enabled;
// }
//
// public String getAuthConfigFile() {
// return authConfigFile;
// }
//
// public int getDeletionBatchSize() {
// return deletionBatchSize;
// }
//
// public int getStatusBatchSize() {
// return statusBatchSize;
// }
//
// public List<TwitterListConfiguration> getLists() {
// return lists;
// }
//
// public int getUpdateCheckHours() {
// return updateCheckHours;
// }
//
// /**
// * @return the dataDirectory
// */
// public String getDataDirectory() {
// return dataDirectory;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/TwitterListConfiguration.java
// public class TwitterListConfiguration {
//
// private String screenName;
//
// private String slug;
//
// private String displayName;
//
// public String getScreenName() {
// return screenName;
// }
//
// public String getSlug() {
// return slug;
// }
//
// /**
// * @return the displayName
// */
// public String getDisplayName() {
// return displayName;
// }
//
// }
| import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.User;
import twitter4j.conf.Configuration;
import uk.co.flax.ukmp.config.TwitterConfiguration;
import uk.co.flax.ukmp.config.TwitterListConfiguration;
import io.dropwizard.lifecycle.Managed;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import twitter4j.PagableResponseList;
import twitter4j.Twitter; | public void registerListener(TwitterListListener listener) {
listeners.add(listener);
}
private void notifyListeners() {
listeners.forEach(listener -> listener.notify(twitterLists));
}
private class ListUpdateThread extends Thread {
private boolean running;
private Twitter twitter;
ListUpdateThread(Twitter twitter) {
this.twitter = twitter;
}
void shutdown() {
this.running = false;
}
@Override
public void run() {
LOGGER.info("Starting list update thread");
long lastUpdate = 0;
running = true;
while (running) {
if (System.currentTimeMillis() - sleepTime > lastUpdate) {
// Update the lists | // Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/TwitterConfiguration.java
// public class TwitterConfiguration {
//
// private String authConfigFile;
//
// private int deletionBatchSize = 50;
//
// private int statusBatchSize = 100;
//
// private boolean enabled;
//
// private List<TwitterListConfiguration> lists;
//
// private int updateCheckHours;
//
// @NotNull
// private String dataDirectory;
//
// public boolean isEnabled() {
// return enabled;
// }
//
// public String getAuthConfigFile() {
// return authConfigFile;
// }
//
// public int getDeletionBatchSize() {
// return deletionBatchSize;
// }
//
// public int getStatusBatchSize() {
// return statusBatchSize;
// }
//
// public List<TwitterListConfiguration> getLists() {
// return lists;
// }
//
// public int getUpdateCheckHours() {
// return updateCheckHours;
// }
//
// /**
// * @return the dataDirectory
// */
// public String getDataDirectory() {
// return dataDirectory;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/TwitterListConfiguration.java
// public class TwitterListConfiguration {
//
// private String screenName;
//
// private String slug;
//
// private String displayName;
//
// public String getScreenName() {
// return screenName;
// }
//
// public String getSlug() {
// return slug;
// }
//
// /**
// * @return the displayName
// */
// public String getDisplayName() {
// return displayName;
// }
//
// }
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/twitter/TwitterListManager.java
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.User;
import twitter4j.conf.Configuration;
import uk.co.flax.ukmp.config.TwitterConfiguration;
import uk.co.flax.ukmp.config.TwitterListConfiguration;
import io.dropwizard.lifecycle.Managed;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import twitter4j.PagableResponseList;
import twitter4j.Twitter;
public void registerListener(TwitterListListener listener) {
listeners.add(listener);
}
private void notifyListeners() {
listeners.forEach(listener -> listener.notify(twitterLists));
}
private class ListUpdateThread extends Thread {
private boolean running;
private Twitter twitter;
ListUpdateThread(Twitter twitter) {
this.twitter = twitter;
}
void shutdown() {
this.running = false;
}
@Override
public void run() {
LOGGER.info("Starting list update thread");
long lastUpdate = 0;
running = true;
while (running) {
if (System.currentTimeMillis() - sleepTime > lastUpdate) {
// Update the lists | for (TwitterListConfiguration listConfig : config.getLists()) { |
flaxsearch/hackday | ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/UKMPConfiguration.java | // Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/SolrConfiguration.java
// public class SolrConfiguration {
//
// @Valid @NotNull
// private String baseUrl;
//
// @Valid @NotNull
// private String queryHandler;
//
// private Map<String, String> facetLabels;
//
// private Map<String, Map<String, String>> facetQueryFields;
//
// @JsonProperty("terms")
// private TermsConfiguration termsConfiguration;
//
// /**
// * @return the baseUrl
// */
// public String getBaseUrl() {
// return baseUrl;
// }
//
// /**
// * @return the default query handler to use.
// */
// public String getQueryHandler() {
// return queryHandler;
// }
//
// public Map<String, String> getFacetLabels() {
// return facetLabels;
// }
//
// public Map<String, Map<String, String>> getFacetQueryFields() {
// return facetQueryFields;
// }
//
// public TermsConfiguration getTermsConfiguration() {
// return termsConfiguration;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/StanfordConfiguration.java
// public class StanfordConfiguration {
//
// private static final String NER_CLASSIFIER_PROPERTY = "loadClassifier";
//
// private Map<String, String> entityProperties;
//
// private Map<String, String> sentimentProperties;
//
// /**
// * @return the properties to set for NER.
// */
// public Map<String, String> getEntityProperties() {
// return entityProperties;
// }
//
// /**
// * @return the sentimentProperties
// */
// public Map<String, String> getSentimentProperties() {
// return sentimentProperties;
// }
//
// /**
// * Get the entity properties map as a Java Properties object.
// * @return a Java Properties object containing the properties.
// */
// public Properties getJavaEntityProperties() {
// Properties props = new Properties();
//
// for (String key : entityProperties.keySet()) {
// props.put(key, entityProperties.get(key));
// }
//
// return props;
// }
//
// /**
// * @return the path to the classifier file.
// */
// public String getClassifierFile() {
// return entityProperties.get(NER_CLASSIFIER_PROPERTY);
// }
//
// /**
// * Get the sentiment properties map as a Java Properties object.
// * @return the sentiment properties.
// */
// public Properties getJavaSentimentProperties() {
// Properties props = new Properties();
//
// for (String key : sentimentProperties.keySet()) {
// props.put(key, sentimentProperties.get(key));
// }
//
// return props;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/TwitterConfiguration.java
// public class TwitterConfiguration {
//
// private String authConfigFile;
//
// private int deletionBatchSize = 50;
//
// private int statusBatchSize = 100;
//
// private boolean enabled;
//
// private List<TwitterListConfiguration> lists;
//
// private int updateCheckHours;
//
// @NotNull
// private String dataDirectory;
//
// public boolean isEnabled() {
// return enabled;
// }
//
// public String getAuthConfigFile() {
// return authConfigFile;
// }
//
// public int getDeletionBatchSize() {
// return deletionBatchSize;
// }
//
// public int getStatusBatchSize() {
// return statusBatchSize;
// }
//
// public List<TwitterListConfiguration> getLists() {
// return lists;
// }
//
// public int getUpdateCheckHours() {
// return updateCheckHours;
// }
//
// /**
// * @return the dataDirectory
// */
// public String getDataDirectory() {
// return dataDirectory;
// }
//
// }
| import io.dropwizard.Configuration;
import uk.co.flax.ukmp.config.SolrConfiguration;
import uk.co.flax.ukmp.config.StanfordConfiguration;
import uk.co.flax.ukmp.config.TwitterConfiguration;
import com.fasterxml.jackson.annotation.JsonProperty; | /**
* Copyright (c) 2013 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp;
/**
* Configuration details for the UKMP application/indexer.
*/
public class UKMPConfiguration extends Configuration {
@JsonProperty("solr") | // Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/SolrConfiguration.java
// public class SolrConfiguration {
//
// @Valid @NotNull
// private String baseUrl;
//
// @Valid @NotNull
// private String queryHandler;
//
// private Map<String, String> facetLabels;
//
// private Map<String, Map<String, String>> facetQueryFields;
//
// @JsonProperty("terms")
// private TermsConfiguration termsConfiguration;
//
// /**
// * @return the baseUrl
// */
// public String getBaseUrl() {
// return baseUrl;
// }
//
// /**
// * @return the default query handler to use.
// */
// public String getQueryHandler() {
// return queryHandler;
// }
//
// public Map<String, String> getFacetLabels() {
// return facetLabels;
// }
//
// public Map<String, Map<String, String>> getFacetQueryFields() {
// return facetQueryFields;
// }
//
// public TermsConfiguration getTermsConfiguration() {
// return termsConfiguration;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/StanfordConfiguration.java
// public class StanfordConfiguration {
//
// private static final String NER_CLASSIFIER_PROPERTY = "loadClassifier";
//
// private Map<String, String> entityProperties;
//
// private Map<String, String> sentimentProperties;
//
// /**
// * @return the properties to set for NER.
// */
// public Map<String, String> getEntityProperties() {
// return entityProperties;
// }
//
// /**
// * @return the sentimentProperties
// */
// public Map<String, String> getSentimentProperties() {
// return sentimentProperties;
// }
//
// /**
// * Get the entity properties map as a Java Properties object.
// * @return a Java Properties object containing the properties.
// */
// public Properties getJavaEntityProperties() {
// Properties props = new Properties();
//
// for (String key : entityProperties.keySet()) {
// props.put(key, entityProperties.get(key));
// }
//
// return props;
// }
//
// /**
// * @return the path to the classifier file.
// */
// public String getClassifierFile() {
// return entityProperties.get(NER_CLASSIFIER_PROPERTY);
// }
//
// /**
// * Get the sentiment properties map as a Java Properties object.
// * @return the sentiment properties.
// */
// public Properties getJavaSentimentProperties() {
// Properties props = new Properties();
//
// for (String key : sentimentProperties.keySet()) {
// props.put(key, sentimentProperties.get(key));
// }
//
// return props;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/TwitterConfiguration.java
// public class TwitterConfiguration {
//
// private String authConfigFile;
//
// private int deletionBatchSize = 50;
//
// private int statusBatchSize = 100;
//
// private boolean enabled;
//
// private List<TwitterListConfiguration> lists;
//
// private int updateCheckHours;
//
// @NotNull
// private String dataDirectory;
//
// public boolean isEnabled() {
// return enabled;
// }
//
// public String getAuthConfigFile() {
// return authConfigFile;
// }
//
// public int getDeletionBatchSize() {
// return deletionBatchSize;
// }
//
// public int getStatusBatchSize() {
// return statusBatchSize;
// }
//
// public List<TwitterListConfiguration> getLists() {
// return lists;
// }
//
// public int getUpdateCheckHours() {
// return updateCheckHours;
// }
//
// /**
// * @return the dataDirectory
// */
// public String getDataDirectory() {
// return dataDirectory;
// }
//
// }
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/UKMPConfiguration.java
import io.dropwizard.Configuration;
import uk.co.flax.ukmp.config.SolrConfiguration;
import uk.co.flax.ukmp.config.StanfordConfiguration;
import uk.co.flax.ukmp.config.TwitterConfiguration;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Copyright (c) 2013 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp;
/**
* Configuration details for the UKMP application/indexer.
*/
public class UKMPConfiguration extends Configuration {
@JsonProperty("solr") | private SolrConfiguration solrConfiguration; |
flaxsearch/hackday | ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/UKMPConfiguration.java | // Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/SolrConfiguration.java
// public class SolrConfiguration {
//
// @Valid @NotNull
// private String baseUrl;
//
// @Valid @NotNull
// private String queryHandler;
//
// private Map<String, String> facetLabels;
//
// private Map<String, Map<String, String>> facetQueryFields;
//
// @JsonProperty("terms")
// private TermsConfiguration termsConfiguration;
//
// /**
// * @return the baseUrl
// */
// public String getBaseUrl() {
// return baseUrl;
// }
//
// /**
// * @return the default query handler to use.
// */
// public String getQueryHandler() {
// return queryHandler;
// }
//
// public Map<String, String> getFacetLabels() {
// return facetLabels;
// }
//
// public Map<String, Map<String, String>> getFacetQueryFields() {
// return facetQueryFields;
// }
//
// public TermsConfiguration getTermsConfiguration() {
// return termsConfiguration;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/StanfordConfiguration.java
// public class StanfordConfiguration {
//
// private static final String NER_CLASSIFIER_PROPERTY = "loadClassifier";
//
// private Map<String, String> entityProperties;
//
// private Map<String, String> sentimentProperties;
//
// /**
// * @return the properties to set for NER.
// */
// public Map<String, String> getEntityProperties() {
// return entityProperties;
// }
//
// /**
// * @return the sentimentProperties
// */
// public Map<String, String> getSentimentProperties() {
// return sentimentProperties;
// }
//
// /**
// * Get the entity properties map as a Java Properties object.
// * @return a Java Properties object containing the properties.
// */
// public Properties getJavaEntityProperties() {
// Properties props = new Properties();
//
// for (String key : entityProperties.keySet()) {
// props.put(key, entityProperties.get(key));
// }
//
// return props;
// }
//
// /**
// * @return the path to the classifier file.
// */
// public String getClassifierFile() {
// return entityProperties.get(NER_CLASSIFIER_PROPERTY);
// }
//
// /**
// * Get the sentiment properties map as a Java Properties object.
// * @return the sentiment properties.
// */
// public Properties getJavaSentimentProperties() {
// Properties props = new Properties();
//
// for (String key : sentimentProperties.keySet()) {
// props.put(key, sentimentProperties.get(key));
// }
//
// return props;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/TwitterConfiguration.java
// public class TwitterConfiguration {
//
// private String authConfigFile;
//
// private int deletionBatchSize = 50;
//
// private int statusBatchSize = 100;
//
// private boolean enabled;
//
// private List<TwitterListConfiguration> lists;
//
// private int updateCheckHours;
//
// @NotNull
// private String dataDirectory;
//
// public boolean isEnabled() {
// return enabled;
// }
//
// public String getAuthConfigFile() {
// return authConfigFile;
// }
//
// public int getDeletionBatchSize() {
// return deletionBatchSize;
// }
//
// public int getStatusBatchSize() {
// return statusBatchSize;
// }
//
// public List<TwitterListConfiguration> getLists() {
// return lists;
// }
//
// public int getUpdateCheckHours() {
// return updateCheckHours;
// }
//
// /**
// * @return the dataDirectory
// */
// public String getDataDirectory() {
// return dataDirectory;
// }
//
// }
| import io.dropwizard.Configuration;
import uk.co.flax.ukmp.config.SolrConfiguration;
import uk.co.flax.ukmp.config.StanfordConfiguration;
import uk.co.flax.ukmp.config.TwitterConfiguration;
import com.fasterxml.jackson.annotation.JsonProperty; | /**
* Copyright (c) 2013 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp;
/**
* Configuration details for the UKMP application/indexer.
*/
public class UKMPConfiguration extends Configuration {
@JsonProperty("solr")
private SolrConfiguration solrConfiguration;
@JsonProperty("stanford") | // Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/SolrConfiguration.java
// public class SolrConfiguration {
//
// @Valid @NotNull
// private String baseUrl;
//
// @Valid @NotNull
// private String queryHandler;
//
// private Map<String, String> facetLabels;
//
// private Map<String, Map<String, String>> facetQueryFields;
//
// @JsonProperty("terms")
// private TermsConfiguration termsConfiguration;
//
// /**
// * @return the baseUrl
// */
// public String getBaseUrl() {
// return baseUrl;
// }
//
// /**
// * @return the default query handler to use.
// */
// public String getQueryHandler() {
// return queryHandler;
// }
//
// public Map<String, String> getFacetLabels() {
// return facetLabels;
// }
//
// public Map<String, Map<String, String>> getFacetQueryFields() {
// return facetQueryFields;
// }
//
// public TermsConfiguration getTermsConfiguration() {
// return termsConfiguration;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/StanfordConfiguration.java
// public class StanfordConfiguration {
//
// private static final String NER_CLASSIFIER_PROPERTY = "loadClassifier";
//
// private Map<String, String> entityProperties;
//
// private Map<String, String> sentimentProperties;
//
// /**
// * @return the properties to set for NER.
// */
// public Map<String, String> getEntityProperties() {
// return entityProperties;
// }
//
// /**
// * @return the sentimentProperties
// */
// public Map<String, String> getSentimentProperties() {
// return sentimentProperties;
// }
//
// /**
// * Get the entity properties map as a Java Properties object.
// * @return a Java Properties object containing the properties.
// */
// public Properties getJavaEntityProperties() {
// Properties props = new Properties();
//
// for (String key : entityProperties.keySet()) {
// props.put(key, entityProperties.get(key));
// }
//
// return props;
// }
//
// /**
// * @return the path to the classifier file.
// */
// public String getClassifierFile() {
// return entityProperties.get(NER_CLASSIFIER_PROPERTY);
// }
//
// /**
// * Get the sentiment properties map as a Java Properties object.
// * @return the sentiment properties.
// */
// public Properties getJavaSentimentProperties() {
// Properties props = new Properties();
//
// for (String key : sentimentProperties.keySet()) {
// props.put(key, sentimentProperties.get(key));
// }
//
// return props;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/TwitterConfiguration.java
// public class TwitterConfiguration {
//
// private String authConfigFile;
//
// private int deletionBatchSize = 50;
//
// private int statusBatchSize = 100;
//
// private boolean enabled;
//
// private List<TwitterListConfiguration> lists;
//
// private int updateCheckHours;
//
// @NotNull
// private String dataDirectory;
//
// public boolean isEnabled() {
// return enabled;
// }
//
// public String getAuthConfigFile() {
// return authConfigFile;
// }
//
// public int getDeletionBatchSize() {
// return deletionBatchSize;
// }
//
// public int getStatusBatchSize() {
// return statusBatchSize;
// }
//
// public List<TwitterListConfiguration> getLists() {
// return lists;
// }
//
// public int getUpdateCheckHours() {
// return updateCheckHours;
// }
//
// /**
// * @return the dataDirectory
// */
// public String getDataDirectory() {
// return dataDirectory;
// }
//
// }
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/UKMPConfiguration.java
import io.dropwizard.Configuration;
import uk.co.flax.ukmp.config.SolrConfiguration;
import uk.co.flax.ukmp.config.StanfordConfiguration;
import uk.co.flax.ukmp.config.TwitterConfiguration;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Copyright (c) 2013 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp;
/**
* Configuration details for the UKMP application/indexer.
*/
public class UKMPConfiguration extends Configuration {
@JsonProperty("solr")
private SolrConfiguration solrConfiguration;
@JsonProperty("stanford") | private StanfordConfiguration stanfordConfiguration; |
flaxsearch/hackday | ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/UKMPConfiguration.java | // Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/SolrConfiguration.java
// public class SolrConfiguration {
//
// @Valid @NotNull
// private String baseUrl;
//
// @Valid @NotNull
// private String queryHandler;
//
// private Map<String, String> facetLabels;
//
// private Map<String, Map<String, String>> facetQueryFields;
//
// @JsonProperty("terms")
// private TermsConfiguration termsConfiguration;
//
// /**
// * @return the baseUrl
// */
// public String getBaseUrl() {
// return baseUrl;
// }
//
// /**
// * @return the default query handler to use.
// */
// public String getQueryHandler() {
// return queryHandler;
// }
//
// public Map<String, String> getFacetLabels() {
// return facetLabels;
// }
//
// public Map<String, Map<String, String>> getFacetQueryFields() {
// return facetQueryFields;
// }
//
// public TermsConfiguration getTermsConfiguration() {
// return termsConfiguration;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/StanfordConfiguration.java
// public class StanfordConfiguration {
//
// private static final String NER_CLASSIFIER_PROPERTY = "loadClassifier";
//
// private Map<String, String> entityProperties;
//
// private Map<String, String> sentimentProperties;
//
// /**
// * @return the properties to set for NER.
// */
// public Map<String, String> getEntityProperties() {
// return entityProperties;
// }
//
// /**
// * @return the sentimentProperties
// */
// public Map<String, String> getSentimentProperties() {
// return sentimentProperties;
// }
//
// /**
// * Get the entity properties map as a Java Properties object.
// * @return a Java Properties object containing the properties.
// */
// public Properties getJavaEntityProperties() {
// Properties props = new Properties();
//
// for (String key : entityProperties.keySet()) {
// props.put(key, entityProperties.get(key));
// }
//
// return props;
// }
//
// /**
// * @return the path to the classifier file.
// */
// public String getClassifierFile() {
// return entityProperties.get(NER_CLASSIFIER_PROPERTY);
// }
//
// /**
// * Get the sentiment properties map as a Java Properties object.
// * @return the sentiment properties.
// */
// public Properties getJavaSentimentProperties() {
// Properties props = new Properties();
//
// for (String key : sentimentProperties.keySet()) {
// props.put(key, sentimentProperties.get(key));
// }
//
// return props;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/TwitterConfiguration.java
// public class TwitterConfiguration {
//
// private String authConfigFile;
//
// private int deletionBatchSize = 50;
//
// private int statusBatchSize = 100;
//
// private boolean enabled;
//
// private List<TwitterListConfiguration> lists;
//
// private int updateCheckHours;
//
// @NotNull
// private String dataDirectory;
//
// public boolean isEnabled() {
// return enabled;
// }
//
// public String getAuthConfigFile() {
// return authConfigFile;
// }
//
// public int getDeletionBatchSize() {
// return deletionBatchSize;
// }
//
// public int getStatusBatchSize() {
// return statusBatchSize;
// }
//
// public List<TwitterListConfiguration> getLists() {
// return lists;
// }
//
// public int getUpdateCheckHours() {
// return updateCheckHours;
// }
//
// /**
// * @return the dataDirectory
// */
// public String getDataDirectory() {
// return dataDirectory;
// }
//
// }
| import io.dropwizard.Configuration;
import uk.co.flax.ukmp.config.SolrConfiguration;
import uk.co.flax.ukmp.config.StanfordConfiguration;
import uk.co.flax.ukmp.config.TwitterConfiguration;
import com.fasterxml.jackson.annotation.JsonProperty; | /**
* Copyright (c) 2013 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp;
/**
* Configuration details for the UKMP application/indexer.
*/
public class UKMPConfiguration extends Configuration {
@JsonProperty("solr")
private SolrConfiguration solrConfiguration;
@JsonProperty("stanford")
private StanfordConfiguration stanfordConfiguration;
@JsonProperty("twitter") | // Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/SolrConfiguration.java
// public class SolrConfiguration {
//
// @Valid @NotNull
// private String baseUrl;
//
// @Valid @NotNull
// private String queryHandler;
//
// private Map<String, String> facetLabels;
//
// private Map<String, Map<String, String>> facetQueryFields;
//
// @JsonProperty("terms")
// private TermsConfiguration termsConfiguration;
//
// /**
// * @return the baseUrl
// */
// public String getBaseUrl() {
// return baseUrl;
// }
//
// /**
// * @return the default query handler to use.
// */
// public String getQueryHandler() {
// return queryHandler;
// }
//
// public Map<String, String> getFacetLabels() {
// return facetLabels;
// }
//
// public Map<String, Map<String, String>> getFacetQueryFields() {
// return facetQueryFields;
// }
//
// public TermsConfiguration getTermsConfiguration() {
// return termsConfiguration;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/StanfordConfiguration.java
// public class StanfordConfiguration {
//
// private static final String NER_CLASSIFIER_PROPERTY = "loadClassifier";
//
// private Map<String, String> entityProperties;
//
// private Map<String, String> sentimentProperties;
//
// /**
// * @return the properties to set for NER.
// */
// public Map<String, String> getEntityProperties() {
// return entityProperties;
// }
//
// /**
// * @return the sentimentProperties
// */
// public Map<String, String> getSentimentProperties() {
// return sentimentProperties;
// }
//
// /**
// * Get the entity properties map as a Java Properties object.
// * @return a Java Properties object containing the properties.
// */
// public Properties getJavaEntityProperties() {
// Properties props = new Properties();
//
// for (String key : entityProperties.keySet()) {
// props.put(key, entityProperties.get(key));
// }
//
// return props;
// }
//
// /**
// * @return the path to the classifier file.
// */
// public String getClassifierFile() {
// return entityProperties.get(NER_CLASSIFIER_PROPERTY);
// }
//
// /**
// * Get the sentiment properties map as a Java Properties object.
// * @return the sentiment properties.
// */
// public Properties getJavaSentimentProperties() {
// Properties props = new Properties();
//
// for (String key : sentimentProperties.keySet()) {
// props.put(key, sentimentProperties.get(key));
// }
//
// return props;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/TwitterConfiguration.java
// public class TwitterConfiguration {
//
// private String authConfigFile;
//
// private int deletionBatchSize = 50;
//
// private int statusBatchSize = 100;
//
// private boolean enabled;
//
// private List<TwitterListConfiguration> lists;
//
// private int updateCheckHours;
//
// @NotNull
// private String dataDirectory;
//
// public boolean isEnabled() {
// return enabled;
// }
//
// public String getAuthConfigFile() {
// return authConfigFile;
// }
//
// public int getDeletionBatchSize() {
// return deletionBatchSize;
// }
//
// public int getStatusBatchSize() {
// return statusBatchSize;
// }
//
// public List<TwitterListConfiguration> getLists() {
// return lists;
// }
//
// public int getUpdateCheckHours() {
// return updateCheckHours;
// }
//
// /**
// * @return the dataDirectory
// */
// public String getDataDirectory() {
// return dataDirectory;
// }
//
// }
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/UKMPConfiguration.java
import io.dropwizard.Configuration;
import uk.co.flax.ukmp.config.SolrConfiguration;
import uk.co.flax.ukmp.config.StanfordConfiguration;
import uk.co.flax.ukmp.config.TwitterConfiguration;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Copyright (c) 2013 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp;
/**
* Configuration details for the UKMP application/indexer.
*/
public class UKMPConfiguration extends Configuration {
@JsonProperty("solr")
private SolrConfiguration solrConfiguration;
@JsonProperty("stanford")
private StanfordConfiguration stanfordConfiguration;
@JsonProperty("twitter") | private TwitterConfiguration twitterConfiguration; |
flaxsearch/hackday | ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/services/SentimentAnalysisService.java | // Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/api/Sentiment.java
// public class Sentiment {
//
// public static final int SENTIMENT_POSITIVE = 3;
// public static final int SENTIMENT_NEUTRAL = 2;
// public static final int SENTIMENT_NEGATIVE = 1;
//
// @JsonProperty("class")
// private final String sentimentClass;
// @JsonProperty("value")
// private final int sentimentValue;
//
// public Sentiment(String classText, int value) {
// this.sentimentClass = classText;
// this.sentimentValue = value;
// }
//
// /**
// * @return the sentimentClass
// */
// public String getSentimentClass() {
// return sentimentClass;
// }
//
// /**
// * @return the sentimentValue
// */
// public int getSentimentValue() {
// return sentimentValue;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/StanfordConfiguration.java
// public class StanfordConfiguration {
//
// private static final String NER_CLASSIFIER_PROPERTY = "loadClassifier";
//
// private Map<String, String> entityProperties;
//
// private Map<String, String> sentimentProperties;
//
// /**
// * @return the properties to set for NER.
// */
// public Map<String, String> getEntityProperties() {
// return entityProperties;
// }
//
// /**
// * @return the sentimentProperties
// */
// public Map<String, String> getSentimentProperties() {
// return sentimentProperties;
// }
//
// /**
// * Get the entity properties map as a Java Properties object.
// * @return a Java Properties object containing the properties.
// */
// public Properties getJavaEntityProperties() {
// Properties props = new Properties();
//
// for (String key : entityProperties.keySet()) {
// props.put(key, entityProperties.get(key));
// }
//
// return props;
// }
//
// /**
// * @return the path to the classifier file.
// */
// public String getClassifierFile() {
// return entityProperties.get(NER_CLASSIFIER_PROPERTY);
// }
//
// /**
// * Get the sentiment properties map as a Java Properties object.
// * @return the sentiment properties.
// */
// public Properties getJavaSentimentProperties() {
// Properties props = new Properties();
//
// for (String key : sentimentProperties.keySet()) {
// props.put(key, sentimentProperties.get(key));
// }
//
// return props;
// }
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.co.flax.ukmp.api.Sentiment;
import uk.co.flax.ukmp.config.StanfordConfiguration;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.neural.rnn.RNNCoreAnnotations;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.sentiment.SentimentCoreAnnotations;
import edu.stanford.nlp.trees.Tree;
import edu.stanford.nlp.util.CoreMap; | /**
* Copyright (c) 2014 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp.services;
/**
* A service class to parse and return sentiment values for strings.
*
* <p>
* The incoming text is slightly preprocessed, to replace links and usernames
* with simple tokens, as per
* http://cs.stanford.edu/people/alecmgo/papers/TwitterDistantSupervision09.pdf
* </p>
*/
public class SentimentAnalysisService {
private static final String LINK_REGEX = "(https?://\\S+)";
private static final String USERNAME_REGEX = "(@(\\w+))";
private static final Logger LOGGER = LoggerFactory.getLogger(SentimentAnalysisService.class);
private final StanfordCoreNLP pipeline;
/**
* Create a new SentimentAnalyzer using details from the Stanford
* configuration properties.
*
* @param config the configuration.
*/ | // Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/api/Sentiment.java
// public class Sentiment {
//
// public static final int SENTIMENT_POSITIVE = 3;
// public static final int SENTIMENT_NEUTRAL = 2;
// public static final int SENTIMENT_NEGATIVE = 1;
//
// @JsonProperty("class")
// private final String sentimentClass;
// @JsonProperty("value")
// private final int sentimentValue;
//
// public Sentiment(String classText, int value) {
// this.sentimentClass = classText;
// this.sentimentValue = value;
// }
//
// /**
// * @return the sentimentClass
// */
// public String getSentimentClass() {
// return sentimentClass;
// }
//
// /**
// * @return the sentimentValue
// */
// public int getSentimentValue() {
// return sentimentValue;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/StanfordConfiguration.java
// public class StanfordConfiguration {
//
// private static final String NER_CLASSIFIER_PROPERTY = "loadClassifier";
//
// private Map<String, String> entityProperties;
//
// private Map<String, String> sentimentProperties;
//
// /**
// * @return the properties to set for NER.
// */
// public Map<String, String> getEntityProperties() {
// return entityProperties;
// }
//
// /**
// * @return the sentimentProperties
// */
// public Map<String, String> getSentimentProperties() {
// return sentimentProperties;
// }
//
// /**
// * Get the entity properties map as a Java Properties object.
// * @return a Java Properties object containing the properties.
// */
// public Properties getJavaEntityProperties() {
// Properties props = new Properties();
//
// for (String key : entityProperties.keySet()) {
// props.put(key, entityProperties.get(key));
// }
//
// return props;
// }
//
// /**
// * @return the path to the classifier file.
// */
// public String getClassifierFile() {
// return entityProperties.get(NER_CLASSIFIER_PROPERTY);
// }
//
// /**
// * Get the sentiment properties map as a Java Properties object.
// * @return the sentiment properties.
// */
// public Properties getJavaSentimentProperties() {
// Properties props = new Properties();
//
// for (String key : sentimentProperties.keySet()) {
// props.put(key, sentimentProperties.get(key));
// }
//
// return props;
// }
//
// }
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/services/SentimentAnalysisService.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.co.flax.ukmp.api.Sentiment;
import uk.co.flax.ukmp.config.StanfordConfiguration;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.neural.rnn.RNNCoreAnnotations;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.sentiment.SentimentCoreAnnotations;
import edu.stanford.nlp.trees.Tree;
import edu.stanford.nlp.util.CoreMap;
/**
* Copyright (c) 2014 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp.services;
/**
* A service class to parse and return sentiment values for strings.
*
* <p>
* The incoming text is slightly preprocessed, to replace links and usernames
* with simple tokens, as per
* http://cs.stanford.edu/people/alecmgo/papers/TwitterDistantSupervision09.pdf
* </p>
*/
public class SentimentAnalysisService {
private static final String LINK_REGEX = "(https?://\\S+)";
private static final String USERNAME_REGEX = "(@(\\w+))";
private static final Logger LOGGER = LoggerFactory.getLogger(SentimentAnalysisService.class);
private final StanfordCoreNLP pipeline;
/**
* Create a new SentimentAnalyzer using details from the Stanford
* configuration properties.
*
* @param config the configuration.
*/ | public SentimentAnalysisService(StanfordConfiguration config) { |
flaxsearch/hackday | ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/services/SentimentAnalysisService.java | // Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/api/Sentiment.java
// public class Sentiment {
//
// public static final int SENTIMENT_POSITIVE = 3;
// public static final int SENTIMENT_NEUTRAL = 2;
// public static final int SENTIMENT_NEGATIVE = 1;
//
// @JsonProperty("class")
// private final String sentimentClass;
// @JsonProperty("value")
// private final int sentimentValue;
//
// public Sentiment(String classText, int value) {
// this.sentimentClass = classText;
// this.sentimentValue = value;
// }
//
// /**
// * @return the sentimentClass
// */
// public String getSentimentClass() {
// return sentimentClass;
// }
//
// /**
// * @return the sentimentValue
// */
// public int getSentimentValue() {
// return sentimentValue;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/StanfordConfiguration.java
// public class StanfordConfiguration {
//
// private static final String NER_CLASSIFIER_PROPERTY = "loadClassifier";
//
// private Map<String, String> entityProperties;
//
// private Map<String, String> sentimentProperties;
//
// /**
// * @return the properties to set for NER.
// */
// public Map<String, String> getEntityProperties() {
// return entityProperties;
// }
//
// /**
// * @return the sentimentProperties
// */
// public Map<String, String> getSentimentProperties() {
// return sentimentProperties;
// }
//
// /**
// * Get the entity properties map as a Java Properties object.
// * @return a Java Properties object containing the properties.
// */
// public Properties getJavaEntityProperties() {
// Properties props = new Properties();
//
// for (String key : entityProperties.keySet()) {
// props.put(key, entityProperties.get(key));
// }
//
// return props;
// }
//
// /**
// * @return the path to the classifier file.
// */
// public String getClassifierFile() {
// return entityProperties.get(NER_CLASSIFIER_PROPERTY);
// }
//
// /**
// * Get the sentiment properties map as a Java Properties object.
// * @return the sentiment properties.
// */
// public Properties getJavaSentimentProperties() {
// Properties props = new Properties();
//
// for (String key : sentimentProperties.keySet()) {
// props.put(key, sentimentProperties.get(key));
// }
//
// return props;
// }
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.co.flax.ukmp.api.Sentiment;
import uk.co.flax.ukmp.config.StanfordConfiguration;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.neural.rnn.RNNCoreAnnotations;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.sentiment.SentimentCoreAnnotations;
import edu.stanford.nlp.trees.Tree;
import edu.stanford.nlp.util.CoreMap; | /**
* Copyright (c) 2014 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp.services;
/**
* A service class to parse and return sentiment values for strings.
*
* <p>
* The incoming text is slightly preprocessed, to replace links and usernames
* with simple tokens, as per
* http://cs.stanford.edu/people/alecmgo/papers/TwitterDistantSupervision09.pdf
* </p>
*/
public class SentimentAnalysisService {
private static final String LINK_REGEX = "(https?://\\S+)";
private static final String USERNAME_REGEX = "(@(\\w+))";
private static final Logger LOGGER = LoggerFactory.getLogger(SentimentAnalysisService.class);
private final StanfordCoreNLP pipeline;
/**
* Create a new SentimentAnalyzer using details from the Stanford
* configuration properties.
*
* @param config the configuration.
*/
public SentimentAnalysisService(StanfordConfiguration config) {
pipeline = new StanfordCoreNLP(config.getJavaSentimentProperties());
}
/**
* Analyse tweet text, returning the sentiment extracted from the longest
* sentence (by character count).
* @param text the tweet text.
* @return a {@link Sentiment} object containing the sentiment value and
* its label.
*/ | // Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/api/Sentiment.java
// public class Sentiment {
//
// public static final int SENTIMENT_POSITIVE = 3;
// public static final int SENTIMENT_NEUTRAL = 2;
// public static final int SENTIMENT_NEGATIVE = 1;
//
// @JsonProperty("class")
// private final String sentimentClass;
// @JsonProperty("value")
// private final int sentimentValue;
//
// public Sentiment(String classText, int value) {
// this.sentimentClass = classText;
// this.sentimentValue = value;
// }
//
// /**
// * @return the sentimentClass
// */
// public String getSentimentClass() {
// return sentimentClass;
// }
//
// /**
// * @return the sentimentValue
// */
// public int getSentimentValue() {
// return sentimentValue;
// }
//
// }
//
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/config/StanfordConfiguration.java
// public class StanfordConfiguration {
//
// private static final String NER_CLASSIFIER_PROPERTY = "loadClassifier";
//
// private Map<String, String> entityProperties;
//
// private Map<String, String> sentimentProperties;
//
// /**
// * @return the properties to set for NER.
// */
// public Map<String, String> getEntityProperties() {
// return entityProperties;
// }
//
// /**
// * @return the sentimentProperties
// */
// public Map<String, String> getSentimentProperties() {
// return sentimentProperties;
// }
//
// /**
// * Get the entity properties map as a Java Properties object.
// * @return a Java Properties object containing the properties.
// */
// public Properties getJavaEntityProperties() {
// Properties props = new Properties();
//
// for (String key : entityProperties.keySet()) {
// props.put(key, entityProperties.get(key));
// }
//
// return props;
// }
//
// /**
// * @return the path to the classifier file.
// */
// public String getClassifierFile() {
// return entityProperties.get(NER_CLASSIFIER_PROPERTY);
// }
//
// /**
// * Get the sentiment properties map as a Java Properties object.
// * @return the sentiment properties.
// */
// public Properties getJavaSentimentProperties() {
// Properties props = new Properties();
//
// for (String key : sentimentProperties.keySet()) {
// props.put(key, sentimentProperties.get(key));
// }
//
// return props;
// }
//
// }
// Path: ukmp/java/webapp/src/main/java/uk/co/flax/ukmp/services/SentimentAnalysisService.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.co.flax.ukmp.api.Sentiment;
import uk.co.flax.ukmp.config.StanfordConfiguration;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.neural.rnn.RNNCoreAnnotations;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.sentiment.SentimentCoreAnnotations;
import edu.stanford.nlp.trees.Tree;
import edu.stanford.nlp.util.CoreMap;
/**
* Copyright (c) 2014 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp.services;
/**
* A service class to parse and return sentiment values for strings.
*
* <p>
* The incoming text is slightly preprocessed, to replace links and usernames
* with simple tokens, as per
* http://cs.stanford.edu/people/alecmgo/papers/TwitterDistantSupervision09.pdf
* </p>
*/
public class SentimentAnalysisService {
private static final String LINK_REGEX = "(https?://\\S+)";
private static final String USERNAME_REGEX = "(@(\\w+))";
private static final Logger LOGGER = LoggerFactory.getLogger(SentimentAnalysisService.class);
private final StanfordCoreNLP pipeline;
/**
* Create a new SentimentAnalyzer using details from the Stanford
* configuration properties.
*
* @param config the configuration.
*/
public SentimentAnalysisService(StanfordConfiguration config) {
pipeline = new StanfordCoreNLP(config.getJavaSentimentProperties());
}
/**
* Analyse tweet text, returning the sentiment extracted from the longest
* sentence (by character count).
* @param text the tweet text.
* @return a {@link Sentiment} object containing the sentiment value and
* its label.
*/ | public Sentiment analyze(String text) { |
flaxsearch/hackday | ukmp/java/indexer/src/main/java/uk/co/flax/ukmp/twitter/UKMPStatusStreamHandler.java | // Path: ukmp/java/indexer/src/main/java/uk/co/flax/ukmp/index/IndexerSearchEngine.java
// public interface IndexerSearchEngine {
//
// public void storeStatus(Status status, String party);
//
// public void deleteStatus(long userId, long statusId);
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import twitter4j.StallWarning;
import twitter4j.Status;
import twitter4j.StatusDeletionNotice;
import uk.co.flax.ukmp.index.IndexerSearchEngine;
import com.twitter.hbc.twitter4j.handler.StatusStreamHandler;
import com.twitter.hbc.twitter4j.message.DisconnectMessage;
import com.twitter.hbc.twitter4j.message.StallWarningMessage; | /**
* Copyright (c) 2014 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp.twitter;
/**
* @author Matt Pearce
*/
public class UKMPStatusStreamHandler implements StatusStreamHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(UKMPStatusStreamHandler.class);
private final String name; | // Path: ukmp/java/indexer/src/main/java/uk/co/flax/ukmp/index/IndexerSearchEngine.java
// public interface IndexerSearchEngine {
//
// public void storeStatus(Status status, String party);
//
// public void deleteStatus(long userId, long statusId);
//
// }
// Path: ukmp/java/indexer/src/main/java/uk/co/flax/ukmp/twitter/UKMPStatusStreamHandler.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import twitter4j.StallWarning;
import twitter4j.Status;
import twitter4j.StatusDeletionNotice;
import uk.co.flax.ukmp.index.IndexerSearchEngine;
import com.twitter.hbc.twitter4j.handler.StatusStreamHandler;
import com.twitter.hbc.twitter4j.message.DisconnectMessage;
import com.twitter.hbc.twitter4j.message.StallWarningMessage;
/**
* Copyright (c) 2014 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp.twitter;
/**
* @author Matt Pearce
*/
public class UKMPStatusStreamHandler implements StatusStreamHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(UKMPStatusStreamHandler.class);
private final String name; | private final IndexerSearchEngine searchEngine; |
flaxsearch/hackday | ukmp/java/indexer/src/main/java/uk/co/flax/ukmp/twitter/TwitterStreamThread.java | // Path: ukmp/java/indexer/src/main/java/uk/co/flax/ukmp/IndexerConfiguration.java
// public class IndexerConfiguration {
//
// private String authenticationFile;
// private String dataDirectory;
// private String archiveDirectory;
// private int numListeners;
// private int numThreads;
// private int messageQueueSize;
//
// private Map<String, PartyConfiguration> parties;
//
// /**
// * @return the authenticationFile
// */
// public String getAuthenticationFile() {
// return authenticationFile;
// }
//
// /**
// * @param authenticationFile the authenticationFile to set
// */
// public void setAuthenticationFile(String authenticationFile) {
// this.authenticationFile = authenticationFile;
// }
//
// /**
// * @return the parties
// */
// public Map<String, PartyConfiguration> getParties() {
// return parties;
// }
//
// /**
// * @param parties the parties to set
// */
// public void setParties(Map<String, PartyConfiguration> parties) {
// this.parties = parties;
// }
//
// /**
// * @return the dataDirectory
// */
// public String getDataDirectory() {
// return dataDirectory;
// }
//
// /**
// * @param dataDirectory the dataDirectory to set
// */
// public void setDataDirectory(String dataDirectory) {
// this.dataDirectory = dataDirectory;
// }
//
// /**
// * @return the archiveDirectory
// */
// public String getArchiveDirectory() {
// return archiveDirectory;
// }
//
// /**
// * @param archiveDirectory the archiveDirectory to set
// */
// public void setArchiveDirectory(String archiveDirectory) {
// this.archiveDirectory = archiveDirectory;
// }
//
// /**
// * @return the numListeners
// */
// public int getNumListeners() {
// return numListeners;
// }
//
// /**
// * @param numListeners the numListeners to set
// */
// public void setNumListeners(int numListeners) {
// this.numListeners = numListeners;
// }
//
// /**
// * @return the messageQueueSize
// */
// public int getMessageQueueSize() {
// return messageQueueSize;
// }
//
// /**
// * @param messageQueueSize the messageQueueSize to set
// */
// public void setMessageQueueSize(int messageQueueSize) {
// this.messageQueueSize = messageQueueSize;
// }
//
// /**
// * @return the numThreads
// */
// public int getNumThreads() {
// return numThreads;
// }
//
// /**
// * @param numThreads the numThreads to set
// */
// public void setNumThreads(int numThreads) {
// this.numThreads = numThreads;
// }
//
// }
//
// Path: ukmp/java/indexer/src/main/java/uk/co/flax/ukmp/index/IndexerSearchEngine.java
// public interface IndexerSearchEngine {
//
// public void storeStatus(Status status, String party);
//
// public void deleteStatus(long userId, long statusId);
//
// }
| import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.twitter.hbc.ClientBuilder;
import com.twitter.hbc.core.Constants;
import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint;
import com.twitter.hbc.core.processor.StringDelimitedProcessor;
import com.twitter.hbc.httpclient.BasicClient;
import com.twitter.hbc.httpclient.auth.Authentication;
import com.twitter.hbc.httpclient.auth.OAuth1;
import com.twitter.hbc.twitter4j.Twitter4jStatusClient;
import twitter4j.StatusListener;
import twitter4j.conf.Configuration;
import uk.co.flax.ukmp.IndexerConfiguration;
import uk.co.flax.ukmp.index.IndexerSearchEngine; | /**
* Copyright (c) 2014 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp.twitter;
/**
* @author Matt Pearce
*/
public class TwitterStreamThread extends Thread {
private static final Logger LOGGER = LoggerFactory.getLogger(TwitterStreamThread.class);
| // Path: ukmp/java/indexer/src/main/java/uk/co/flax/ukmp/IndexerConfiguration.java
// public class IndexerConfiguration {
//
// private String authenticationFile;
// private String dataDirectory;
// private String archiveDirectory;
// private int numListeners;
// private int numThreads;
// private int messageQueueSize;
//
// private Map<String, PartyConfiguration> parties;
//
// /**
// * @return the authenticationFile
// */
// public String getAuthenticationFile() {
// return authenticationFile;
// }
//
// /**
// * @param authenticationFile the authenticationFile to set
// */
// public void setAuthenticationFile(String authenticationFile) {
// this.authenticationFile = authenticationFile;
// }
//
// /**
// * @return the parties
// */
// public Map<String, PartyConfiguration> getParties() {
// return parties;
// }
//
// /**
// * @param parties the parties to set
// */
// public void setParties(Map<String, PartyConfiguration> parties) {
// this.parties = parties;
// }
//
// /**
// * @return the dataDirectory
// */
// public String getDataDirectory() {
// return dataDirectory;
// }
//
// /**
// * @param dataDirectory the dataDirectory to set
// */
// public void setDataDirectory(String dataDirectory) {
// this.dataDirectory = dataDirectory;
// }
//
// /**
// * @return the archiveDirectory
// */
// public String getArchiveDirectory() {
// return archiveDirectory;
// }
//
// /**
// * @param archiveDirectory the archiveDirectory to set
// */
// public void setArchiveDirectory(String archiveDirectory) {
// this.archiveDirectory = archiveDirectory;
// }
//
// /**
// * @return the numListeners
// */
// public int getNumListeners() {
// return numListeners;
// }
//
// /**
// * @param numListeners the numListeners to set
// */
// public void setNumListeners(int numListeners) {
// this.numListeners = numListeners;
// }
//
// /**
// * @return the messageQueueSize
// */
// public int getMessageQueueSize() {
// return messageQueueSize;
// }
//
// /**
// * @param messageQueueSize the messageQueueSize to set
// */
// public void setMessageQueueSize(int messageQueueSize) {
// this.messageQueueSize = messageQueueSize;
// }
//
// /**
// * @return the numThreads
// */
// public int getNumThreads() {
// return numThreads;
// }
//
// /**
// * @param numThreads the numThreads to set
// */
// public void setNumThreads(int numThreads) {
// this.numThreads = numThreads;
// }
//
// }
//
// Path: ukmp/java/indexer/src/main/java/uk/co/flax/ukmp/index/IndexerSearchEngine.java
// public interface IndexerSearchEngine {
//
// public void storeStatus(Status status, String party);
//
// public void deleteStatus(long userId, long statusId);
//
// }
// Path: ukmp/java/indexer/src/main/java/uk/co/flax/ukmp/twitter/TwitterStreamThread.java
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.twitter.hbc.ClientBuilder;
import com.twitter.hbc.core.Constants;
import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint;
import com.twitter.hbc.core.processor.StringDelimitedProcessor;
import com.twitter.hbc.httpclient.BasicClient;
import com.twitter.hbc.httpclient.auth.Authentication;
import com.twitter.hbc.httpclient.auth.OAuth1;
import com.twitter.hbc.twitter4j.Twitter4jStatusClient;
import twitter4j.StatusListener;
import twitter4j.conf.Configuration;
import uk.co.flax.ukmp.IndexerConfiguration;
import uk.co.flax.ukmp.index.IndexerSearchEngine;
/**
* Copyright (c) 2014 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp.twitter;
/**
* @author Matt Pearce
*/
public class TwitterStreamThread extends Thread {
private static final Logger LOGGER = LoggerFactory.getLogger(TwitterStreamThread.class);
| private final IndexerConfiguration indexConfig; |
flaxsearch/hackday | ukmp/java/indexer/src/main/java/uk/co/flax/ukmp/twitter/TwitterStreamThread.java | // Path: ukmp/java/indexer/src/main/java/uk/co/flax/ukmp/IndexerConfiguration.java
// public class IndexerConfiguration {
//
// private String authenticationFile;
// private String dataDirectory;
// private String archiveDirectory;
// private int numListeners;
// private int numThreads;
// private int messageQueueSize;
//
// private Map<String, PartyConfiguration> parties;
//
// /**
// * @return the authenticationFile
// */
// public String getAuthenticationFile() {
// return authenticationFile;
// }
//
// /**
// * @param authenticationFile the authenticationFile to set
// */
// public void setAuthenticationFile(String authenticationFile) {
// this.authenticationFile = authenticationFile;
// }
//
// /**
// * @return the parties
// */
// public Map<String, PartyConfiguration> getParties() {
// return parties;
// }
//
// /**
// * @param parties the parties to set
// */
// public void setParties(Map<String, PartyConfiguration> parties) {
// this.parties = parties;
// }
//
// /**
// * @return the dataDirectory
// */
// public String getDataDirectory() {
// return dataDirectory;
// }
//
// /**
// * @param dataDirectory the dataDirectory to set
// */
// public void setDataDirectory(String dataDirectory) {
// this.dataDirectory = dataDirectory;
// }
//
// /**
// * @return the archiveDirectory
// */
// public String getArchiveDirectory() {
// return archiveDirectory;
// }
//
// /**
// * @param archiveDirectory the archiveDirectory to set
// */
// public void setArchiveDirectory(String archiveDirectory) {
// this.archiveDirectory = archiveDirectory;
// }
//
// /**
// * @return the numListeners
// */
// public int getNumListeners() {
// return numListeners;
// }
//
// /**
// * @param numListeners the numListeners to set
// */
// public void setNumListeners(int numListeners) {
// this.numListeners = numListeners;
// }
//
// /**
// * @return the messageQueueSize
// */
// public int getMessageQueueSize() {
// return messageQueueSize;
// }
//
// /**
// * @param messageQueueSize the messageQueueSize to set
// */
// public void setMessageQueueSize(int messageQueueSize) {
// this.messageQueueSize = messageQueueSize;
// }
//
// /**
// * @return the numThreads
// */
// public int getNumThreads() {
// return numThreads;
// }
//
// /**
// * @param numThreads the numThreads to set
// */
// public void setNumThreads(int numThreads) {
// this.numThreads = numThreads;
// }
//
// }
//
// Path: ukmp/java/indexer/src/main/java/uk/co/flax/ukmp/index/IndexerSearchEngine.java
// public interface IndexerSearchEngine {
//
// public void storeStatus(Status status, String party);
//
// public void deleteStatus(long userId, long statusId);
//
// }
| import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.twitter.hbc.ClientBuilder;
import com.twitter.hbc.core.Constants;
import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint;
import com.twitter.hbc.core.processor.StringDelimitedProcessor;
import com.twitter.hbc.httpclient.BasicClient;
import com.twitter.hbc.httpclient.auth.Authentication;
import com.twitter.hbc.httpclient.auth.OAuth1;
import com.twitter.hbc.twitter4j.Twitter4jStatusClient;
import twitter4j.StatusListener;
import twitter4j.conf.Configuration;
import uk.co.flax.ukmp.IndexerConfiguration;
import uk.co.flax.ukmp.index.IndexerSearchEngine; | /**
* Copyright (c) 2014 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp.twitter;
/**
* @author Matt Pearce
*/
public class TwitterStreamThread extends Thread {
private static final Logger LOGGER = LoggerFactory.getLogger(TwitterStreamThread.class);
private final IndexerConfiguration indexConfig;
private final Configuration twitterConfig; | // Path: ukmp/java/indexer/src/main/java/uk/co/flax/ukmp/IndexerConfiguration.java
// public class IndexerConfiguration {
//
// private String authenticationFile;
// private String dataDirectory;
// private String archiveDirectory;
// private int numListeners;
// private int numThreads;
// private int messageQueueSize;
//
// private Map<String, PartyConfiguration> parties;
//
// /**
// * @return the authenticationFile
// */
// public String getAuthenticationFile() {
// return authenticationFile;
// }
//
// /**
// * @param authenticationFile the authenticationFile to set
// */
// public void setAuthenticationFile(String authenticationFile) {
// this.authenticationFile = authenticationFile;
// }
//
// /**
// * @return the parties
// */
// public Map<String, PartyConfiguration> getParties() {
// return parties;
// }
//
// /**
// * @param parties the parties to set
// */
// public void setParties(Map<String, PartyConfiguration> parties) {
// this.parties = parties;
// }
//
// /**
// * @return the dataDirectory
// */
// public String getDataDirectory() {
// return dataDirectory;
// }
//
// /**
// * @param dataDirectory the dataDirectory to set
// */
// public void setDataDirectory(String dataDirectory) {
// this.dataDirectory = dataDirectory;
// }
//
// /**
// * @return the archiveDirectory
// */
// public String getArchiveDirectory() {
// return archiveDirectory;
// }
//
// /**
// * @param archiveDirectory the archiveDirectory to set
// */
// public void setArchiveDirectory(String archiveDirectory) {
// this.archiveDirectory = archiveDirectory;
// }
//
// /**
// * @return the numListeners
// */
// public int getNumListeners() {
// return numListeners;
// }
//
// /**
// * @param numListeners the numListeners to set
// */
// public void setNumListeners(int numListeners) {
// this.numListeners = numListeners;
// }
//
// /**
// * @return the messageQueueSize
// */
// public int getMessageQueueSize() {
// return messageQueueSize;
// }
//
// /**
// * @param messageQueueSize the messageQueueSize to set
// */
// public void setMessageQueueSize(int messageQueueSize) {
// this.messageQueueSize = messageQueueSize;
// }
//
// /**
// * @return the numThreads
// */
// public int getNumThreads() {
// return numThreads;
// }
//
// /**
// * @param numThreads the numThreads to set
// */
// public void setNumThreads(int numThreads) {
// this.numThreads = numThreads;
// }
//
// }
//
// Path: ukmp/java/indexer/src/main/java/uk/co/flax/ukmp/index/IndexerSearchEngine.java
// public interface IndexerSearchEngine {
//
// public void storeStatus(Status status, String party);
//
// public void deleteStatus(long userId, long statusId);
//
// }
// Path: ukmp/java/indexer/src/main/java/uk/co/flax/ukmp/twitter/TwitterStreamThread.java
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.twitter.hbc.ClientBuilder;
import com.twitter.hbc.core.Constants;
import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint;
import com.twitter.hbc.core.processor.StringDelimitedProcessor;
import com.twitter.hbc.httpclient.BasicClient;
import com.twitter.hbc.httpclient.auth.Authentication;
import com.twitter.hbc.httpclient.auth.OAuth1;
import com.twitter.hbc.twitter4j.Twitter4jStatusClient;
import twitter4j.StatusListener;
import twitter4j.conf.Configuration;
import uk.co.flax.ukmp.IndexerConfiguration;
import uk.co.flax.ukmp.index.IndexerSearchEngine;
/**
* Copyright (c) 2014 Lemur Consulting Ltd.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.co.flax.ukmp.twitter;
/**
* @author Matt Pearce
*/
public class TwitterStreamThread extends Thread {
private static final Logger LOGGER = LoggerFactory.getLogger(TwitterStreamThread.class);
private final IndexerConfiguration indexConfig;
private final Configuration twitterConfig; | private final IndexerSearchEngine searchEngine; |
flaxsearch/hackday | nlp/src/main/java/uk/co/flax/hackday/NLPService.java | // Path: nlp/src/main/java/uk/co/flax/hackday/resources/Index.java
// @Path("/")
// public class Index {
//
// private final AbstractSequenceClassifier<CoreLabel> classifier;
//
// public Index(String classifierFile) {
// this.classifier = CRFClassifier.getClassifierNoExceptions(classifierFile);
// }
//
// @GET
// @Produces(MediaType.TEXT_PLAIN)
// public String handleGet() {
// return "POST text to this page!";
// }
//
// @POST
// @Produces(MediaType.APPLICATION_JSON)
// public String handlePost(String text) {
// String retVal = "{}";
//
// Map<String, List<String>> retMap = new HashMap<String, List<String>>();
//
// List<List<CoreLabel>> sentences = classifier.classify(text);
// for (List<CoreLabel> sentence : sentences) {
// // Current object and object type
// String currObj = "";
// String currType = "";
//
// for (CoreLabel word : sentence) {
// String type = word.get(AnswerAnnotation.class);
// String obj = word.word();
//
// // Ignore "O" annotations - these are general
// if (type.equals(currType) && !type.equals("O")) {
// // Append the current word to the previous one - join multi-word names
// currObj = currObj + " " + obj;
// } else {
// // New type - if we have a current object, store it
// if (currObj.length() > 0 && !currType.equals("O")) {
// if (!retMap.containsKey(currType)) {
// // New annotation type - add to the map
// retMap.put(currType, new ArrayList<String>());
// }
//
// retMap.get(currType).add(currObj);
// }
//
// // Hang on to the current type and object, use in the next iteration
// currType = type;
// currObj = obj;
// }
// }
// }
//
// // Convert the map of classifiers to JSON
// try {
// ObjectMapper mapper = new ObjectMapper();
// retVal = mapper.writeValueAsString(retMap);
// } catch (JsonProcessingException e) {
// System.err.println("Cannot convert words to JSON: " + e.getMessage());
// }
//
// return retVal;
// }
//
// }
| import uk.co.flax.hackday.resources.Index;
import com.yammer.dropwizard.Service;
import com.yammer.dropwizard.config.Bootstrap;
import com.yammer.dropwizard.config.Environment; | package uk.co.flax.hackday;
public class NLPService extends Service<NLPConfiguration> {
@Override
public void initialize(Bootstrap<NLPConfiguration> arg0) {
}
@Override
public void run(NLPConfiguration config, Environment env) throws Exception { | // Path: nlp/src/main/java/uk/co/flax/hackday/resources/Index.java
// @Path("/")
// public class Index {
//
// private final AbstractSequenceClassifier<CoreLabel> classifier;
//
// public Index(String classifierFile) {
// this.classifier = CRFClassifier.getClassifierNoExceptions(classifierFile);
// }
//
// @GET
// @Produces(MediaType.TEXT_PLAIN)
// public String handleGet() {
// return "POST text to this page!";
// }
//
// @POST
// @Produces(MediaType.APPLICATION_JSON)
// public String handlePost(String text) {
// String retVal = "{}";
//
// Map<String, List<String>> retMap = new HashMap<String, List<String>>();
//
// List<List<CoreLabel>> sentences = classifier.classify(text);
// for (List<CoreLabel> sentence : sentences) {
// // Current object and object type
// String currObj = "";
// String currType = "";
//
// for (CoreLabel word : sentence) {
// String type = word.get(AnswerAnnotation.class);
// String obj = word.word();
//
// // Ignore "O" annotations - these are general
// if (type.equals(currType) && !type.equals("O")) {
// // Append the current word to the previous one - join multi-word names
// currObj = currObj + " " + obj;
// } else {
// // New type - if we have a current object, store it
// if (currObj.length() > 0 && !currType.equals("O")) {
// if (!retMap.containsKey(currType)) {
// // New annotation type - add to the map
// retMap.put(currType, new ArrayList<String>());
// }
//
// retMap.get(currType).add(currObj);
// }
//
// // Hang on to the current type and object, use in the next iteration
// currType = type;
// currObj = obj;
// }
// }
// }
//
// // Convert the map of classifiers to JSON
// try {
// ObjectMapper mapper = new ObjectMapper();
// retVal = mapper.writeValueAsString(retMap);
// } catch (JsonProcessingException e) {
// System.err.println("Cannot convert words to JSON: " + e.getMessage());
// }
//
// return retVal;
// }
//
// }
// Path: nlp/src/main/java/uk/co/flax/hackday/NLPService.java
import uk.co.flax.hackday.resources.Index;
import com.yammer.dropwizard.Service;
import com.yammer.dropwizard.config.Bootstrap;
import com.yammer.dropwizard.config.Environment;
package uk.co.flax.hackday;
public class NLPService extends Service<NLPConfiguration> {
@Override
public void initialize(Bootstrap<NLPConfiguration> arg0) {
}
@Override
public void run(NLPConfiguration config, Environment env) throws Exception { | env.addResource(new Index(config.getClassifier())); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.