use of org.junit.jupiter.api.TestFactory in project acceptance-testing by Abhigulve.
the class EventHandler method TestInitiator.
@TestFactory
public Collection<DynamicTest> TestInitiator() {
domManipulation.open(jr.getManupulatorBean().getUrl());
String testName = jr.getManupulatorBean().getTestName();
List<List<Map<String, String>>> list = jr.getManupulatorBean().getList();
Collection<DynamicTest> dynamicTests = new ArrayList<>();
for (int j = 0; j < list.size(); j++) {
domManipulation.open(jr.getManupulatorBean().getUrl());
List<Map<String, String>> testCase = list.get(j);
int i = 0;
for (int values = 1; values < testCase.size(); values++) {
Map<String, String> map = testCase.get(values);
domManipulation.action(map.get("id").toString(), map.get("value"), map.get("event").toUpperCase());
i++;
if (i == (testCase.size())) {
DynamicTest dTest = DynamicTest.dynamicTest(testName, () -> domManipulation.testCaseAnalyser(map.get("id").toString(), map.get("condition").toUpperCase()));
dynamicTests.add(dTest);
}
}
}
return dynamicTests;
}
use of org.junit.jupiter.api.TestFactory in project kafka-connect-cdc-mssql by jcustenborder.
the class QueryServiceIT method queryTable.
@TestFactory
public Stream<DynamicTest> queryTable() throws SQLException {
List<ChangeKey> changeCaptureTables = new ArrayList<>();
PooledConnection pooledConnection = null;
try {
pooledConnection = JdbcUtils.openPooledConnection(this.config, new ChangeKey(MsSqlTestConstants.DATABASE_NAME, null, null));
MsSqlQueryBuilder queryBuilder = new MsSqlQueryBuilder(pooledConnection.getConnection());
try (PreparedStatement statement = queryBuilder.listChangeTrackingTablesStatement()) {
try (ResultSet resultSet = statement.executeQuery()) {
while (resultSet.next()) {
String databaseName = resultSet.getString("databaseName");
String schemaName = resultSet.getString("schemaName");
String tableName = resultSet.getString("tableName");
ChangeKey changeKey = new ChangeKey(databaseName, schemaName, tableName);
changeCaptureTables.add(changeKey);
log.trace("Found Change Tracking Enabled Table {}", changeKey);
}
}
}
} finally {
JdbcUtils.closeConnection(pooledConnection);
}
return changeCaptureTables.stream().map(data -> dynamicTest(data.tableName, () -> queryTable(data)));
}
use of org.junit.jupiter.api.TestFactory in project mssql-jdbc by Microsoft.
the class lobsTest method executeDynamicTests.
@TestFactory
public Collection<DynamicTest> executeDynamicTests() {
List<Class> classes = new ArrayList<Class>(Arrays.asList(Blob.class, Clob.class, DBBinaryStream.class, DBCharacterStream.class));
List<Boolean> isResultSetTypes = new ArrayList<>(Arrays.asList(true, false));
Collection<DynamicTest> dynamicTests = new ArrayList<>();
for (Class aClass : classes) {
for (Boolean isResultSetType : isResultSetTypes) {
final Class lobClass = aClass;
final boolean isResultSet = isResultSetType;
Executable exec = new Executable() {
@Override
public void execute() throws Throwable {
testInvalidLobs(lobClass, isResultSet);
}
};
// create a test display name
String testName = " Test: " + lobClass + (isResultSet ? " isResultSet" : " isPreparedStatement");
// create dynamic test
DynamicTest dTest = DynamicTest.dynamicTest(testName, exec);
// add the dynamic test to collection
dynamicTests.add(dTest);
}
}
return dynamicTests;
}
use of org.junit.jupiter.api.TestFactory in project tutorials by eugenp.
the class DynamicTestsExample method dynamicTestsForEmployeeWorkflows.
@TestFactory
Stream<DynamicTest> dynamicTestsForEmployeeWorkflows() {
List<Employee> inputList = Arrays.asList(new Employee(1, "Fred"), new Employee(2), new Employee(3, "John"));
EmployeeDao dao = new EmployeeDao();
Stream<DynamicTest> saveEmployeeStream = inputList.stream().map(emp -> DynamicTest.dynamicTest("saveEmployee: " + emp.toString(), () -> {
Employee returned = dao.save(emp.getId());
assertEquals(returned.getId(), emp.getId());
}));
Stream<DynamicTest> saveEmployeeWithFirstNameStream = inputList.stream().filter(emp -> !emp.getFirstName().isEmpty()).map(emp -> DynamicTest.dynamicTest("saveEmployeeWithName" + emp.toString(), () -> {
Employee returned = dao.save(emp.getId(), emp.getFirstName());
assertEquals(returned.getId(), emp.getId());
assertEquals(returned.getFirstName(), emp.getFirstName());
}));
return Stream.concat(saveEmployeeStream, saveEmployeeWithFirstNameStream);
}
Aggregations