Skip to content

Commit

Permalink
Merge pull request #2 from zebrunner/develop
Browse files Browse the repository at this point in the history
1.0.0
  • Loading branch information
vdelendik authored Mar 31, 2023
2 parents e664c6c + cb9044f commit 04203bc
Show file tree
Hide file tree
Showing 14 changed files with 102 additions and 49 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version>
<carina-utils.version>1.0.3.P1-SNAPSHOT</carina-utils.version>
<carina-utils.version>1.0.3</carina-utils.version>
<opencsv.version>1.7</opencsv.version>
<slf4j.version>1.7.30</slf4j.version>
<commons-lang3.version>3.5</commons-lang3.version>
Expand All @@ -62,7 +62,7 @@
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
</properties>

<repositories>
<!--repositories>
<repository>
<id>zebrunner_snapshots</id>
<name>zebrunner Snapshots</name>
Expand All @@ -74,7 +74,7 @@
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</repositories-->

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
package com.zebrunner.carina.dataprovider;

import com.zebrunner.carina.dataprovider.core.DataProviderFactory;
import java.lang.annotation.Annotation;

import org.testng.ITestContext;
import org.testng.ITestNGMethod;
import org.testng.annotations.DataProvider;

import java.lang.annotation.Annotation;
import com.zebrunner.carina.dataprovider.core.DataProviderFactory;

public interface IAbstractDataProvider {

@DataProvider(name = "DataProvider", parallel = true)
default Object[][] createData(final ITestNGMethod testMethod, ITestContext context) {
Annotation[] annotations = testMethod.getConstructorOrMethod().getMethod().getDeclaredAnnotations();
Object[][] objects = DataProviderFactory.getDataProvider(annotations, context, testMethod);
return objects;
return DataProviderFactory.getDataProvider(annotations, context, testMethod);
}

@DataProvider(name = "SingleDataProvider")
default Object[][] createDataSingleThread(final ITestNGMethod testMethod, ITestContext context) {
Annotation[] annotations = testMethod.getConstructorOrMethod().getMethod().getDeclaredAnnotations();
Object[][] objects = DataProviderFactory.getDataProvider(annotations, context, testMethod);
return objects;
return DataProviderFactory.getDataProvider(annotations, context, testMethod);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface CsvDataSourceParameters {

/**
* Define data provider instance
*
* @return String
*/
String className() default "com.qaprosoft.carina.core.foundation.dataprovider.core.impl.CsvDataProvider";
String className() default "com.zebrunner.carina.dataprovider.core.impl.CsvDataProvider";

/**
* Define column separator for parsing
Expand Down Expand Up @@ -107,42 +108,42 @@
String testMethodColumn() default "";

/**
* Reason: not implemented
* @deprecated Reason: not implemented
*
* @return String
*/
@Deprecated(forRemoval = true, since = "1.0.0")
String testRailColumn() default "";

/**
* Reason: not implemented
* @deprecated Reason: not implemented
*
* @return String
*/
@Deprecated(forRemoval = true, since = "1.0.0")
String qTestColumn() default "";

/**
* Reason: not implemented
* @deprecated Reason: not implemented
*
* @return String
*/
@Deprecated(forRemoval = true, since = "1.0.0")
String testMethodOwnerColumn() default "";

/**
* Reason: not implemented
* @deprecated Reason: not implemented
*
* @return String
*/
@Deprecated(forRemoval = true, since = "1.0.0")
String bugColumn() default "";

/**
* Reason: not implemented
* @deprecated Reason: not implemented
*
* @return String[]
*/
@Deprecated(forRemoval = true, since = "1.0.0")
String[] doNotRunTestNames() default {};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface XlsDataSourceParameters {

/**
* Define data provider instance
*
* @return String
*/
String className() default "com.qaprosoft.carina.core.foundation.dataprovider.core.impl.XlsDataProvider";
String className() default "com.zebrunner.carina.dataprovider.core.impl.XlsDataProvider";

/**
* Is mutually exclusive with path
Expand All @@ -38,7 +39,7 @@
String spreadsheetId() default "";

/**
* Define data provider instance
* Define sheet from xls file
*
* @return String
*/
Expand Down Expand Up @@ -108,39 +109,39 @@
String testMethodColumn() default "";

/**
* Reason: not implemented
* @deprecated Reason: not implemented
*
* @return String
*/
@Deprecated(forRemoval = true, since = "1.0.0")
String testRailColumn() default "";

/**
* Reason: not implemented
* @deprecated Reason: not implemented
*
* @return String
*/
@Deprecated(forRemoval = true, since = "1.0.0")
String qTestColumn() default "";

/**
* Reason: not implemented
* @deprecated Reason: not implemented
*
* @return String
*/
@Deprecated(forRemoval = true, since = "1.0.0")
String testMethodOwnerColumn() default "";

/**
* Reason: not implemented
* @deprecated Reason: not implemented
*
* @return String
*/
@Deprecated(forRemoval = true, since = "1.0.0")
String bugColumn() default "";

/**
* Reason: not implemented
* @deprecated Reason: not implemented
*
* @return String
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* Created by Patotsky on 16.12.2014.
*/
public class DataProviderFactory {

private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

private DataProviderFactory() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,24 @@
*******************************************************************************/
package com.zebrunner.carina.dataprovider.core.groupping;

import java.util.*;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
* Created by Patotsky on 29.12.2014.
*
* @deprecated unused
*/

@Deprecated(forRemoval = true, since = "1.0.0")
public class GroupByImpl {

private GroupByImpl() {
// hide
}

public static Object[][] getGroupedDataProviderArgs(Object[][] objects, int fieldNumber) {
//add unique group values
Set<String> groupValues = new LinkedHashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

/**
* Created by Patotsky on 08.01.2015.
*
* @deprecated unused
*/

@Deprecated(forRemoval = true, since = "1.0.0")
@SuppressWarnings("serial")
public class GroupByException extends RuntimeException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import java.util.Map;
import java.util.Set;

import com.zebrunner.carina.dataprovider.parser.DSBean;
import org.testng.ITestContext;
import org.testng.ITestNGMethod;

import com.zebrunner.carina.dataprovider.parser.DSBean;
import com.zebrunner.carina.utils.ParameterGenerator;
import com.zebrunner.carina.utils.parser.xls.AbstractTable;

Expand All @@ -36,6 +36,7 @@
*/

public abstract class BaseDataProvider {

protected Map<String, String> tuidMap = Collections.synchronizedMap(new HashMap<>());
protected Map<String, String> testColumnNamesMap = Collections.synchronizedMap(new HashMap<>());

Expand Down Expand Up @@ -138,7 +139,7 @@ private void fillArgsAsArray(Object[][] dataProvider, AbstractTable table, DSBea
// populate the rest of arguments by static parameters from testParams
for (int staticArgsColumn = 0; staticArgsColumn < dsBean.getStaticArgs().size(); staticArgsColumn++) {
String staticArgName = dsBean.getStaticArgs().get(staticArgsColumn);
dataProvider[rowIndex][staticArgsColumn + row.entrySet().size()] = getStaticParam(staticArgName, dsBean);
dataProvider[rowIndex][staticArgsColumn + dsBean.getArgs().size()] = getStaticParam(staticArgName, dsBean);
}
}
}
Expand Down Expand Up @@ -221,8 +222,11 @@ private String getValueFromRow(Map<String, String> row, List<String> columnNames
}

protected static Object getStaticParam(String name, DSBean dsBean) {
//get value from suite by name
return ParameterGenerator.process(dsBean.getTestParams().get(name));
Object param = ParameterGenerator.process(dsBean.getTestParams().get(name));
if (param == null) {
throw new RuntimeException("Cant find parameter " + name + " in suite");
}
return param;
}

public Map<String, String> getTestColumnNamesMap() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,17 @@
import com.zebrunner.carina.dataprovider.parser.DSBean;
import com.zebrunner.carina.dataprovider.parser.csv.CSVParser;
import com.zebrunner.carina.dataprovider.parser.csv.CSVTable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.ITestContext;
import org.testng.ITestNGMethod;

import java.lang.annotation.Annotation;
import java.lang.invoke.MethodHandles;
import java.util.List;
import java.util.Map;

/**
* Created by Patotsky on 16.12.2014.
*/
public class CsvDataProvider extends BaseDataProvider {
private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

/**
* Create data provider for test based on csv data source, suite and annotation parameters
Expand Down
Loading

0 comments on commit 04203bc

Please sign in to comment.