Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mirrors
biopet.biopet
Commits
0a883e99
Commit
0a883e99
authored
Feb 24, 2016
by
Peter van 't Hof
Browse files
Added test to generatePages
parent
85d30737
Changes
3
Hide whitespace changes
Inline
Side-by-side
public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/report/ReportBuilder.scala
View file @
0a883e99
...
...
@@ -93,9 +93,9 @@ trait ReportBuilder extends ToolCommand {
private
var
total
=
0
private
var
_sampleId
:
Option
[
String
]
=
None
protected
def
sampleId
=
_sampleId
protected
[
report
]
def
sampleId
=
_sampleId
private
var
_libId
:
Option
[
String
]
=
None
protected
def
libId
=
_libId
protected
[
report
]
def
libId
=
_libId
case
class
ExtFile
(
resourcePath
:
String
,
targetPath
:
String
)
...
...
@@ -152,6 +152,8 @@ trait ReportBuilder extends ToolCommand {
total
=
ReportBuilder
.
countPages
(
indexPage
)
logger
.
info
(
total
+
" pages to be generated"
)
done
=
0
logger
.
info
(
"Generate pages"
)
val
jobs
=
generatePage
(
summary
,
indexPage
,
cmdArgs
.
outputDir
,
args
=
pageArgs
++
cmdArgs
.
pageArgs
.
toMap
++
...
...
public/biopet-core/src/test/resources/empty_summary.json
0 → 100644
View file @
0a883e99
{
}
\ No newline at end of file
public/biopet-core/src/test/scala/nl/lumc/sasc/biopet/core/report/ReportBuilderTest.scala
View file @
0a883e99
package
nl.lumc.sasc.biopet.core.report
import
java.io.File
import
java.nio.file.Paths
import
com.google.common.io.Files
import
org.scalatest.Matchers
import
org.scalatest.testng.TestNGSuite
import
org.testng.annotations.Test
import
org.testng.annotations.
{
DataProvider
,
Test
}
/**
* Created by pjvanthof on 24/02/16.
*/
class
ReportBuilderTest
extends
TestNGSuite
with
Matchers
{
private
def
resourcePath
(
p
:
String
)
:
String
=
{
Paths
.
get
(
getClass
.
getResource
(
p
).
toURI
).
toString
}
@DataProvider
(
name
=
"testGeneratePages"
)
def
generatePageProvider
=
{
val
sample
=
Array
(
Some
(
"sampleName"
),
None
)
val
lib
=
Array
(
Some
(
"libName"
),
None
)
val
nested
=
Array
(
false
,
true
)
for
(
s
<-
sample
;
l
<-
lib
;
n
<-
nested
)
yield
Array
(
s
,
l
,
n
)
}
@Test
(
dataProvider
=
"testGeneratePages"
)
def
testGeneratePages
(
sample
:
Option
[
String
],
lib
:
Option
[
String
],
nested
:
Boolean
)
:
Unit
=
{
val
builder
=
new
ReportBuilder
{
def
reportName
:
String
=
"test"
def
indexPage
:
ReportPage
=
ReportPage
(
(
if
(
nested
)
"p1"
->
ReportPage
(
Nil
,
Nil
,
Map
())
::
Nil
else
Nil
),
Nil
,
Map
())
}
val
tempDir
=
Files
.
createTempDir
()
tempDir
.
deleteOnExit
()
val
args
=
Array
(
"-s"
,
resourcePath
(
"/empty_summary.json"
),
"-o"
,
tempDir
.
getAbsolutePath
)
++
sample
.
map
(
x
=>
Array
(
"-a"
,
s
"sampleId=$x"
)).
getOrElse
(
Array
())
++
lib
.
map
(
x
=>
Array
(
"-a"
,
s
"libId=$x"
)).
getOrElse
(
Array
())
builder
.
main
(
args
)
builder
.
sampleId
shouldBe
sample
builder
.
libId
shouldBe
lib
builder
.
extFiles
.
foreach
(
x
=>
new
File
(
tempDir
,
"ext"
+
File
.
separator
+
x
.
targetPath
)
should
exist
)
new
File
(
tempDir
,
"index.html"
)
should
exist
new
File
(
tempDir
,
"p1"
+
File
.
separator
+
"index.html"
).
exists
()
shouldBe
nested
}
@Test
def
testCountPages
:
Unit
=
{
ReportBuilder
.
countPages
(
ReportPage
(
Nil
,
Nil
,
Map
()))
shouldBe
1
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment