Skip to content

Commit 39ccaa6

Browse files
Merge pull request #350 from testsigmahq/feat/CUS-11035-Migrated-the-classes-to-other-applications
feat/CUS-11035-Migrated the classes to other applications
2 parents 40442d3 + 7dfb093 commit 39ccaa6

54 files changed

Lines changed: 3989 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

mongodb_nlps/pom.xml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
6+
<modelVersion>4.0.0</modelVersion>
7+
<groupId>com.testsigma.addons</groupId>
8+
<artifactId>mongodb_nlps</artifactId>
9+
<version>1.0.5</version>
10+
<packaging>jar</packaging>
11+
12+
<properties>
13+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14+
<maven.compiler.source>11</maven.compiler.source>
15+
<maven.compiler.target>11</maven.compiler.target>
16+
<testsigma.sdk.version>1.2.24_cloud</testsigma.sdk.version>
17+
<junit.jupiter.version>5.8.0-M1</junit.jupiter.version>
18+
<testsigma.addon.maven.plugin>1.0.0</testsigma.addon.maven.plugin>
19+
<maven.source.plugin.version>3.2.1</maven.source.plugin.version>
20+
<lombok.version>1.18.30</lombok.version>
21+
22+
</properties>
23+
24+
<dependencies>
25+
<dependency>
26+
<groupId>com.testsigma</groupId>
27+
<artifactId>testsigma-java-sdk</artifactId>
28+
<version>${testsigma.sdk.version}</version>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.projectlombok</groupId>
32+
<artifactId>lombok</artifactId>
33+
<version>${lombok.version}</version>
34+
<optional>true</optional>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.junit.jupiter</groupId>
38+
<artifactId>junit-jupiter-api</artifactId>
39+
<version>${junit.jupiter.version}</version>
40+
<scope>test</scope>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.testng</groupId>
44+
<artifactId>testng</artifactId>
45+
<version>6.14.3</version>
46+
</dependency>
47+
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
48+
<dependency>
49+
<groupId>org.seleniumhq.selenium</groupId>
50+
<artifactId>selenium-java</artifactId>
51+
<version>4.33.0</version>
52+
</dependency>
53+
<!-- https://mvnrepository.com/artifact/io.appium/java-client -->
54+
<dependency>
55+
<groupId>io.appium</groupId>
56+
<artifactId>java-client</artifactId>
57+
<version>9.4.0</version>
58+
</dependency>
59+
<!-- https://mvnrepository.com/artifact/org.mongodb/mongo-java-driver -->
60+
<dependency>
61+
<groupId>org.mongodb</groupId>
62+
<artifactId>mongo-java-driver</artifactId>
63+
<version>3.12.10</version>
64+
</dependency>
65+
<dependency>
66+
<groupId>org.apache.commons</groupId>
67+
<artifactId>commons-lang3</artifactId>
68+
<version>3.17.0</version>
69+
</dependency>
70+
71+
72+
</dependencies>
73+
<build>
74+
<finalName>mongodb_nlps</finalName>
75+
<plugins>
76+
<plugin>
77+
<groupId>org.apache.maven.plugins</groupId>
78+
<artifactId>maven-shade-plugin</artifactId>
79+
<version>3.2.4</version>
80+
<executions>
81+
<execution>
82+
<phase>package</phase>
83+
<goals>
84+
<goal>shade</goal>
85+
</goals>
86+
</execution>
87+
</executions>
88+
</plugin>
89+
<plugin>
90+
<groupId>org.apache.maven.plugins</groupId>
91+
<artifactId>maven-source-plugin</artifactId>
92+
<version>${maven.source.plugin.version}</version>
93+
<executions>
94+
<execution>
95+
<id>attach-sources</id>
96+
<goals>
97+
<goal>jar</goal>
98+
</goals>
99+
</execution>
100+
</executions>
101+
</plugin>
102+
</plugins>
103+
</build>
104+
</project>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.testsigma.addons.android;
2+
3+
import com.mongodb.DB;
4+
import com.mongodb.MongoClient;
5+
import com.mongodb.MongoClientURI;
6+
import com.testsigma.sdk.AndroidAction;
7+
import com.testsigma.sdk.ApplicationType;
8+
import com.testsigma.sdk.Result;
9+
import com.testsigma.sdk.WebAction;
10+
import com.testsigma.sdk.annotation.Action;
11+
import com.testsigma.sdk.annotation.TestData;
12+
import lombok.Data;
13+
import org.apache.commons.lang3.exception.ExceptionUtils;
14+
import org.openqa.selenium.NoSuchElementException;
15+
16+
import java.util.Set;
17+
18+
@Data
19+
@Action(actionText = "Get the list of collections on the DBname and MongoDB_Connection",
20+
description = "validates list of collections fetched from db",
21+
applicationType = ApplicationType.ANDROID)
22+
public class MongoDB_GetListofCollection extends AndroidAction {
23+
24+
@TestData(reference = "DBname")
25+
private com.testsigma.sdk.TestData testData1;
26+
@TestData(reference = "MongoDB_Connection")
27+
private com.testsigma.sdk.TestData testData2;
28+
StringBuffer sb = new StringBuffer();
29+
30+
@Override
31+
public Result execute() throws NoSuchElementException {
32+
Result result = Result.SUCCESS;
33+
logger.info("Initiating execution");
34+
try{
35+
String connection = testData2.getValue().toString();
36+
37+
MongoClientURI uri = new MongoClientURI(connection);
38+
MongoClient mongoClient = new MongoClient(uri);
39+
40+
DB db = mongoClient.getDB(testData1.getValue().toString());
41+
42+
Set<String> colls = db.getCollectionNames();
43+
44+
sb.append("<br>");
45+
for (String collections : colls) {
46+
sb.append(collections);
47+
}
48+
setSuccessMessage("Successfully fetched the collection list: " +sb.toString());
49+
logger.info("Successfully fetched the collection list: " +sb.toString() +connection);
50+
}
51+
catch (Exception e){
52+
String errorMessage = ExceptionUtils.getStackTrace(e);
53+
result = Result.FAILED;
54+
setErrorMessage(errorMessage);
55+
logger.warn(errorMessage);
56+
}
57+
return result;
58+
}
59+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.testsigma.addons.android;
2+
3+
import com.mongodb.MongoClient;
4+
import com.mongodb.MongoClientURI;
5+
import com.testsigma.sdk.AndroidAction;
6+
import com.testsigma.sdk.ApplicationType;
7+
import com.testsigma.sdk.Result;
8+
import com.testsigma.sdk.WebAction;
9+
import com.testsigma.sdk.annotation.Action;
10+
import com.testsigma.sdk.annotation.TestData;
11+
import lombok.Data;
12+
import org.apache.commons.lang3.exception.ExceptionUtils;
13+
import org.openqa.selenium.NoSuchElementException;
14+
15+
import java.util.Set;
16+
17+
@SuppressWarnings("deprecation")
18+
@Data
19+
@Action(actionText = "Get the list of collections on DBname and connection MongoDB_ConnectionURL",
20+
description = "validates values of particular collection fetched from db with connectionURL localhost:port/username/password",
21+
applicationType = ApplicationType.ANDROID)
22+
public class MongoDB_GetListofCollectionsWithConnectionURL extends AndroidAction {
23+
24+
@TestData(reference = "DBname")
25+
private com.testsigma.sdk.TestData testData1;
26+
@TestData(reference = "MongoDB_ConnectionURL")
27+
private com.testsigma.sdk.TestData testData2;
28+
StringBuffer sb = new StringBuffer();
29+
30+
@Override
31+
public Result execute() throws NoSuchElementException {
32+
Result result = Result.SUCCESS;
33+
logger.info("Initiating execution");
34+
try{
35+
String database = testData1.getValue().toString();
36+
String connection = testData2.getValue().toString();
37+
38+
MongoClientURI uri = new MongoClientURI(connection);
39+
MongoClient mongoClient = new MongoClient(uri);
40+
41+
Set<String> colls = mongoClient.getDB(database).getCollectionNames();
42+
43+
sb.append("<br>");
44+
for (String collections : colls) {
45+
sb.append(collections);
46+
sb.append("<br>");
47+
}
48+
setSuccessMessage("Successfully fetched the collection list: " +sb.toString());
49+
logger.info("Successfully fetched the collection list: " +sb.toString());
50+
}
51+
catch (Exception e){
52+
String errorMessage = ExceptionUtils.getStackTrace(e);
53+
result = Result.FAILED;
54+
setErrorMessage(errorMessage);
55+
logger.warn(errorMessage);
56+
}
57+
return result;
58+
}
59+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.testsigma.addons.android;
2+
3+
import com.mongodb.MongoClient;
4+
import com.mongodb.MongoClientURI;
5+
import com.mongodb.client.MongoCursor;
6+
import com.testsigma.sdk.AndroidAction;
7+
import com.testsigma.sdk.ApplicationType;
8+
import com.testsigma.sdk.Result;
9+
import com.testsigma.sdk.WebAction;
10+
import com.testsigma.sdk.annotation.Action;
11+
import com.testsigma.sdk.annotation.TestData;
12+
import lombok.Data;
13+
import org.apache.commons.lang3.exception.ExceptionUtils;
14+
import org.openqa.selenium.NoSuchElementException;
15+
16+
@Data
17+
@Action(actionText = "Get the list of databases on the MongoDB_Connection",
18+
description = "validates list of databases fetched from db",
19+
applicationType = ApplicationType.ANDROID)
20+
public class MongoDB_GetListofDatabases extends AndroidAction {
21+
22+
@TestData(reference = "MongoDB_Connection")
23+
private com.testsigma.sdk.TestData testData1;
24+
StringBuffer sb = new StringBuffer();
25+
26+
@Override
27+
public Result execute() throws NoSuchElementException {
28+
Result result = Result.SUCCESS;
29+
logger.info("Initiating execution");
30+
try{
31+
String connection = testData1.getValue().toString();
32+
33+
MongoClientURI uri = new MongoClientURI(connection);
34+
MongoClient mongoClient = new MongoClient(uri);
35+
36+
MongoCursor<String> dbsCursord = mongoClient.listDatabaseNames().iterator();
37+
38+
sb.append("<br>");
39+
while(dbsCursord.hasNext()) {
40+
sb.append(dbsCursord.next());
41+
sb.append("<br>");
42+
}
43+
setSuccessMessage("Successfully fetched the databases list: " +sb.toString());
44+
logger.info("Successfully fetched the databases list: " +sb.toString());
45+
}
46+
catch (Exception e){
47+
String errorMessage = ExceptionUtils.getStackTrace(e);
48+
result = Result.FAILED;
49+
setErrorMessage(errorMessage);
50+
logger.warn(errorMessage);
51+
}
52+
return result;
53+
}
54+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.testsigma.addons.android;
2+
3+
import com.mongodb.*;
4+
import com.testsigma.sdk.AndroidAction;
5+
import com.testsigma.sdk.ApplicationType;
6+
import com.testsigma.sdk.Result;
7+
import com.testsigma.sdk.WebAction;
8+
import com.testsigma.sdk.annotation.Action;
9+
import com.testsigma.sdk.annotation.TestData;
10+
import lombok.Data;
11+
import org.apache.commons.lang3.exception.ExceptionUtils;
12+
import org.openqa.selenium.NoSuchElementException;
13+
14+
import java.util.Iterator;
15+
16+
@Data
17+
@Action(actionText = "Get the values of particular collection CollectionName on the DBname and MongoDB_Connection",
18+
description = "validates values of particular collection fetched from db",
19+
applicationType = ApplicationType.ANDROID)
20+
public class MongoDB_GetvaluesofCollection extends AndroidAction {
21+
22+
@TestData(reference = "DBname")
23+
private com.testsigma.sdk.TestData testData1;
24+
@TestData(reference = "MongoDB_Connection")
25+
private com.testsigma.sdk.TestData testData2;
26+
@TestData(reference = "CollectionName")
27+
private com.testsigma.sdk.TestData testData3;
28+
StringBuffer sb = new StringBuffer();
29+
30+
@Override
31+
public Result execute() throws NoSuchElementException {
32+
Result result = Result.SUCCESS;
33+
logger.info("Initiating execution");
34+
try{
35+
String connection = testData2.getValue().toString();
36+
37+
MongoClientURI uri = new MongoClientURI(connection);
38+
MongoClient mongoClient = new MongoClient(uri);
39+
40+
DB db = mongoClient.getDB(testData1.getValue().toString());
41+
42+
DBCollection collection = db.getCollection(testData3.getValue().toString());
43+
44+
DBCursor iterDoc = collection.find();
45+
Iterator it = iterDoc.iterator();
46+
sb.append("<br>");
47+
while (it.hasNext()) {
48+
sb.append(it.next());
49+
sb.append("<br>");
50+
}
51+
setSuccessMessage("Successfully fetched the values from collection: " +sb.toString());
52+
logger.info("Successfully fetched the values from collection: " +sb.toString());
53+
}
54+
catch (Exception e){
55+
String errorMessage = ExceptionUtils.getStackTrace(e);
56+
result = Result.FAILED;
57+
setErrorMessage(errorMessage);
58+
logger.warn(errorMessage);
59+
}
60+
return result;
61+
}
62+
}

0 commit comments

Comments
 (0)