galen icon indicating copy to clipboard operation
galen copied to clipboard

Implement Serializable interface to GalenTestInfo Class

Open dhapolapankaj opened this issue 6 years ago • 3 comments

Hello Team,

Can we add every new report to existing Galen report?

I have created a jar file which will

  1. attach to the existing browser session
  2. Using GSpecfile and Expected Image, it perform Galen Checks
  3. It generate Results
  4. Jar file execution is complete

I am passing below parameter while executing the jar file.

java -DSessionID="c0888bc7befe99465fdc7cc6ac539565" -DWebDriverListnerURL="http://localhost:62922" -DSpecFilePath="Specfiles\Test001.gspec" -DBrowserDimensionToTestOn="1290x960" -DStepNumber="11" -DResultFolderPath="C:\Projects\EclipseWorkspace" -jar MyJarfile.jar

Now I am calling this Jar file using external process, hence for each call it will create separate folder like below

image Now each folder contains its own report.html

image

Now do we have any possibility to collate all this exclusive session result together?

Thanks PD

dhapolapankaj avatar Apr 21 '18 12:04 dhapolapankaj

Hi @ishubin I did some research. I concluded that we need to implement the Serializable interface to class com.galenframework.reports.GalenTestInfo

Would it be possible for you to prioritize this request?

I realized I can extends this Class GalentTestInfo and implement Serializable to MyCustomClass but here still we need a default no argument constructor in super class i.e. GalenTestInfo class

dhapolapankaj avatar May 14 '18 04:05 dhapolapankaj

Hi @ishubin I made some more advancement for this issue. I realized we have Jackson Json Api already used.

I tried using the ObjectMapper object's mapper.writeValue(new File(strFilePathName), testLists); and
allTestLists = obj.readValue(new File(strFilePathName), obj.getTypeFactory().constructCollectionType(List.class, GalenTestInfo.class));

It is failing to read the object value and complaining about the default construtor for Class GalenTestInfo

Now in next approach I created a Class called GTGalenTestInfo to extend the GalenTestInfo and implments Serializable

and Created a List<GTGalenTestInfo> to save this info as object.

while saving I am getting error message

com.fasterxml.jackson.databind.JsonMappingException: Direct self-reference leading to cycle (through reference chain: java.util.LinkedList[0]->com.gt.lib.GTGalenTestInfo["galenTestInfo"]) at com.fasterxml.jackson.databind.ser.BeanPropertyWriter._handleSelfReference(BeanPropertyWriter.java:724) at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:499) at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:639) at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:152) at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:117) at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23) at com.fasterxml.jackson.databind.ser.std.AsArraySerializerBase.serialize(AsArraySerializerBase.java:183) at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:114) at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:2866) at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:2272) at com.gt.lib.GalenImageComparer.SerializeReportToDisk(GalenImageComparer.java:124) at com.gt.lib.GalenImageComparer.doCompare(GalenImageComparer.java:62)

any suggestion?

dhapolapankaj avatar May 15 '18 11:05 dhapolapankaj

Hi @ishubin I did some more digging. This is actually not an issue but an enhancement request to have GalenTestInfo to be exported as JSON and later on imported. So that we could use LinkedList<GalenTestInfo>.add(GalenTestInfo) and later on Generate HTML report of all this list.

Do you think we can get this capability implemented?

Thanks PD

dhapolapankaj avatar May 23 '18 12:05 dhapolapankaj