I'm stuck facing problems with pegdown v1.4.2 while trying to implement custom ParserPlugin to a library I'm writing (Maven project, JDK 8):
CustomPlugin:
public class CustomHeadersParserPlugin extends Parser implements BlockPluginParser {
public CustomHeadersParserPlugin() {super(HtmlMdProc.MDP_SETTINGS, HtmlMdProc.PROCESSING_TIME_LIMIT, DefaultParseRunnerProvider);
}
public CustomHeadersParserPlugin(Integer options, Long maxParsingTimeInMillis) {
super(options, maxParsingTimeInMillis, DefaultParseRunnerProvider);
}
public CustomHeadersParserPlugin(Integer options, Long maxParsingTimeInMillis, ParseRunnerProvider parseRunnerProvider) {
super(options, maxParsingTimeInMillis, parseRunnerProvider);
}
public CustomHeadersParserPlugin(Integer options, Long maxParsingTimeInMillis, ParseRunnerProvider parseRunnerProvider, PegDownPlugins plugins) {
super(options, maxParsingTimeInMillis, parseRunnerProvider, plugins);
}
//************* CUSTOM RULES ***************
...
Pegdown Usage:
public class HtmlMdProc {
public static final int MDP_SETTINGS = Extensions.HARDWRAPS | Extensions.AUTOLINKS | Extensions.TABLES | Extensions.FENCED_CODE_BLOCKS;
public static final long PROCESSING_TIME_LIMIT = 5000l;
...
public HtmlMdProc markdown() {
PegDownPlugins pdp = PegDownPlugins.builder().withPlugin(CustomHeadersParserPlugin.class).build();
PegDownProcessor mdp = new PegDownProcessor(MDP_SETTINGS, PROCESSING_TIME_LIMIT, pdp);
RootNode rn = mdp.parseMarkdown(text.toCharArray());
String result = new CustomMarkdownToHtmlSerializer().toHtml(rn);
if (result != null)
this.text = result;
else
logger.debug("Could not process markdown in {} seconds", PROCESSING_TIME_LIMIT / 1000);
return this;
}
Test:
#Test
public void testmarkdownWithoutCode() {
String before = "Simple new line\nTest\n\nTest\nVot";
String expected = "<p>Simple new line<br />Test</p><p>Test<br />Vot</p>".replaceAll("\r", "");
HtmlMdProc textProc = new HtmlMdProc(before);
String result = textProc.markdown().text();
assertEquals(expected, result);
}
Testing Exeption:
java.lang.RuntimeException: Error creating extended parser class: null
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.parboiled.transform.AsmUtils.createClassReader(AsmUtils.java:56)
at org.parboiled.transform.ClassNodeInitializer.process(ClassNodeInitializer.java:62)
at org.parboiled.transform.ParserTransformer.extendParserClass(ParserTransformer.java:44)
at org.parboiled.transform.ParserTransformer.transformParser(ParserTransformer.java:38)
at org.parboiled.Parboiled.createParser(Parboiled.java:54)
at org.pegdown.plugins.PegDownPlugins$Builder.withPlugin(PegDownPlugins.java:113)
at com.myorg.html.services.HtmlMdProc.markdown(HtmlMdProc.java:317)
at com.myorg.html.services.HtmlMdProcTest.testmarkdownWithoutCode(HtmlMdProcTest.java:262)
Can I somehow bind my CustomHeadersParserPlugin avoiding spooky Reflections?
If not, tell me how to setup maven-bundle-plugin in pom.xml to make it work with pegdown v 1.4.2.
I found Issue with discussion Here, but I'm too novice to deal alone with Maven plugins and Reflections.
The only solution is to wait for This Issue to be closed, until I thing there is no luck with Pegdown and Java 8.
Related
I'm writing my own maven plugin, and I have an issue to load a certain class. This post proposed a way to enrich the ClassRealm to broad class loading scope.
#Mojo(
name = "deploy",
defaultPhase = LifecyclePhase.DEPLOY,
requiresDependencyCollection = ResolutionScope.RUNTIME,
requiresDirectInvocation = true,
requiresOnline = true
)
public class DeployMojo extends AbstractMojo {
#Parameter
private String server;
#Parameter(defaultValue = "${project}", readonly = true, required = true)
private MavenProject project;
#Component
private PluginDescriptor descriptor;
public void execute() throws MojoExecutionException, MojoFailureException {
// Added runtime resources for the project and create the classloader
final var realm = descriptor.getClassRealm();
final ArrayList<String> classpathElements;
try {
classpathElements = new ArrayList<>(project.getRuntimeClasspathElements());
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Unable to resolve project dependencies", e);
}
classpathElements.add(project.getBuild().getOutputDirectory());
final var urls = new URL[classpathElements.size()];
for (int i = 0; i < classpathElements.size(); ++i) {
try {
urls[i] = new File(classpathElements.get(i)).toURI().toURL();
realm.addURL(urls[i]);
} catch (MalformedURLException e) {
throw new MojoExecutionException(String.format("Unable to parse classpath: %s as URL", classpathElements.get(i)), e);
}
}
//Some other operations
}
}
However, when I try to get the ClassRealm via descriptor.getClassRealm(), it shows that Cannot access org.codehaus.plexus.classworlds.realm.ClassRealm. Also in the documentation, it mentions that Warning: This is an internal utility method that is only public for technical reasons, it is not part of the public API. In particular, this method can be changed or deleted without prior notice and must not be used by plugins.
I wonder is there a way to enrich the ClassRealm, or this is something that we shouldn't change.
I am facing some difficulties in writing junit test to pass the for loop condition to getParts() method from SlingHttpServletRequest.getParts(). There is no problem with the implementation, I am able to process the file attachment properly. However, I am unable to do so in the junit test.
The following is my implementation:
#Model(adaptables = SlingHttpServletRequest.class)
public class Comment {
//Variables declaration
#Inject
private CommentService service;
#PostConstruct
public void setup() {
requestData = new JSONObject();
for (String item : request.getRequestParameterMap().keySet()) {
try {
requestData.put(item, request.getParameter(item));
}
} catch (Exception e) {
Throw error message
}
}
//Upload attachment to server
try {
for (Part part : request.getParts()) { <= The JUnit test stopped at this line and throw the error below
} catch (Exception e) {
Throw error message
}
I have tried using a SlingHttpServletRequestWrapper class to override the getParts method but to no avail.
The following is my junit test:
public class CommentTest {
public final AemContext context = new AemContext();
private CommentService commentService = mock(CommentService.class);
#InjectMocks
private Comment comment;
private static String PATH = "/content/testproject/en/page/sub-page";
#Before
public void setUp() throws Exception {
context.addModelsForPackage("de.com.adsl.sightly.model");
context.load().json("/components/textrte.json", PATH);
context.currentPage(PATH);
}
#Test
public void testSetup() throws IOException, ServletException {
//before
context.request().setParameterMap(getRequestCat1());
context.registerService(CommentService.class, commentService);
Resource resource = context.resourceResolver().getResource(PATH + "/jcr:content/root/responsivegrid/textrte");
assertNotNull(resource);
//when
comment = new CustomRequest(context.request()).adaptTo(Comment.class);
//then
comment.setup();
}
private class CustomRequest extends SlingHttpServletRequestWrapper {
public CustomRequest(SlingHttpServletRequest request) {
super(request);
}
#Override
public Collection<Part> getParts() {
final String mockContent =
"------WebKitFormBoundarycTqA2AimXQHBAJbZ\n" +
"Content-Disposition: form-data; name=\"key\"\n" +
"\n" +
"myvalue1\n" +
"------WebKitFormBoundarycTqA2AimXQHBAJbZ";
final List<Part> parts = MockPart.parseAll(mockContent);
assertNotNull(parts);
return parts;
}
};
}
The following is the error message that I encountered:
14:53:04.918 [main] ERROR de.com.adsl.sightly.model.Comment - Error Message: null
java.lang.UnsupportedOperationException: null
at org.apache.sling.servlethelpers.MockSlingHttpServletRequest.getParts(MockSlingHttpServletRequest.java:882) ~[org.apache.sling.servlet-helpers-1.1.10.jar:?]
at de.com.adsl.sightly.model.Comment.uploadFile(Feedback.java:137) ~[classes/:?]
at de.com.adsl.sightly.model.Comment.setup(Feedback.java:82) [classes/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_201]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_201]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_201]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_201]
at org.apache.sling.models.impl.ModelAdapterFactory.invokePostConstruct(ModelAdapterFactory.java:792) [org.apache.sling.models.impl-1.3.8.jar:?]
at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:607) [org.apache.sling.models.impl-1.3.8.jar:?]
at org.apache.sling.models.impl.ModelAdapterFactory.internalCreateModel(ModelAdapterFactory.java:335) [org.apache.sling.models.impl-1.3.8.jar:?]
at org.apache.sling.models.impl.ModelAdapterFactory.getAdapter(ModelAdapterFactory.java:211) [org.apache.sling.models.impl-1.3.8.jar:?]
...
I have looked up various solutions online such as writing two mockito when statements but has not been successful. I would greatly appreciate any form of help or sharing of knowledge if you have encountered the following issue previously. Thank you!
From the source code of MockSlingServletResquest it always throws that exception as it's not supported yet by the mocked class.
https://github.com/apache/sling-org-apache-sling-servlet-helpers/blob/71ef769e5564cf78e49d6679a3270ba8706ae406/src/main/java/org/apache/sling/servlethelpers/MockSlingHttpServletRequest.java#L953
Maybe you should consider writing a servlet, or another approach.
I try to get some data from a dbus service and work with it in Java.
I can get the information in cli with the following command:
dbus-send --print-reply --system --dest=com.victronenergy.solarcharger.ttyUSB0 /Dc/0/Voltage com.victronenergy.BusItem.GetValue
The result is:
method return time=1538903662.321580 sender=:1.14 -> destination=:1.806 serial=335692 reply_serial=2
variant double 13.43
What I tried to get this data in Java, is:
After hours of reading, I created an Interface.
package javadbus;
import java.util.Map;
import org.freedesktop.dbus.DBusInterface;
import org.freedesktop.dbus.DBusSignal;
import org.freedesktop.dbus.Variant;
import org.freedesktop.dbus.exceptions.DBusException;
public interface BusItem extends DBusInterface
{
public static class PropertiesChanged extends DBusSignal
{
public final Map<String,Variant> changes;
public PropertiesChanged(String path, Map<String,Variant> changes) throws DBusException
{
super(path, changes);
this.changes = changes;
}
}
public String GetDescription(String language, int length);
public Variant GetValue();
public String GetText();
public int SetValue(Variant value);
public Variant GetMin();
public Variant GetMax();
public int SetDefault();
public Variant GetDefault();
}
Here I call getConnection() and getRemoteObject() successfully.
package javadbus;
import org.freedesktop.dbus.DBusConnection;
import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.Variant;
public class VictronEnergyDBusSolarCharger {
private String port;
private DBusConnection conn;
public VictronEnergyDBusSolarCharger(String port) {
this.port = port;
try {
this.conn = DBusConnection.getConnection(DBusConnection.SYSTEM);
} catch (DBusException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private String getData(String item) {
BusItem bi;
String data = null;
Variant vData = null;
try {
bi = (BusItem)conn.getRemoteObject("com.victronenergy.solarcharger." + this.port, item, BusItem.class);
vData = bi.GetValue();
//data = bi.GetText();
} catch (DBusException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return data;
}
...
}
It was a big task to resolve all dependecies and get the code compiled. But finaly I did it. So, javac now runs without errors.
But if I try to call the Method GetValue(), I get the following Exception:
[Sender] INFO org.freedesktop.dbus.MessageWriter - <= MethodCall(0,1) { Path=>/org/freedesktop/DBus, Interface=>org.freedesktop.DBus, Member=>Hello, Destination=>org.freedesktop.DBus } { }
[Sender] INFO org.freedesktop.dbus.MessageWriter - <= MethodCall(0,3) { Path=>/Dc/0/Voltage, Interface=>javadbus.BusItem, Member=>GetValue, Destination=>com.victronenergy.solarcharger.ttyUSB0 } { }
Exception in thread "main" org.freedesktop.DBus$Error$UnknownMethod: Method "GetValue" with signature "" on interface "javadbus.BusItem" doesn't exist
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.freedesktop.dbus.Error.getException(Error.java:141)
at org.freedesktop.dbus.Error.throwException(Error.java:171)
at org.freedesktop.dbus.RemoteInvocationHandler.executeRemoteMethod(RemoteInvocationHandler.java:158)
at org.freedesktop.dbus.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:222)
at com.sun.proxy.$Proxy1.GetValue(Unknown Source)
at javadbus.VictronEnergyDBusSolarCharger.getData(VictronEnergyDBusSolarCharger.java:28)
at javadbus.VictronEnergyDBusSolarCharger.getDcV(VictronEnergyDBusSolarCharger.java:38)
at javadbus.MainClass.main(MainClass.java:7)
Is it necessary to make a implementation of this Method GetValue? But why e.g. how should I do this? I only want to get this Information and not provide it like a Server.
Why was it a big task to get all dependencies?
dbus-java library and dependencies are all available at maven central, so a proper maven project should just work out-of-the-box.
Back to topic:
You don't have to implement GetValue(), but you need a suitable java interface for BusItem.
As far as I can see in the documentation of victronenergy (https://www.victronenergy.com/live/open_source:ccgx:d-bus) , your interface is not correct.
You provide SetDefault()/GetDefault() methods, which are only available on com.victronenergy.settings Objects, but you want to retrieve a com.victronenergy.BusItem (no part of the com.victronenergy.settings package).
This is one error. The second error is: you use the wrong package name for your BusItem class.
In your case DBus will try to resolve an object with the path javadbus.BusItem which is not provided by the connected BusAddress com.victronenergy.solarcharger.ttyUSB0.
The BusItem class has to be in package com.victronenergy or you have to use the annotation #DBusInterfaceName("com.victronenergy.BusItem").
The annotation will tell the DBus library to ignore the java package/class name and use the one provided in the annotation.
The Inteface BusItem had been created by CreateInterface-Script from https://dbus.freedesktop.org/doc/dbus-java/dbus-java/dbus-javase10.html and the XML from Introspect()
But you solved my real problem. I used the annotation #DBusInterfaceName("com.victronenergy.BusItem") now. No Exception anymore an i get data from my solarcharger. Thank you so much!
I am trying to use dropwizard-sundial and am having trouble with a resource. I'm not sure if it's a classpath issue or if I am failing to register resources properly.
This is my application class' run method:
public void run(DataLoaderApplicationConfiguration configuration, Environment environment) throws Exception {
logger.info("Started DataLoader Application");
final String template = configuration.getTemplate();
environment.healthChecks().register("TemplateHealth", new TemplateHealthCheck(template));
// JOBS
environment.jersey().packages("com.tradier.dataloader.jobs");
}
I get the following error at runtime:
INFO [2015-04-07 15:00:19,737] com.xeiam.sundial.plugins.AnnotationJobTriggerPlugin: Loading annotated jobs from com.tradier.dataloader.jobs.
[WARNING]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:293)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.RuntimeException: Unexpected problem: No resource for com/tradier/dataloader/jobs
at org.quartz.classloading.CascadingClassLoadHelper.getJobClasses(CascadingClassLoadHelper.java:217)
at com.xeiam.sundial.plugins.AnnotationJobTriggerPlugin.start(AnnotationJobTriggerPlugin.java:72)
at org.quartz.QuartzScheduler.startPlugins(QuartzScheduler.java:1102)
at org.quartz.QuartzScheduler.start(QuartzScheduler.java:211)
at com.xeiam.sundial.SundialJobScheduler.startScheduler(SundialJobScheduler.java:102)
Check out a working example at https://github.com/timmolter/XDropWizard. It uses annotated jobs. You need to add the package name conatining the annotated jobs in your config.yaml file like this:
sundial:
thread-pool-size: 5
shutdown-on-unload: true
wait-on-shutdown: false
start-delay-seconds: 0
start-scheduler-on-load: true
global-lock-on-load: false
annotated-jobs-package-name: org.knowm.xdropwizard.jobs
If you still are getting an exception, leave a report at: https://github.com/timmolter/dropwizard-sundial/issues.
#Jeyashree Narayanan, the jobs package should not be configured in the application class as you have shown, it can be easily done in the yml file. Here is the explanation in simple steps:
Step 1: Configuration in yml file and the Configuration class
sundial:
thread-pool-size: 10
shutdown-on-unload: true
start-delay-seconds: 0
start-scheduler-on-load: true
global-lock-on-load: false
annotated-jobs-package-name: com.tradier.dataloader.jobs
tasks: [startjob, stopjob]
Configuration Class:
#JsonIgnoreProperties(ignoreUnknown = true)
public class DropwizardSundialConfiguration extends Configuration {
#Valid
#NotNull
public SundialConfiguration sundialConfiguration = new SundialConfiguration();
#JsonProperty("sundial")
public SundialConfiguration getSundialConfiguration() {
return sundialConfiguration;
}
}
Step 2: Add and configure the dropwizard-sundial bundle in the application class.
public class DropwizardSundialApplication extends Application<DropwizardSundialConfiguration> {
private static final Logger logger = LoggerFactory.getLogger(DropwizardSundialApplication.class);
public static void main(String[] args) throws Exception {
new DropwizardSundialApplication().run("server", args[0]);
}
#Override
public void initialize(Bootstrap<DropwizardSundialConfiguration> b) {
b.addBundle(new SundialBundle<DropwizardSundialConfiguration>() {
#Override
public SundialConfiguration getSundialConfiguration(DropwizardSundialConfiguration configuration) {
return configuration.getSundialConfiguration();
}
});
}
}
Step 3: Add the required job classes.
Here is a sample Cron job class:
#CronTrigger(cron = "0 19 13 * * ?")
public class CronJob extends Job {
private static final Logger logger = LoggerFactory.getLogger(CronJob.class);
#Override
public void doRun() throws JobInterruptException {
logger.info("Hello from Cron Job");
}
}
I have also written a blog post and a working application which is available on GitHub with these steps. Please check: http://softwaredevelopercentral.blogspot.com/2019/05/dropwizard-sundial-scheduler-tutorial.html
It appears to be a classpath issue.
From https://github.com/timmolter/Sundial/blob/develop/src/main/java/com/xeiam/sundial/SundialJobScheduler.java#L102:
public static void startScheduler(int threadPoolSize, String annotatedJobsPackageName) {
try {
createScheduler(threadPoolSize, annotatedJobsPackageName);
getScheduler().start(); // ---> Line 102
} catch (SchedulerException e) {
logger.error("COULD NOT START SUNDIAL SCHEDULER!!!", e);
throw new SchedulerStartupException(e);
}
I'm also using Sundial in my dropwizard project, I have all my jobs defined in jobs.xml, Sundial config defined in the .yaml file, and start it as follows:
SundialJobScheduler.startScheduler();
SundialManager sm = new SundialManager(config.getSundialConfiguration(),environment);
environment.lifecycle().manage(sm);
We use Mercury Quality Center 9 for storage tests and test results.
I need to read test data from Test Plan and to write test result into Test Lab via java.
I tried to find about this in google but I have not found anything.
UPDATE:
I tried to use qctools4j for working with MQC 9 with the following code:
public void connect() {
try{
IQcConnection conn = QcConnectionFactory.createConnection("http://qc/qcbin");
conn.connect("login", "password", "DEFAULT","project");
TestClient tc = conn.getTestClient();
System.out.println("Connection success!!!");
}
catch (QcException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
I got the following exception message:
*org.qctools4j.exception.QcException: Can't co-create object
at org.qctools4j.clients.QcConnectionImpl.initConnection(Unknown Source)
at org.qctools4j.clients.QcConnectionImpl.<init>(Unknown Source)
at org.qctools4j.QcConnectionFactory.createConnection(Unknown Source)
at automation_framework1.automation_framework1.QCWorker.connect1(QCWorker.java:38)
at automation_framework1.automation_framework1.Main.main(Main.java:12)
Caused by: com.jacob.com.ComFailException: Can't co-create object
at com.jacob.com.Dispatch.createInstanceNative(Native Method)
at com.jacob.com.Dispatch.<init>(Dispatch.java:99)
at com.jacob.activeX.ActiveXComponent.<init>(ActiveXComponent.java:58)
at org.qctools4j.clients.QcConnectionImpl.initConnection(Unknown Source)*
What am I doing wrong?
I took part in developping QC 9 and I am not sure there is Java API. However, there is a COM interface or OTA API. You can use some library that helps to call COM API from Java.
For example:
Jacob it is open source and here are some examples.
Nevaobject - it is commercial but more stable.
Good luck!
EDIT:
just saw qctools4j (it is based on Jacob) - never tried it.
I found how to solve the problem. I used groovy scriptom with the following code (may be it will help somebody):
def tdc;
public QualityCenterController(){
static{
System.load("C:\\WINDOWS\\system32\\OTAClient.dll");
System.load("D:\\Work\\automation_framework\\libs\\lib\\jacob-1.16-M2-x86.dll");
}
public void connect(){
tdc = new ActiveXObject ("TDApiOle80.TDConnection");
tdc.InitConnectionEx("http://qc/qcbin");
tdc.Login("username", "password");
tdc.Connect("DEFAULT","PROJECT");
System.out.println("login is success");
}
//ReqFactory Object
public void getRequirements(){
def requironmetns = tdc.ReqFactory();
def listReq = requironmetns.NewList("");
for (def iterReq : listReq) {
getRequirement(iterReq);
}
println listReq.count();
}
//Req Object
public void getRequirement(def itemReq){
println 'ID: '+itemReq.ID();
println 'Name:' + itemReq.Name();
println 'Path:' + itemReq.Path();
println 'Reviewed:' + itemReq.Reviewed();
println 'Author:' + itemReq.Author();
println 'Priority: ' + itemReq.Priority();
println 'Comment: '+removeHtmlTag(itemReq.Comment());
println 'Type: ' + itemReq.Type();
}
public Test getTestsFromTestLab(String path){
Test resultTest = new Test();
def labFolder = tdc.TestSetTreeManager.NodeByPath(path);
def tsList = labFolder.FindTestInstances("");
for (def iterable_element : tsList){
Test test = getTestData(iterable_element);
def steps = iterable_element.Test().DesignStepFactory();
TestStep testStep = getTest(steps);
}
return resultTest;
}
public TestStep getTest(def testData){
TestStep testStep = new TestStep();
def listSteps = testData.NewList("");
for(def item1 : listSteps){
testStep = getTestStepData(item1);
showTestStep(testStep);
}
return testStep;
}
private TestStep getTestStepData(def stepData){
TestStep testStep = new TestStep();
testStep.setId(stepData.ID());
testStep.setName(stepData.StepName());
testStep.setDescription(removeHtmlTag(stepData.StepDescription()));
testStep.setExpected(removeHtmlTag(stepData.StepExpectedResult()));
testStep.setStepOrder(stepData.Order());
return testStep;
}
public Test getTestData(def testData){
Test test = new Test();
test.setId(Integer.parseInt(testData.Id()));
test.setName(testData.Name());
test.setExecStatus(testData.Status());
showTest(test);
return test;
}
private String removeHtmlTag(String html){
String result = "";
result = Jsoup.parse(html).text();
return result;
}
public void showTestStep(TestStep testStep){
println testStep.getId();
println testStep.getName();
println testStep.getDescription();
println testStep.getExpected();
println testStep.getStepOrder();
}
public void showTest(Test test){
println test.getId();
println test.getName();
println test.getExecStatus();
}