-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTML + Groovy template #55
- Loading branch information
Showing
7 changed files
with
146 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
core/modules/core/test/integration/HtmlGroovyIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package integration; | ||
|
||
import com.haulmont.yarg.formatters.ReportFormatter; | ||
import com.haulmont.yarg.formatters.factory.DefaultFormatterFactory; | ||
import com.haulmont.yarg.formatters.factory.FormatterFactoryInput; | ||
import com.haulmont.yarg.structure.BandData; | ||
import com.haulmont.yarg.structure.BandOrientation; | ||
import com.haulmont.yarg.structure.ReportOutputType; | ||
import com.haulmont.yarg.structure.impl.ReportTemplateImpl; | ||
import junit.framework.Assert; | ||
import org.apache.commons.io.FileUtils; | ||
import org.apache.commons.io.IOUtils; | ||
import org.junit.Test; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.util.HashSet; | ||
|
||
public class HtmlGroovyIntegrationTest { | ||
@Test | ||
public void testHtmlFormatter() throws Exception { | ||
BandData root = new BandData("Root", null, BandOrientation.HORIZONTAL); | ||
|
||
BandData userBand = new BandData("User", root, BandOrientation.HORIZONTAL); | ||
userBand.addData("active", true); | ||
userBand.addData("login", "admin"); | ||
root.addChild(userBand); | ||
root.setFirstLevelBandDefinitionNames(new HashSet<String>()); | ||
root.getFirstLevelBandDefinitionNames().add("User"); | ||
|
||
FileOutputStream outputStream = new FileOutputStream("./result/integration/html-groovy-test-result.html"); | ||
|
||
ReportFormatter formatter = new DefaultFormatterFactory().createFormatter(new FormatterFactoryInput("html", root, | ||
new ReportTemplateImpl("", "./modules/core/test/integration/html-groovy-test-template.html", | ||
"./modules/core/test/integration/html-groovy-test-template.html", ReportOutputType.html, true), outputStream)); | ||
|
||
formatter.renderDocument(); | ||
|
||
IOUtils.closeQuietly(outputStream); | ||
|
||
File sample = new File("./modules/core/test/integration/html-groovy-test-template-result.html"); | ||
File result = new File("./result/integration/html-groovy-test-result.html"); | ||
boolean isTwoEqual = FileUtils.contentEqualsIgnoreEOL(sample, result, null); | ||
|
||
Assert.assertTrue("Files are not equal", isTwoEqual); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
core/modules/core/test/integration/html-groovy-test-template-result.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http:https://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | ||
<html xmlns="http:https://www.w3.org/1999/xhtml" xml:lang="ru"> | ||
<head> | ||
<title> Report User </title> | ||
<style type="text/css"> | ||
body {font-family: 'Charis SIL', sans-serif;} | ||
tbody tr {height:20px; min-height:20px} | ||
|
||
</style> | ||
</head> | ||
<body> | ||
|
||
<p>Login: admin</p> | ||
<p>Active: true</p> | ||
</body> | ||
</html> |
17 changes: 17 additions & 0 deletions
17
core/modules/core/test/integration/html-groovy-test-template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http:https://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | ||
<html xmlns="http:https://www.w3.org/1999/xhtml" xml:lang="ru"> | ||
<head> | ||
<title> Report User </title> | ||
<style type="text/css"> | ||
body {font-family: 'Charis SIL', sans-serif;} | ||
tbody tr {height:20px; min-height:20px} | ||
|
||
</style> | ||
</head> | ||
<body> | ||
<% def user = Root.bands.User %> | ||
<p>Login: ${user.fields.login.first()}</p> | ||
<p>Active: ${user.fields.active.first()}</p> | ||
</body> | ||
</html> |