Skip to content

Commit

Permalink
fix: review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SivasaiPodugu committed Feb 16, 2024
1 parent 1885b54 commit 5a94451
Show file tree
Hide file tree
Showing 44 changed files with 244 additions and 159 deletions.
34 changes: 29 additions & 5 deletions sql_server_queries/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.testsigma.addons</groupId>
<artifactId>sql_server_queries</artifactId>
<version>1.1.0</version>
<version>2.0.0</version>
<packaging>jar</packaging>

<properties>
Expand Down Expand Up @@ -68,12 +68,23 @@
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.ibatis/ibatis-core -->
<dependency>
<groupId>org.apache.ibatis</groupId>
<artifactId>ibatis-core</artifactId>
<version>3.0</version>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>10.2.0.jre11</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>msal4j</artifactId>
<version>1.11.2</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>adal4j</artifactId>
<version>1.6.5</version>
</dependency>



</dependencies>
<build>
Expand All @@ -89,6 +100,19 @@
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>true</minimizeJar>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.Objects;

@Data
@Action(actionText = "Validate SQL Query Query1 and compare with the Query Query2 from the Connection DB_Connection_URL for Database Database-Name using Username user-name and Password password",
@Action(actionText = "SQLServer: Validate SQL Query Query1 and compare with the Query Query2 from the Connection DB_Connection_URL for Database Database-Name using Username user-name and Password password",
description = "This action validate queries on the database connections",
applicationType = ApplicationType.ANDROID)
public class SqlValidateQueriesonTables extends WebAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.Objects;

@Data
@Action(actionText = "Validate SQL Query Query1 and compare with the Query Query2 from the Connection DB_Connection_URL",
@Action(actionText = "SQLServer: Validate SQL Query Query1 and compare with the Query Query2 from the Connection DB_Connection_URL",
description = "This action validate queries on the database connections",
applicationType = ApplicationType.ANDROID)
public class SqlValidateQueriesonTablesWithUrl extends WebAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.sql.Statement;

@Data
@Action(actionText = "Execute SQL Query on the Connection DB_Connection_URL for Database Database-Name using Username user-name and Password password",
@Action(actionText = "SQLServer: Execute SQL Query on the Connection DB_Connection_URL for Database Database-Name using Username user-name and Password password",
description = "This action executes given query against the connection provided and prints the no. of affected/fetched rows.",
applicationType = ApplicationType.ANDROID)
public class Sqlqueries extends WebAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.sql.Statement;

@Data
@Action(actionText = "Execute SQL Query on the Connection DB_Connection_URL for Database Database-Name using Username user-name and Password password and verify affected rows count is Row-Count",
@Action(actionText = "SQLServer: Execute SQL Query on the Connection DB_Connection_URL for Database Database-Name using Username user-name and Password password and verify affected rows count is Row-Count",
description = "This Action executes given SQL query and validates the affected rows.",
applicationType = ApplicationType.ANDROID)
public class SqlqueriesValidate extends WebAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.sql.Statement;

@Data
@Action(actionText = "Execute SQL Query on the Connection DB_Connection_URL and verify affected rows count is Row-Count",
@Action(actionText = "SQLServer: Execute SQL Query on the Connection DB_Connection_URL and verify affected rows count is Row-Count",
description = "This Action executes given SQL query and validates the affected rows.",
applicationType = ApplicationType.ANDROID)
public class SqlqueriesValidateWithUrl extends WebAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.sql.Statement;

@Data
@Action(actionText = "Execute SQL Query on the Connection DB_Connection_URL",
@Action(actionText = "SQLServer: Execute SQL Query on the Connection DB_Connection_URL",
description = "This action executes given query against the connection provided and prints the no. of affected/fetched rows.",
applicationType = ApplicationType.ANDROID)
public class SqlqueriesWithUrl extends WebAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.sql.Statement;

@Data
@Action(actionText = "Execute SQL Select-Query on the connection DB_Connection_URL for Database Database-Name using Username user-name and Password password and store output into a variable-name",
@Action(actionText = "SQLServer: Execute SQL Select-Query on the connection DB_Connection_URL for Database Database-Name using Username user-name and Password password and store output into a variable-name",
description = "This Action executes a given Select Query and stores the result(First cell data) into a provided runtime variable.",
applicationType = ApplicationType.ANDROID)
public class Sqlselect extends WebAction {
Expand Down Expand Up @@ -49,21 +49,29 @@ public Result execute() throws NoSuchElementException {
String query = testData1.getValue().toString();
ResultSet resultSet = stmt.executeQuery(query);
StringBuilder resultStringBuilder = new StringBuilder();
ResultSetMetaData metaData = resultSet.getMetaData();
int columnCount = metaData.getColumnCount();

while (resultSet.next()) {
ResultSetMetaData metaData = resultSet.getMetaData();
int columnCount = metaData.getColumnCount();

if (columnCount > 0) {
// Assuming you want the first column's value
String resultData = resultSet.getObject(1).toString();

// Append the resultData to the StringBuilder
resultStringBuilder.append(resultData).append(", ");
for (int i = 1; i <= columnCount; i++) {
resultStringBuilder.append(metaData.getColumnName(i));
if (i < columnCount) {
resultStringBuilder.append(", ");
}
}
resultStringBuilder.append("\n");

setSuccessMessage("Successfully Executed Select Query and Resultset is : " + resultData);
logger.info("Successfully Executed Select Query and Resultset is : " + resultData);
while (resultSet.next()) {
for (int i = 1; i <= columnCount; i++) {
Object resultData = resultSet.getObject(i);
if (resultData != null) {
resultStringBuilder.append(resultData.toString());
}
else{
resultStringBuilder.append("null");
}
resultStringBuilder.append(", ");
}
resultStringBuilder.append("\n");
}

if (resultStringBuilder.length() > 0) {
Expand All @@ -72,8 +80,7 @@ public Result execute() throws NoSuchElementException {
runTimeData = new com.testsigma.sdk.RunTimeData();
runTimeData.setValue(concatenatedResult);
runTimeData.setKey(testData3.getValue().toString());

logger.info("Successfully retrieved result of the given query: " + concatenatedResult);
logger.info("Successfully Executed Select Query and Resultset is : " + concatenatedResult);
}
setSuccessMessage("Successfully Executed Select Query and stored in runtime variable: "+ testData3.getValue().toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.sql.Statement;

@Data
@Action(actionText = "Execute SQL Select-Query on the connection DB_Connection_URL and store output into a variable-name",
@Action(actionText = "SQLServer: Execute SQL Select-Query on the connection DB_Connection_URL and store output into a variable-name",
description = "This Action executes a given Select Query and stores the result(First cell data) into a provided runtime variable.",
applicationType = ApplicationType.ANDROID)
public class SqlselectWithUrl extends WebAction {
Expand Down Expand Up @@ -45,30 +45,37 @@ public Result execute() throws NoSuchElementException {
ResultSet resultSet = stmt.executeQuery(query);
StringBuilder resultStringBuilder = new StringBuilder();

while (resultSet.next()) {
ResultSetMetaData metaData = resultSet.getMetaData();
int columnCount = metaData.getColumnCount();

if (columnCount > 0) {
// Assuming you want the first column's value
String resultData = resultSet.getObject(1).toString();
ResultSetMetaData metaData = resultSet.getMetaData();
int columnCount = metaData.getColumnCount();

// Append the resultData to the StringBuilder
resultStringBuilder.append(resultData).append(", ");

setSuccessMessage("Successfully Executed Select Query and Resultset is : " + resultData);
logger.info("Successfully Executed Select Query and Resultset is : " + resultData);
for (int i = 1; i <= columnCount; i++) {
resultStringBuilder.append(metaData.getColumnName(i));
if (i < columnCount) {
resultStringBuilder.append(", ");
}
}
resultStringBuilder.append("\n");

while (resultSet.next()) {
for (int i = 1; i <= columnCount; i++) {
Object resultData = resultSet.getObject(i);
if (resultData != null) {
resultStringBuilder.append(resultData.toString());
}
else{
resultStringBuilder.append("null");
}
resultStringBuilder.append(", ");
}
resultStringBuilder.append("\n");
}
if (resultStringBuilder.length() > 0) {
resultStringBuilder.setLength(resultStringBuilder.length() - 2);
String concatenatedResult = resultStringBuilder.toString();
runTimeData = new com.testsigma.sdk.RunTimeData();
runTimeData.setValue(concatenatedResult);
runTimeData.setKey(testData3.getValue().toString());

logger.info("Successfully retrieved result of the given query: " + concatenatedResult);
logger.info("Successfully Executed Select Query and Resultset is : " + concatenatedResult);
}
setSuccessMessage("Successfully Executed Select Query and stored in runtime variable: "+ testData3.getValue().toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.sql.Statement;

@Data
@Action(actionText = "Execute SQL Select_Query on the connection DB_Connection_URL for Database Database-Name using Username user-name and Password password and verify output is Expected_Value",
@Action(actionText = "SQLServer: Execute SQL Select_Query on the connection DB_Connection_URL for Database Database-Name using Username user-name and Password password and verify output is Expected_Value",
description = "This Action executes a given Select Query and validates the result(First cell data) against the expected value.",
applicationType = ApplicationType.ANDROID)
public class Sqlselectvalidate extends WebAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.sql.Statement;

@Data
@Action(actionText = "Execute SQL Select_Query on the connection DB_Connection_URL and verify output is Expected_Value",
@Action(actionText = "SQLServer: Execute SQL Select_Query on the connection DB_Connection_URL and verify output is Expected_Value",
description = "This Action executes a given Select Query and validates the result(First cell data) against the expected value.",
applicationType = ApplicationType.ANDROID)
public class SqlselectvalidateWithUrl extends WebAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.Objects;

@Data
@Action(actionText = "Validate SQL Query Query1 and compare with the Query Query2 from the Connection DB_Connection_URL for Database Database-Name using Username user-name and Password password",
@Action(actionText = "SQLServer: Validate SQL Query Query1 and compare with the Query Query2 from the Connection DB_Connection_URL for Database Database-Name using Username user-name and Password password",
description = "This action validate queries on the database connections",
applicationType = ApplicationType.IOS)
public class SqlValidateQueriesonTables extends WebAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.Objects;

@Data
@Action(actionText = "Validate SQL Query Query1 and compare with the Query Query2 from the Connection DB_Connection_URL",
@Action(actionText = "SQLServer: Validate SQL Query Query1 and compare with the Query Query2 from the Connection DB_Connection_URL",
description = "This action validate queries on the database connections",
applicationType = ApplicationType.IOS)
public class SqlValidateQueriesonTablesWithUrl extends WebAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.sql.Statement;

@Data
@Action(actionText = "Execute SQL Query on the Connection DB_Connection_URL for Database Database-Name using Username user-name and Password password",
@Action(actionText = "SQLServer: Execute SQL Query on the Connection DB_Connection_URL for Database Database-Name using Username user-name and Password password",
description = "This action executes given query against the connection provided and prints the no. of affected/fetched rows.",
applicationType = ApplicationType.IOS)
public class Sqlqueries extends WebAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.sql.Statement;

@Data
@Action(actionText = "Execute SQL Query on the Connection DB_Connection_URL for Database Database-Name using Username user-name and Password password and verify affected rows count is Row-Count",
@Action(actionText = "SQLServer: Execute SQL Query on the Connection DB_Connection_URL for Database Database-Name using Username user-name and Password password and verify affected rows count is Row-Count",
description = "This Action executes given SQL query and validates the affected rows.",
applicationType = ApplicationType.IOS)
public class SqlqueriesValidate extends WebAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.sql.Statement;

@Data
@Action(actionText = "Execute SQL Query on the Connection DB_Connection_URL and verify affected rows count is Row-Count",
@Action(actionText = "SQLServer: Execute SQL Query on the Connection DB_Connection_URL and verify affected rows count is Row-Count",
description = "This Action executes given SQL query and validates the affected rows.",
applicationType = ApplicationType.IOS)
public class SqlqueriesValidateWithUrl extends WebAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.sql.Statement;

@Data
@Action(actionText = "Execute SQL Query on the Connection DB_Connection_URL",
@Action(actionText = "SQLServer: Execute SQL Query on the Connection DB_Connection_URL",
description = "This action executes given query against the connection provided and prints the no. of affected/fetched rows.",
applicationType = ApplicationType.IOS)
public class SqlqueriesWithUrl extends WebAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.sql.Statement;

@Data
@Action(actionText = "Execute SQL Select-Query on the connection DB_Connection_URL for Database Database-Name using Username user-name and Password password and store output into a variable-name",
@Action(actionText = "SQLServer: Execute SQL Select-Query on the connection DB_Connection_URL for Database Database-Name using Username user-name and Password password and store output into a variable-name",
description = "This Action executes a given Select Query and stores the result(First cell data) into a provided runtime variable.",
applicationType = ApplicationType.IOS)
public class Sqlselect extends WebAction {
Expand Down Expand Up @@ -49,21 +49,29 @@ public Result execute() throws NoSuchElementException {
String query = testData1.getValue().toString();
ResultSet resultSet = stmt.executeQuery(query);
StringBuilder resultStringBuilder = new StringBuilder();
ResultSetMetaData metaData = resultSet.getMetaData();
int columnCount = metaData.getColumnCount();

while (resultSet.next()) {
ResultSetMetaData metaData = resultSet.getMetaData();
int columnCount = metaData.getColumnCount();

if (columnCount > 0) {
// Assuming you want the first column's value
String resultData = resultSet.getObject(1).toString();

// Append the resultData to the StringBuilder
resultStringBuilder.append(resultData).append(", ");
for (int i = 1; i <= columnCount; i++) {
resultStringBuilder.append(metaData.getColumnName(i));
if (i < columnCount) {
resultStringBuilder.append(", ");
}
}
resultStringBuilder.append("\n");

setSuccessMessage("Successfully Executed Select Query and Resultset is : " + resultData);
logger.info("Successfully Executed Select Query and Resultset is : " + resultData);
while (resultSet.next()) {
for (int i = 1; i <= columnCount; i++) {
Object resultData = resultSet.getObject(i);
if (resultData != null) {
resultStringBuilder.append(resultData.toString());
}
else{
resultStringBuilder.append("null");
}
resultStringBuilder.append(", ");
}
resultStringBuilder.append("\n");
}

if (resultStringBuilder.length() > 0) {
Expand All @@ -72,8 +80,7 @@ public Result execute() throws NoSuchElementException {
runTimeData = new com.testsigma.sdk.RunTimeData();
runTimeData.setValue(concatenatedResult);
runTimeData.setKey(testData3.getValue().toString());

logger.info("Successfully retrieved result of the given query: " + concatenatedResult);
logger.info("Successfully Executed Select Query and Resultset is : " + concatenatedResult);
}
setSuccessMessage("Successfully Executed Select Query and stored in runtime variable: "+ testData3.getValue().toString());
}
Expand Down
Loading

0 comments on commit 5a94451

Please sign in to comment.