Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions convert_date_format/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.testsigma.addons</groupId>
<artifactId>convert_date_format</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<testsigma.sdk.version>1.2.24_cloud</testsigma.sdk.version>
<junit.jupiter.version>5.8.0-M1</junit.jupiter.version>
<testsigma.addon.maven.plugin>1.0.0</testsigma.addon.maven.plugin>
<maven.source.plugin.version>3.2.1</maven.source.plugin.version>
<lombok.version>1.18.30</lombok.version>

</properties>

<dependencies>
<dependency>
<groupId>com.testsigma</groupId>
<artifactId>testsigma-java-sdk</artifactId>
<version>${testsigma.sdk.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.33.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.appium/java-client -->
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>9.4.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.13.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
</dependency>

</dependencies>
<build>
<finalName>convert_date_format</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven.source.plugin.version}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.testsigma.addons.android;

import com.testsigma.sdk.AndroidAction;
import com.testsigma.sdk.ApplicationType;
import com.testsigma.sdk.Result;
import com.testsigma.sdk.WebAction;
import com.testsigma.sdk.annotation.Action;
import com.testsigma.sdk.annotation.RunTimeData;
import com.testsigma.sdk.annotation.TestData;
import lombok.Data;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.openqa.selenium.NoSuchElementException;

import java.text.SimpleDateFormat;
import java.util.Date;

@Data
@Action(actionText = "Convert the date from the testdata in format1 to format2 and store it in a runtime variable",
description = "To store the number of char from testdata into runtime variable",
applicationType = ApplicationType.ANDROID)

public class DateFormatConversion extends AndroidAction
{

@TestData(reference = "testdata")
private com.testsigma.sdk.TestData testData1;

@TestData(reference = "format1")
private com.testsigma.sdk.TestData testData2;

@TestData(reference = "format2")
private com.testsigma.sdk.TestData testData3;

@TestData(reference = "variable")
private com.testsigma.sdk.TestData runtimeVar;

@RunTimeData
private com.testsigma.sdk.RunTimeData runTimeData;

@Override
public Result execute() throws NoSuchElementException
{
//Your Awesome code starts here
logger.info("Initiating execution");
Result result = Result.SUCCESS;

try {
SimpleDateFormat inputFormat = new SimpleDateFormat(testData2.getValue().toString());
SimpleDateFormat outputFormat = new SimpleDateFormat(testData3.getValue().toString());
logger.info("testdata = " + testData1.getValue().toString());
logger.info("format1 = " + testData2.getValue().toString());
logger.info("format2 = " + testData3.getValue().toString());
logger.info("variable = " + runtimeVar.getValue().toString());

String inputDateString = testData1.getValue().toString();
Date parsedDate = inputFormat.parse(inputDateString);

String outputDateString = outputFormat.format(parsedDate);
logger.info("outputDateString = " + outputDateString);

runTimeData.setKey(runtimeVar.getValue().toString());
runTimeData.setValue(outputDateString);

logger.info("Successfully converted date from " + testData2.getValue().toString() + " to " + testData3.getValue().toString() + " and stored in runtime variable = " +outputDateString);
setSuccessMessage("Successfully converted date from " + testData2.getValue().toString() + " to " + testData3.getValue().toString() + " and stored in runtime variable = " +outputDateString);
} catch(Exception e) {
logger.warn("Operation failed , the error message is ::::"+ ExceptionUtils.getStackTrace(e));
setErrorMessage("Operation failed , the error message is ::::"+ ExceptionUtils.getMessage(e));
result = Result.FAILED;
}
return result;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.testsigma.addons.ios;

import com.testsigma.sdk.*;
import com.testsigma.sdk.annotation.Action;
import com.testsigma.sdk.annotation.RunTimeData;
import com.testsigma.sdk.annotation.TestData;
import lombok.Data;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.devtools.v135.io.IO;

import java.text.SimpleDateFormat;
import java.util.Date;

@Data
@Action(actionText = "Convert the date from the testdata in format1 to format2 and store it in a runtime variable",
description = "To store the number of char from testdata into runtime variable",
applicationType = ApplicationType.IOS)
Comment on lines +16 to +18
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Inaccurate description — applies to all 6 platform files.

The description says "To store the number of char from testdata into runtime variable" which describes a character-count action, not a date format conversion. This text is user-facing in the Testsigma UI and will mislead users.

Proposed fix
-        description = "To store the number of char from testdata into runtime variable",
+        description = "Convert a date string from one format to another and store the result in a runtime variable",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Action(actionText = "Convert the date from the testdata in format1 to format2 and store it in a runtime variable",
description = "To store the number of char from testdata into runtime variable",
applicationType = ApplicationType.IOS)
`@Action`(actionText = "Convert the date from the testdata in format1 to format2 and store it in a runtime variable",
description = "Convert a date string from one format to another and store the result in a runtime variable",
applicationType = ApplicationType.IOS)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@convert_date_format/src/main/java/com/testsigma/addons/ios/DateFormatConversion.java`
around lines 16 - 18, The Action annotation's description is incorrect for the
DateFormatConversion action; update the description parameter in the `@Action`
annotation for the DateFormatConversion class (and the equivalent class in the
other 5 platform files) to a user-facing, accurate string such as "Convert a
date from format1 to format2 and store it in a runtime variable" so the
Testsigma UI shows the correct purpose of the action; ensure you modify the
description value in the `@Action` annotation for DateFormatConversion across all
six platform-specific files.


public class DateFormatConversion extends IOSAction {

@TestData(reference = "testdata")
private com.testsigma.sdk.TestData testData1;

@TestData(reference = "format1")
private com.testsigma.sdk.TestData testData2;

@TestData(reference = "format2")
private com.testsigma.sdk.TestData testData3;

@TestData(reference = "variable")
private com.testsigma.sdk.TestData runtimeVar;

@RunTimeData
private com.testsigma.sdk.RunTimeData runTimeData;

@Override
public Result execute() throws NoSuchElementException
{
//Your Awesome code starts here
logger.info("Initiating execution");
Result result = Result.SUCCESS;

try {
SimpleDateFormat inputFormat = new SimpleDateFormat(testData2.getValue().toString());
SimpleDateFormat outputFormat = new SimpleDateFormat(testData3.getValue().toString());
logger.info("testdata = " + testData1.getValue().toString());
logger.info("format1 = " + testData2.getValue().toString());
logger.info("format2 = " + testData3.getValue().toString());
logger.info("variable = " + runtimeVar.getValue().toString());

String inputDateString = testData1.getValue().toString();
Date parsedDate = inputFormat.parse(inputDateString);

String outputDateString = outputFormat.format(parsedDate);
logger.info("outputDateString = " + outputDateString);

runTimeData.setKey(runtimeVar.getValue().toString());
runTimeData.setValue(outputDateString);

logger.info("Successfully converted date from " + testData2.getValue().toString() + " to " + testData3.getValue().toString() + " and stored in runtime variable = " +outputDateString);
setSuccessMessage("Successfully converted date from " + testData2.getValue().toString() + " to " + testData3.getValue().toString() + " and stored in runtime variable = " +outputDateString);
} catch(Exception e) {
logger.warn("Operation failed , the error message is ::::"+ ExceptionUtils.getStackTrace(e));
setErrorMessage("Operation failed , the error message is ::::"+ ExceptionUtils.getMessage(e));
result = Result.FAILED;
}
return result;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.testsigma.addons.mobileweb;

import com.testsigma.sdk.AndroidAction;
import com.testsigma.sdk.ApplicationType;
import com.testsigma.sdk.Result;
import com.testsigma.sdk.WebAction;
import com.testsigma.sdk.annotation.Action;
import com.testsigma.sdk.annotation.RunTimeData;
import com.testsigma.sdk.annotation.TestData;
import lombok.Data;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.openqa.selenium.NoSuchElementException;

import java.text.SimpleDateFormat;
import java.util.Date;

@Data
@Action(actionText = "Convert the date from the testdata in format1 to format2 and store it in a runtime variable",
description = "To store the number of char from testdata into runtime variable",
applicationType = ApplicationType.MOBILE_WEB)

public class DateFormatConversion extends WebAction
{

@TestData(reference = "testdata")
private com.testsigma.sdk.TestData testData1;

@TestData(reference = "format1")
private com.testsigma.sdk.TestData testData2;

@TestData(reference = "format2")
private com.testsigma.sdk.TestData testData3;

@TestData(reference = "variable")
private com.testsigma.sdk.TestData runtimeVar;

@RunTimeData
private com.testsigma.sdk.RunTimeData runTimeData;

@Override
public Result execute() throws NoSuchElementException
{
//Your Awesome code starts here
logger.info("Initiating execution");
Result result = Result.SUCCESS;

try {
SimpleDateFormat inputFormat = new SimpleDateFormat(testData2.getValue().toString());
SimpleDateFormat outputFormat = new SimpleDateFormat(testData3.getValue().toString());
logger.info("testdata = " + testData1.getValue().toString());
logger.info("format1 = " + testData2.getValue().toString());
logger.info("format2 = " + testData3.getValue().toString());
logger.info("variable = " + runtimeVar.getValue().toString());

String inputDateString = testData1.getValue().toString();
Date parsedDate = inputFormat.parse(inputDateString);

String outputDateString = outputFormat.format(parsedDate);
logger.info("outputDateString = " + outputDateString);

runTimeData.setKey(runtimeVar.getValue().toString());
runTimeData.setValue(outputDateString);

logger.info("Successfully converted date from " + testData2.getValue().toString() + " to " + testData3.getValue().toString() + " and stored in runtime variable = " +outputDateString);
setSuccessMessage("Successfully converted date from " + testData2.getValue().toString() + " to " + testData3.getValue().toString() + " and stored in runtime variable = " +outputDateString);
} catch(Exception e) {
logger.warn("Operation failed , the error message is ::::"+ ExceptionUtils.getStackTrace(e));
setErrorMessage("Operation failed , the error message is ::::"+ ExceptionUtils.getMessage(e));
result = Result.FAILED;
}
return result;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.testsigma.addons.restapi;

import com.testsigma.sdk.*;
import com.testsigma.sdk.annotation.Action;
import com.testsigma.sdk.annotation.RunTimeData;
import com.testsigma.sdk.annotation.TestData;
import lombok.Data;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.openqa.selenium.NoSuchElementException;

import java.text.SimpleDateFormat;
import java.util.Date;

@Data
@Action(actionText = "Convert the date from the testdata in format1 to format2 and store it in a runtime variable",
description = "To store the number of char from testdata into runtime variable",
applicationType = ApplicationType.REST_API)

public class DateFormatConversion extends RestApiAction
{

@TestData(reference = "testdata")
private com.testsigma.sdk.TestData testData1;

@TestData(reference = "format1")
private com.testsigma.sdk.TestData testData2;

@TestData(reference = "format2")
private com.testsigma.sdk.TestData testData3;

@TestData(reference = "variable")
private com.testsigma.sdk.TestData runtimeVar;

@RunTimeData
private com.testsigma.sdk.RunTimeData runTimeData;

@Override
public Result execute() throws NoSuchElementException
{
//Your Awesome code starts here
logger.info("Initiating execution");
Result result = Result.SUCCESS;

try {
SimpleDateFormat inputFormat = new SimpleDateFormat(testData2.getValue().toString());
SimpleDateFormat outputFormat = new SimpleDateFormat(testData3.getValue().toString());
logger.info("testdata = " + testData1.getValue().toString());
logger.info("format1 = " + testData2.getValue().toString());
logger.info("format2 = " + testData3.getValue().toString());
logger.info("variable = " + runtimeVar.getValue().toString());

String inputDateString = testData1.getValue().toString();
Date parsedDate = inputFormat.parse(inputDateString);

String outputDateString = outputFormat.format(parsedDate);
logger.info("outputDateString = " + outputDateString);

runTimeData.setKey(runtimeVar.getValue().toString());
runTimeData.setValue(outputDateString);

logger.info("Successfully converted date from " + testData2.getValue().toString() + " to " + testData3.getValue().toString() + " and stored in runtime variable = " +outputDateString);
setSuccessMessage("Successfully converted date from " + testData2.getValue().toString() + " to " + testData3.getValue().toString() + " and stored in runtime variable = " +outputDateString);
} catch(Exception e) {
logger.warn("Operation failed , the error message is ::::"+ ExceptionUtils.getStackTrace(e));
setErrorMessage("Operation failed , the error message is ::::"+ ExceptionUtils.getMessage(e));
result = Result.FAILED;
}
return result;
}
}

Loading
Loading