Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARQ-1878 Introduce TableEntry #11

Closed
wants to merge 6 commits into from
Closed

ARQ-1878 Introduce TableEntry #11

wants to merge 6 commits into from

Conversation

smiklosovic
Copy link
Member

@aslakknutsen could you try if it is ok for you, please?

@aslakknutsen
Copy link
Member

Awesome.. Will do :)

@aslakknutsen
Copy link
Member

Few things..

  • Is the idea to use the first TableRowEntry as the table/th ?
  • It's currently only support on Test level. What about Class and Suite?

@smiklosovic
Copy link
Member Author

  1. you are setting header via .setHeader() method on TableEntry, that should generate th tag automatically with colspan of size as there is (the biggest) number of cells in any row. If you do not set any header, just rows are generated in table tag as tr's.

Do you want to have colspan and rowspan attributes on td's as well? That would make generation of these tables pretty much flexible. However when you want to style it, you are on your own. The best option here is to make your own xsl template and set it in config (it is already done), I just can not think for all possible use cases in advance ...

  1. Yes, good catch, I have to add it there as well. I put it on test, class and suite reports and report itself.

@aslakknutsen
Copy link
Member

  1. Right, but doesn't a table with multiple cells have one header pr cell?

The 'one header per table' feature is nice, but to me that belongs more in a 'GroupEntry' or something.

group = new GroupEntry('My Tabled Data')
table = new TableEntry('header 1', 'header 2');
table.getRows().add('data 1', 'data2')
grou.add(table)

@smiklosovic
Copy link
Member Author

Aha ... well, I have to make my mind about that.

GroupEntry is not needed, multiple tables are done in such way you just add multiple TableEntries to properties and in xslt there is iteration over all tables and they get rendered one by one.

TableEntry has rows which have cells. Every cell can have colspan and rowspan, by default set to 1 for both.

I see what you want ... wait a moment

@smiklosovic
Copy link
Member Author

You basically want to have this, right?

http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_tbody

meaning this heading for every column

<thead>
    <tr>
        <th>Month</th>
        <th>Savings</th>
    </tr>
</thead>

@aslakknutsen
Copy link
Member

GroupEntry is not needed, multiple tables are done in such way you just add multiple TableEntries to properties

Right, but that would require me to add a TableEntry to a KeyValue property? I only have a 'key'..

@smiklosovic
Copy link
Member Author

Lets have TestMethodReport, it has property field like this:

@XmlElements({
    @XmlElement(name = "property", type = KeyValueEntry.class),
    @XmlElement(name = "file", type = FileEntry.class),
    @XmlElement(name = "video", type = VideoEntry.class),
    @XmlElement(name = "screenshot", type = ScreenshotEntry.class),
    @XmlElement(name = "table", type = TableEntry.class)
})
private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();

It means that you do

KeyValueEntry kve = new KeyValueEntry();
TableEntry table1 = new TableEntry();
ScreenshotEntry screenshot = new ScreenshotEntry();
TableEntry table2 = new TableEntry();

and then it will be added like (via firing these objects in property event)

getProperties().add(table1);
getProperties().add(screenshot);
getProperties().add(table2);
getProperties().add(kve);

So in that method report in xslt template, firstly you iterate over key value entries and render them, then over tables and they are rendered as well.

You can add whatever you want in that propertyEntries list as long it extends PropertyEntry and it is up to xslt to render it - it looks what that entry really is (if key-value, table or screenshot) and renders it appropriately.

You just fire table in that report event the same way you fire key-value.

The thing is when you want to add some new entry like we are adding table right now, you have to add it on that propertyEntries among XmlElements for JAXB to be able to marshall it and you have to customize your xslt template to be able to render that new one. It can not be done totally generic because you need to say xslt how some particular entry has to be rendered into html.

@aslakknutsen
Copy link
Member

<thead>
   <tr>
       <th>Month</th>
       <th>Savings</th>
   </tr>
</thead>

Correct, that's what I'm looking for when I say Table Header.

@aslakknutsen
Copy link
Member

I understand how to add it to a PropertyEntry per say. And that is fine.

What I'm wondering about is a generic way to say that this data belongs to gather / comes from the same extension.

Let's say my extension provide the report with 'n' number of KeyValueEntry elements.

I can add a bunch of 'single' KeyValueEntries like "XRebel Request=X", "XRebel SQL=X". With this a part of the key says something about where the data comes from. If we go a bit deeper I might need to say "XRebel Request Stacktrace 1=x", "XRebel Request Stacktrace 2=x".

What I was wondering instead, could we have a GroupEntry that defines these as 'one' thing.

xrebel = new GroupEntry("XRebel")
xrebel.add(new KeyValueEntry("averageTime", 10))
xrebel.add(new KeyValueEntry("numberOfRequests", 10))

sql = new GroupEntry("SQL");
sql.add(new TableEntry("time", "query").addRows(new TableRowEntry(20, "select * from x")))
xrebel.add(sql);

That could render 'roughly' as:

<div> 
  <h3>XRebel</h3>
  <dl>
    <dt>averageTime</dt>
    <dd>10</dd>
    <dt>numberOfRequests</dt>
    <dd>10</dd>
  </dl>
  <div>
    <h4>SQL</h4>
    <table>
      <theader>
        <tr><th>time</th></tr>
        <tr><th>query</th></tr>
      </theader>
      <tbody>
        <tr><td>20</td></tr>
        <tr><td>select * from x</td></tr>
      </tbody>
    </table>
  </div>
</div>

@smiklosovic
Copy link
Member Author

I see, but I do not know how to render it in xslt since this may be recursive as you are adding GroupEntry into GroupEntry. Maybe it could be possible by writing some custom xslt function which calls itself recrusivly but I have to look into it more deeper.

@aslakknutsen
Copy link
Member

Maybe xslt is not the best rendering engine for the usecase.. ;)

@smiklosovic
Copy link
Member Author

oh man, I am getting the same feeling as I want to add something to it, it is not too flexible. There is also asciidoc exporter, maybe that one comes more handy.

However I like how that HTML output looks like. I was playing with jquery yesterday and I done that collapsable thing partially. Like when you click on a test method, it gets expanded, when you click on it again, it gets collapsed. When you click on a test class, all test methods are collapsed, when you click on test suite, all test clases are collapsed ... That is the idea.

*
*/
@XmlRootElement(name = "groupEntry")
public class GroupEntry extends PropertyEntry {
Copy link
Member Author

Choose a reason for hiding this comment

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

@aslakknutsen

This should give you GroupEntry which can hold other GroupEntries in properties hence you can nested it recursively.

It holds only tables and key-values. Doing it in general is PITA and I think you basically need these two property elements with that xrebel.

XSLT transformation is not yet done, I am curious with that recursive thing.

@smiklosovic
Copy link
Member Author

@aslakknutsen could you give me ack here so I can get rid of this from my todo list, please?

@smiklosovic
Copy link
Member Author

merged and closing

@smiklosovic smiklosovic closed this Dec 3, 2014
@smiklosovic smiklosovic deleted the ARQ-1878 branch January 13, 2015 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants