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
7778c07d
Commit
7778c07d
authored
Jul 03, 2015
by
Peter van 't Hof
Browse files
Fix code style warnings
parent
1ac69d32
Changes
14
Hide whitespace changes
Inline
Side-by-side
public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/core/config/ConfigTest.scala
View file @
7778c07d
...
...
@@ -24,7 +24,7 @@ import org.testng.annotations.{ DataProvider, Test }
* Created by pjvan_thof on 1/8/15.
*/
class
ConfigTest
extends
TestNGSuite
with
Matchers
with
ConfigUtils
.
ImplicitConversions
{
@Test
def
testLoadConfigFile
:
Unit
=
{
@Test
def
testLoadConfigFile
()
:
Unit
=
{
val
config
=
new
Config
config
.
loadConfigFile
(
ConfigTest
.
file
)
config
.
map
shouldBe
ConfigTest
.
map
...
...
@@ -32,7 +32,7 @@ class ConfigTest extends TestNGSuite with Matchers with ConfigUtils.ImplicitConv
config
.
map
shouldBe
ConfigTest
.
map
}
@Test
def
testContains
:
Unit
=
{
@Test
def
testContains
()
:
Unit
=
{
ConfigTest
.
config
.
contains
(
"m1"
)
shouldBe
true
ConfigTest
.
config
.
contains
(
"notexist"
)
shouldBe
false
ConfigTest
.
config
.
contains
(
new
ConfigValueIndex
(
"m1"
,
Nil
,
"k1"
))
shouldBe
true
...
...
@@ -40,23 +40,23 @@ class ConfigTest extends TestNGSuite with Matchers with ConfigUtils.ImplicitConv
ConfigTest
.
config
.
contains
(
new
ConfigValueIndex
(
"notexist"
,
Nil
,
"k1"
,
false
))
shouldBe
false
}
@Test
def
testApply
:
Unit
=
{
@Test
def
testApply
()
:
Unit
=
{
ConfigTest
.
config
(
"m1"
,
Nil
,
"k1"
).
asString
shouldBe
"v2"
ConfigTest
.
config
(
"m1"
,
Nil
,
"notexist"
,
default
=
"default"
).
asString
shouldBe
"default"
}
@Test
def
testMergeConfigs
:
Unit
=
{
@Test
def
testMergeConfigs
()
:
Unit
=
{
val
map1
=
Map
(
"1"
->
1
)
val
map2
=
Map
(
"2"
->
2
)
Config
.
mergeConfigs
(
new
Config
(
map1
),
new
Config
(
map2
)).
map
shouldBe
ConfigUtils
.
mergeMaps
(
map1
,
map2
)
}
@Test
def
testToString
:
Unit
=
{
@Test
def
testToString
()
:
Unit
=
{
val
map1
=
Map
(
"1"
->
1
)
new
Config
(
map1
).
toString
()
shouldBe
map1
.
toString
()
}
@Test
def
testSkipNested
:
Unit
=
{
@Test
def
testSkipNested
()
:
Unit
=
{
val
map
=
Map
(
"1"
->
Map
(
"2"
->
Map
(
"4"
->
Map
(
"5"
->
Map
(
"k1"
->
"v1"
)))))
Config
.
getValueFromMap
(
map
,
new
ConfigValueIndex
(
"5"
,
List
(
"1"
,
"2"
,
"4"
,
"5"
),
"k1"
)).
get
.
asString
shouldBe
"v1"
Config
.
getValueFromMap
(
map
,
new
ConfigValueIndex
(
"5"
,
List
(
"1"
,
"2"
,
"3"
,
"4"
,
"5"
),
"k1"
)).
get
.
asString
shouldBe
"v1"
...
...
public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/core/config/ConfigValueTest.scala
View file @
7778c07d
...
...
@@ -26,7 +26,7 @@ import org.testng.annotations.Test
*/
class
ConfigValueTest
extends
TestNGSuite
with
Matchers
{
val
index
=
ConfigValueIndex
(
""
,
Nil
,
""
)
@Test
def
testAs
:
Unit
=
{
@Test
def
testAs
()
:
Unit
=
{
ConfigValue
(
index
,
index
,
"bla"
).
asString
shouldBe
"bla"
ConfigValue
(
index
,
index
,
1
).
asInt
shouldBe
1
ConfigValue
(
index
,
index
,
1.0
).
asDouble
shouldBe
1.0
...
...
@@ -37,7 +37,7 @@ class ConfigValueTest extends TestNGSuite with Matchers {
ConfigValue
(
index
,
index
,
List
(
"bla"
)).
asFileList
shouldBe
List
(
new
File
(
"bla"
))
}
@Test
def
testToString
:
Unit
=
{
ConfigValue
(
index
,
index
,
"bla"
,
true
).
toString
.
getClass
.
getSimpleName
shouldBe
"String"
@Test
def
testToString
()
:
Unit
=
{
ConfigValue
(
index
,
index
,
"bla"
,
default
=
true
).
toString
.
getClass
.
getSimpleName
shouldBe
"String"
}
}
public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/core/config/ConfigurableTest.scala
View file @
7778c07d
...
...
@@ -23,7 +23,7 @@ import org.testng.annotations.Test
* Created by pjvan_thof on 1/8/15.
*/
class
ConfigurableTest
extends
TestNGSuite
with
Matchers
{
@Test
def
testConfigurable
:
Unit
=
{
@Test
def
testConfigurable
()
:
Unit
=
{
val
classC
=
new
ClassC
{
override
def
configName
=
"classc"
override
val
globalConfig
=
new
Config
(
ConfigurableTest
.
map
)
...
...
public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/extensions/GsnapTest.scala
View file @
7778c07d
...
...
@@ -26,7 +26,7 @@ import scala.sys.process.{ Process, ProcessLogger }
class
GsnapTest
extends
TestNGSuite
with
Matchers
{
private
def
setConfig
(
key
:
String
,
value
:
String
)
:
Map
[
String
,
Any
]
=
{
val
oldMap
:
Map
[
String
,
Any
]
=
Config
.
global
.
map
.
toMap
val
oldMap
:
Map
[
String
,
Any
]
=
Config
.
global
.
map
Config
.
global
.
map
+=
(
key
->
value
)
oldMap
}
...
...
public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/extensions/picard/CollectAlignmentSummaryMetricsTest.scala
View file @
7778c07d
...
...
@@ -28,7 +28,7 @@ import org.testng.annotations.Test
class
CollectAlignmentSummaryMetricsTest
extends
TestNGSuite
with
Matchers
{
@Test
def
summaryData
:
Unit
=
{
def
summaryData
()
:
Unit
=
{
val
file
=
new
File
(
Paths
.
get
(
getClass
.
getResource
(
"/picard.alignmentMetrics"
).
toURI
).
toString
)
val
job
=
new
CollectAlignmentSummaryMetrics
(
null
)
job
.
output
=
file
...
...
public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/extensions/picard/CollectInsertSizeMetricsTest.scala
View file @
7778c07d
...
...
@@ -28,7 +28,7 @@ import org.testng.annotations.Test
class
CollectInsertSizeMetricsTest
extends
TestNGSuite
with
Matchers
{
@Test
def
summaryData
:
Unit
=
{
def
summaryData
()
:
Unit
=
{
val
file
=
new
File
(
Paths
.
get
(
getClass
.
getResource
(
"/picard.insertsizemetrics"
).
toURI
).
toString
)
val
job
=
new
CollectInsertSizeMetrics
(
null
)
job
.
output
=
file
...
...
public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/extensions/picard/MarkDuplicatesTest.scala
View file @
7778c07d
...
...
@@ -28,7 +28,7 @@ import org.testng.annotations.Test
class
MarkDuplicatesTest
extends
TestNGSuite
with
Matchers
{
@Test
def
summaryData
:
Unit
=
{
def
summaryData
()
:
Unit
=
{
val
file
=
new
File
(
Paths
.
get
(
getClass
.
getResource
(
"/picard.dedup.metrics"
).
toURI
).
toString
)
val
job
=
new
MarkDuplicates
(
null
)
job
.
outputMetrics
=
file
...
...
public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/FastqSyncTest.scala
View file @
7778c07d
...
...
@@ -61,8 +61,8 @@ class FastqSyncTest extends TestNGSuite with MockitoSugar with Matchers {
val
(
numDiscard1
,
numDiscard2
,
numKept
)
=
syncFastq
(
refMock
,
aMock
,
bMock
,
aOutMock
,
bOutMock
)
obs
.
verify
(
aOutMock
).
write
(
exp
(
0
)
)
obs
.
verify
(
bOutMock
).
write
(
exp
(
0
)
)
obs
.
verify
(
aOutMock
).
write
(
exp
.
head
)
obs
.
verify
(
bOutMock
).
write
(
exp
.
head
)
obs
.
verify
(
aOutMock
).
write
(
exp
(
1
))
obs
.
verify
(
bOutMock
).
write
(
exp
(
1
))
...
...
@@ -156,8 +156,8 @@ class FastqSyncTest extends TestNGSuite with MockitoSugar with Matchers {
val
(
numDiscard1
,
numDiscard2
,
numKept
)
=
syncFastq
(
refMock
,
aMock
,
bMock
,
aOutMock
,
bOutMock
)
// exp(1) is discarded by syncFastq
obs
.
verify
(
aOutMock
).
write
(
exp
(
0
)
)
obs
.
verify
(
bOutMock
).
write
(
exp
(
0
)
)
obs
.
verify
(
aOutMock
).
write
(
exp
.
head
)
obs
.
verify
(
bOutMock
).
write
(
exp
.
head
)
obs
.
verify
(
aOutMock
).
write
(
exp
(
2
))
obs
.
verify
(
bOutMock
).
write
(
exp
(
2
))
...
...
public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/SeqStatTest.scala
View file @
7778c07d
...
...
@@ -92,7 +92,7 @@ class SeqStatTest extends TestNGSuite with MockitoSugar with Matchers {
baseHistogram
(
39
)
shouldEqual
5
baseHistogram
(
34
)
shouldEqual
5
baseHistogram
(
33
)
shouldEqual
5
baseHistogram
(
0
)
shouldEqual
5
baseHistogram
.
head
shouldEqual
5
}
@Test
def
testArgsMinimum
()
=
{
...
...
public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/VcfStatsTest.scala
View file @
7778c07d
...
...
@@ -29,7 +29,7 @@ import scala.collection.mutable
class
VcfStatsTest
extends
TestNGSuite
with
Matchers
{
@Test
def
testSampleToSampleStats
:
Unit
=
{
def
testSampleToSampleStats
()
:
Unit
=
{
val
s1
=
SampleToSampleStats
()
val
s2
=
SampleToSampleStats
()
s1
.
alleleOverlap
shouldBe
0
...
...
@@ -60,7 +60,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
}
@Test
def
testSampleStats
:
Unit
=
{
def
testSampleStats
()
:
Unit
=
{
val
s1
=
SampleStats
()
val
s2
=
SampleStats
()
...
...
@@ -94,7 +94,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
}
@Test
def
testAlleleOverlap
:
Unit
=
{
def
testAlleleOverlap
()
:
Unit
=
{
val
a1
=
Allele
.
create
(
"G"
)
val
a2
=
Allele
.
create
(
"A"
)
...
...
public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/VepNormalizerTest.scala
View file @
7778c07d
...
...
@@ -92,21 +92,21 @@ class VepNormalizerTest extends TestNGSuite with MockitoSugar with Matchers {
val
reader
=
new
VCFFileReader
(
vepped
,
false
)
val
header
=
reader
.
getFileHeader
val
new_infos
=
parseCsq
(
header
)
explodeTranscripts
(
reader
.
iterator
().
next
(),
new_infos
,
true
).
length
should
be
(
11
)
explodeTranscripts
(
reader
.
iterator
().
next
(),
new_infos
,
removeCsq
=
true
).
length
should
be
(
11
)
}
@Test
def
testStandardVEPLength
()
=
{
val
reader
=
new
VCFFileReader
(
vepped
,
false
)
val
header
=
reader
.
getFileHeader
val
new_infos
=
parseCsq
(
header
)
Array
(
standardTranscripts
(
reader
.
iterator
().
next
(),
new_infos
,
true
)).
length
should
be
(
1
)
Array
(
standardTranscripts
(
reader
.
iterator
().
next
(),
new_infos
,
removeCsq
=
true
)).
length
should
be
(
1
)
}
@Test
def
testStandardVEPAttributeLength
()
=
{
val
reader
=
new
VCFFileReader
(
vepped
,
false
)
val
header
=
reader
.
getFileHeader
val
new_infos
=
parseCsq
(
header
)
val
record
=
standardTranscripts
(
reader
.
iterator
().
next
(),
new_infos
,
true
)
val
record
=
standardTranscripts
(
reader
.
iterator
().
next
(),
new_infos
,
removeCsq
=
true
)
def
checkItems
(
items
:
Array
[
String
])
=
{
items
.
foreach
{
check
}
}
...
...
public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/WipeReadsTest.scala
View file @
7778c07d
...
...
@@ -195,7 +195,7 @@ class WipeReadsTest extends TestNGSuite with MockitoSugar with Matchers {
// and only filling the filter with a few items
val
filterNotFunc
=
makeFilterNotFunction
(
intervals
,
sBamFile1
,
bloomSize
=
bloomSize
,
bloomFp
=
bloomFp
)
// by default, set elements are SAM record read names
filterNotFunc
(
sBamRecs1
(
0
)
)
shouldBe
false
filterNotFunc
(
sBamRecs1
.
head
)
shouldBe
false
filterNotFunc
(
sBamRecs1
(
1
))
shouldBe
true
filterNotFunc
(
sBamRecs1
(
2
))
shouldBe
true
filterNotFunc
(
sBamRecs1
(
3
))
shouldBe
true
...
...
@@ -211,7 +211,7 @@ class WipeReadsTest extends TestNGSuite with MockitoSugar with Matchers {
new
Interval
(
"P"
,
191
,
480
)
)
val
filterNotFunc
=
makeFilterNotFunction
(
intervals
,
sBamFile1
,
bloomSize
=
bloomSize
,
bloomFp
=
bloomFp
)
filterNotFunc
(
sBamRecs1
(
0
)
)
shouldBe
false
filterNotFunc
(
sBamRecs1
.
head
)
shouldBe
false
filterNotFunc
(
sBamRecs1
(
1
))
shouldBe
true
filterNotFunc
(
sBamRecs1
(
2
))
shouldBe
true
filterNotFunc
(
sBamRecs1
(
3
))
shouldBe
true
...
...
@@ -225,7 +225,7 @@ class WipeReadsTest extends TestNGSuite with MockitoSugar with Matchers {
new
Interval
(
"chrQ"
,
881
,
1000
)
// overlaps first exon of r05
)
val
filterNotFunc
=
makeFilterNotFunction
(
intervals
,
sBamFile1
,
bloomSize
=
bloomSize
,
bloomFp
=
bloomFp
)
filterNotFunc
(
sBamRecs1
(
0
)
)
shouldBe
false
filterNotFunc
(
sBamRecs1
.
head
)
shouldBe
false
filterNotFunc
(
sBamRecs1
(
1
))
shouldBe
false
filterNotFunc
(
sBamRecs1
(
2
))
shouldBe
false
filterNotFunc
(
sBamRecs1
(
3
))
shouldBe
false
...
...
@@ -240,7 +240,7 @@ class WipeReadsTest extends TestNGSuite with MockitoSugar with Matchers {
new
Interval
(
"chrQ"
,
900
,
920
)
)
val
filterNotFunc
=
makeFilterNotFunction
(
intervals
,
sBamFile1
,
bloomSize
=
bloomSize
,
bloomFp
=
bloomFp
)
filterNotFunc
(
sBamRecs1
(
0
)
)
shouldBe
false
filterNotFunc
(
sBamRecs1
.
head
)
shouldBe
false
filterNotFunc
(
sBamRecs1
(
1
))
shouldBe
false
filterNotFunc
(
sBamRecs1
(
2
))
shouldBe
false
filterNotFunc
(
sBamRecs1
(
3
))
shouldBe
false
...
...
@@ -256,7 +256,7 @@ class WipeReadsTest extends TestNGSuite with MockitoSugar with Matchers {
new
Interval
(
"chrR"
,
500
,
505
)
)
val
filterNotFunc
=
makeFilterNotFunction
(
intervals
,
sBamFile5
,
bloomSize
=
bloomSize
,
bloomFp
=
bloomFp
)
filterNotFunc
(
sBamRecs5
(
0
)
)
shouldBe
true
filterNotFunc
(
sBamRecs5
.
head
)
shouldBe
true
filterNotFunc
(
sBamRecs5
(
1
))
shouldBe
false
filterNotFunc
(
sBamRecs5
(
2
))
shouldBe
false
filterNotFunc
(
sBamRecs5
(
3
))
shouldBe
true
...
...
@@ -271,7 +271,7 @@ class WipeReadsTest extends TestNGSuite with MockitoSugar with Matchers {
)
val
filterNotFunc
=
makeFilterNotFunction
(
intervals
,
sBamFile1
,
bloomSize
=
bloomSize
,
bloomFp
=
bloomFp
,
filterOutMulti
=
false
)
filterNotFunc
(
sBamRecs1
(
0
)
)
shouldBe
false
filterNotFunc
(
sBamRecs1
.
head
)
shouldBe
false
filterNotFunc
(
sBamRecs1
(
1
))
shouldBe
false
filterNotFunc
(
sBamRecs1
(
2
))
shouldBe
true
filterNotFunc
(
sBamRecs1
(
3
))
shouldBe
true
...
...
@@ -287,7 +287,7 @@ class WipeReadsTest extends TestNGSuite with MockitoSugar with Matchers {
)
val
filterNotFunc
=
makeFilterNotFunction
(
intervals
,
sBamFile2
,
bloomSize
=
bloomSize
,
bloomFp
=
bloomFp
,
minMapQ
=
60
)
filterNotFunc
(
sBamRecs2
(
0
)
)
shouldBe
false
filterNotFunc
(
sBamRecs2
.
head
)
shouldBe
false
// r01 is not in since it is below the MAPQ threshold
filterNotFunc
(
sBamRecs2
(
1
))
shouldBe
false
filterNotFunc
(
sBamRecs2
(
2
))
shouldBe
false
...
...
@@ -305,7 +305,7 @@ class WipeReadsTest extends TestNGSuite with MockitoSugar with Matchers {
)
val
filterNotFunc
=
makeFilterNotFunction
(
intervals
,
sBamFile2
,
bloomSize
=
bloomSize
,
bloomFp
=
bloomFp
,
minMapQ
=
60
,
filterOutMulti
=
false
)
filterNotFunc
(
sBamRecs2
(
0
)
)
shouldBe
false
filterNotFunc
(
sBamRecs2
.
head
)
shouldBe
false
filterNotFunc
(
sBamRecs2
(
1
))
shouldBe
false
// this r01 is not in since it is below the MAPQ threshold
filterNotFunc
(
sBamRecs2
(
2
))
shouldBe
false
...
...
@@ -324,7 +324,7 @@ class WipeReadsTest extends TestNGSuite with MockitoSugar with Matchers {
)
val
filterNotFunc
=
makeFilterNotFunction
(
intervals
,
sBamFile2
,
bloomSize
=
bloomSize
,
bloomFp
=
bloomFp
,
readGroupIds
=
Set
(
"002"
,
"003"
))
filterNotFunc
(
sBamRecs2
(
0
)
)
shouldBe
false
filterNotFunc
(
sBamRecs2
.
head
)
shouldBe
false
// only r01 is in the set since it is RG 002
filterNotFunc
(
sBamRecs2
(
1
))
shouldBe
true
filterNotFunc
(
sBamRecs2
(
2
))
shouldBe
true
...
...
@@ -342,7 +342,7 @@ class WipeReadsTest extends TestNGSuite with MockitoSugar with Matchers {
new
Interval
(
"chrQ"
,
991
,
1000
)
// overlaps nothing; lies in the spliced region of r05
)
val
filterNotFunc
=
makeFilterNotFunction
(
intervals
,
pBamFile1
,
bloomSize
=
bloomSize
,
bloomFp
=
bloomFp
)
filterNotFunc
(
pBamRecs1
(
0
)
)
shouldBe
false
filterNotFunc
(
pBamRecs1
.
head
)
shouldBe
false
filterNotFunc
(
pBamRecs1
(
1
))
shouldBe
false
filterNotFunc
(
pBamRecs1
(
2
))
shouldBe
true
filterNotFunc
(
pBamRecs1
(
3
))
shouldBe
true
...
...
@@ -363,7 +363,7 @@ class WipeReadsTest extends TestNGSuite with MockitoSugar with Matchers {
new
Interval
(
"chrQ"
,
891
,
1000
)
)
val
filterNotFunc
=
makeFilterNotFunction
(
intervals
,
pBamFile1
,
bloomSize
=
bloomSize
,
bloomFp
=
bloomFp
)
filterNotFunc
(
pBamRecs1
(
0
)
)
shouldBe
false
filterNotFunc
(
pBamRecs1
.
head
)
shouldBe
false
filterNotFunc
(
pBamRecs1
(
1
))
shouldBe
false
filterNotFunc
(
pBamRecs1
(
2
))
shouldBe
false
filterNotFunc
(
pBamRecs1
(
3
))
shouldBe
false
...
...
@@ -387,7 +387,7 @@ class WipeReadsTest extends TestNGSuite with MockitoSugar with Matchers {
)
val
filterNotFunc
=
makeFilterNotFunction
(
intervals
,
pBamFile1
,
bloomSize
=
bloomSize
,
bloomFp
=
bloomFp
,
filterOutMulti
=
false
)
filterNotFunc
(
pBamRecs1
(
0
)
)
shouldBe
false
filterNotFunc
(
pBamRecs1
.
head
)
shouldBe
false
filterNotFunc
(
pBamRecs1
(
1
))
shouldBe
false
filterNotFunc
(
pBamRecs1
(
2
))
shouldBe
false
filterNotFunc
(
pBamRecs1
(
3
))
shouldBe
false
...
...
@@ -411,7 +411,7 @@ class WipeReadsTest extends TestNGSuite with MockitoSugar with Matchers {
val
filterNotFunc
=
makeFilterNotFunction
(
intervals
,
pBamFile2
,
bloomSize
=
bloomSize
,
bloomFp
=
bloomFp
,
minMapQ
=
60
)
// r01 is not in since it is below the MAPQ threshold
filterNotFunc
(
pBamRecs2
(
0
)
)
shouldBe
false
filterNotFunc
(
pBamRecs2
.
head
)
shouldBe
false
filterNotFunc
(
pBamRecs2
(
1
))
shouldBe
false
filterNotFunc
(
pBamRecs2
(
2
))
shouldBe
false
filterNotFunc
(
pBamRecs2
(
3
))
shouldBe
false
...
...
@@ -431,7 +431,7 @@ class WipeReadsTest extends TestNGSuite with MockitoSugar with Matchers {
val
filterNotFunc
=
makeFilterNotFunction
(
intervals
,
pBamFile2
,
bloomSize
=
bloomSize
,
bloomFp
=
bloomFp
,
readGroupIds
=
Set
(
"002"
,
"003"
))
// only r01 is in the set since it is RG 002
filterNotFunc
(
pBamRecs2
(
0
)
)
shouldBe
false
filterNotFunc
(
pBamRecs2
.
head
)
shouldBe
false
filterNotFunc
(
pBamRecs2
(
1
))
shouldBe
false
filterNotFunc
(
pBamRecs2
(
2
))
shouldBe
true
filterNotFunc
(
pBamRecs2
(
3
))
shouldBe
true
...
...
public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/utils/ConfigUtilsTest.scala
View file @
7778c07d
...
...
@@ -31,7 +31,7 @@ class ConfigUtilsTest extends TestNGSuite with Matchers {
import
ConfigUtils._
import
ConfigUtilsTest._
@Test
def
testGetValueFromPath
:
Unit
=
{
@Test
def
testGetValueFromPath
()
:
Unit
=
{
getValueFromPath
(
map1
,
List
(
"dummy"
))
shouldBe
Some
(
Map
(
"dummy"
->
1
))
getValueFromPath
(
map1
,
List
(
"dummy"
,
"dummy"
))
shouldBe
Some
(
1
)
getValueFromPath
(
map1
,
List
(
"nested3"
,
"nested2"
,
"nested1"
))
shouldBe
Some
(
Map
(
"dummy"
->
1
))
...
...
@@ -39,7 +39,7 @@ class ConfigUtilsTest extends TestNGSuite with Matchers {
getValueFromPath
(
map1
,
List
(
"dummy"
,
"notexist"
))
shouldBe
None
}
@Test
def
testGetMapFromPath
:
Unit
=
{
@Test
def
testGetMapFromPath
()
:
Unit
=
{
getMapFromPath
(
map1
,
List
(
"dummy"
))
shouldBe
Some
(
Map
(
"dummy"
->
1
))
getMapFromPath
(
map1
,
List
(
"nested3"
,
"nested2"
,
"nested1"
))
shouldBe
Some
(
Map
(
"dummy"
->
1
))
intercept
[
IllegalStateException
]
{
...
...
@@ -48,7 +48,7 @@ class ConfigUtilsTest extends TestNGSuite with Matchers {
}
// Merge maps
@Test
def
testMergeMaps
:
Unit
=
{
@Test
def
testMergeMaps
()
:
Unit
=
{
val
mergedMap
=
mergeMaps
(
map1
,
map2
)
getValueFromPath
(
mergedMap
,
List
(
"nested"
,
"1"
))
shouldBe
Some
(
1
)
getValueFromPath
(
mergedMap
,
List
(
"nested"
,
"2"
))
shouldBe
Some
(
1
)
...
...
@@ -56,7 +56,7 @@ class ConfigUtilsTest extends TestNGSuite with Matchers {
}
// Json to scala values
@Test
def
testFileToJson
:
Unit
=
{
@Test
def
testFileToJson
()
:
Unit
=
{
fileToJson
(
file1
)
shouldBe
json1
fileToJson
(
file2
)
shouldBe
json2
intercept
[
IllegalStateException
]
{
...
...
@@ -64,7 +64,7 @@ class ConfigUtilsTest extends TestNGSuite with Matchers {
}
}
@Test
def
testJsonToMap
:
Unit
=
{
@Test
def
testJsonToMap
()
:
Unit
=
{
jsonToMap
(
json1
)
shouldBe
map1
jsonToMap
(
json2
)
shouldBe
map2
intercept
[
IllegalStateException
]
{
...
...
@@ -72,13 +72,13 @@ class ConfigUtilsTest extends TestNGSuite with Matchers {
}
}
@Test
def
testFileToConfigMap
:
Unit
=
{
@Test
def
testFileToConfigMap
()
:
Unit
=
{
fileToConfigMap
(
file1
)
shouldBe
map1
fileToConfigMap
(
file2
)
shouldBe
map2
}
// Any/scala values to Json objects
@Test
def
testAnyToJson
:
Unit
=
{
@Test
def
testAnyToJson
()
:
Unit
=
{
anyToJson
(
"bla"
)
shouldBe
jString
(
"bla"
)
anyToJson
(
1337
)
shouldBe
Json
.
jNumberOrString
(
1337
)
anyToJson
(
13.37
)
shouldBe
Json
.
jNumberOrString
(
13.37
)
...
...
@@ -90,7 +90,7 @@ class ConfigUtilsTest extends TestNGSuite with Matchers {
anyToJson
(
Map
(
"bla"
->
1337
))
shouldBe
(
"bla"
:=
1337
)
->:
jEmptyObject
}
@Test
def
testMapToJson
:
Unit
=
{
@Test
def
testMapToJson
()
:
Unit
=
{
mapToJson
(
Map
())
shouldBe
jEmptyObject
mapToJson
(
Map
(
"bla"
->
1337
))
shouldBe
(
"bla"
:=
1337
)
->:
jEmptyObject
mapToJson
(
Map
(
"bla"
->
Map
()))
shouldBe
(
"bla"
:=
jEmptyObject
)
->:
jEmptyObject
...
...
@@ -98,14 +98,14 @@ class ConfigUtilsTest extends TestNGSuite with Matchers {
}
// Any to scala values
@Test
def
testAny2string
:
Unit
=
{
@Test
def
testAny2string
()
:
Unit
=
{
any2string
(
"bla"
)
shouldBe
"bla"
any2string
(
1337
)
shouldBe
"1337"
any2string
(
true
)
shouldBe
"true"
any2string
(
13.37
)
shouldBe
"13.37"
}
@Test
def
testAny2int
:
Unit
=
{
@Test
def
testAny2int
()
:
Unit
=
{
any2int
(
1337
)
shouldBe
1337
any2int
(
"1337"
)
shouldBe
1337
any2int
(
13.37
)
shouldBe
13
...
...
@@ -114,7 +114,7 @@ class ConfigUtilsTest extends TestNGSuite with Matchers {
}
}
@Test
def
testAny2long
:
Unit
=
{
@Test
def
testAny2long
()
:
Unit
=
{
any2long
(
1337L
)
shouldBe
1337L
any2long
(
1337
)
shouldBe
1337L
any2long
(
"1337"
)
shouldBe
1337L
...
...
@@ -124,7 +124,7 @@ class ConfigUtilsTest extends TestNGSuite with Matchers {
}
}
@Test
def
testAny2double
:
Unit
=
{
@Test
def
testAny2double
()
:
Unit
=
{
any2double
(
13.37
)
shouldBe
13.37d
any2double
(
"1337"
)
shouldBe
1337d
any2double
(
1337
)
shouldBe
1337d
...
...
@@ -135,7 +135,7 @@ class ConfigUtilsTest extends TestNGSuite with Matchers {
}
}
@Test
def
testAny2float
:
Unit
=
{
@Test
def
testAny2float
()
:
Unit
=
{
any2float
(
1337d
)
shouldBe
1337f
any2float
(
"1337"
)
shouldBe
1337f
any2float
(
1337
)
shouldBe
1337f
...
...
@@ -146,7 +146,7 @@ class ConfigUtilsTest extends TestNGSuite with Matchers {
}
}
@Test
def
testAny2boolean
:
Unit
=
{
@Test
def
testAny2boolean
()
:
Unit
=
{
any2boolean
(
true
)
shouldBe
true
any2boolean
(
"false"
)
shouldBe
false
any2boolean
(
"true"
)
shouldBe
true
...
...
@@ -157,21 +157,21 @@ class ConfigUtilsTest extends TestNGSuite with Matchers {
}
}
@Test
def
testAny2list
:
Unit
=
{
@Test
def
testAny2list
()
:
Unit
=
{
any2list
(
Nil
)
shouldBe
Nil
any2list
(
List
(
1
,
2
,
3
,
4
))
shouldBe
List
(
1
,
2
,
3
,
4
)
any2list
(
List
(
1337
))
shouldBe
List
(
1337
)
any2list
(
1337
)
shouldBe
List
(
1337
)
}
@Test
def
testAny2stringList
:
Unit
=
{
@Test
def
testAny2stringList
()
:
Unit
=
{
any2stringList
(
Nil
)
shouldBe
Nil
any2stringList
(
List
(
"1337"
))
shouldBe
List
(
"1337"
)
any2stringList
(
List
(
1337
))
shouldBe
List
(
"1337"
)
any2stringList
(
1337
)
shouldBe
List
(
"1337"
)
}
@Test
def
testAny2map
:
Unit
=
{
@Test
def
testAny2map
()
:
Unit
=
{
any2map
(
Map
())
shouldBe
Map
()
any2map
(
Map
(
"bla"
->
1337
))
shouldBe
Map
(
"bla"
->
1337
)
any2map
(
null
)
shouldBe
null
...
...
@@ -180,7 +180,7 @@ class ConfigUtilsTest extends TestNGSuite with Matchers {
}
}
@Test
def
testImplicits
:
Unit
=
{
@Test
def
testImplicits
()
:
Unit
=
{
val
index
=
ConfigValueIndex
(
"test"
,
Nil
,
"test"
)
new
ImplicitConversions
{
configValue2list
(
ConfigValue
(
index
,
index
,
List
(
""
)))
shouldBe
List
(
""
)
...
...
@@ -210,7 +210,7 @@ object ConfigUtilsTest {
val
w
=
new
PrintWriter
(
file
)
w
.
write
(
text
)
w
.
close
()
return
file
file
}
val
jsonText1
=
...
...
public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/utils/PackageTest.scala
View file @
7778c07d
...
...
@@ -11,13 +11,13 @@ import scala.util.Try
*/
class
PackageTest
extends
TestNGSuite
with
Matchers
{
@Test
def
testConvert
:
Unit
=
{
@Test
def
testConvert
()
:
Unit
=
{
tryToParseNumber
(
"4"
)
shouldBe
Try
(
4
)
tryToParseNumber
(
"13.37"
)
shouldBe
Try
(
13.37
)
tryToParseNumber
(
"I'm not a number"
)
should
not
be
Try
(
"I'm not a number"
)
tryToParseNumber
(
"4"
,
true
)
shouldBe
Try
(
4
)
tryToParseNumber
(
"13.37"
,
true
)
shouldBe
Try
(
13.37
)
tryToParseNumber
(
"I'm not a number"
,
true
)
shouldBe
Try
(
"I'm not a number"
)
tryToParseNumber
(
"4"
,
fallBack
=
true
)
shouldBe
Try
(
4
)
tryToParseNumber
(
"13.37"
,
fallBack
=
true
)
shouldBe
Try
(
13.37
)
tryToParseNumber
(
"I'm not a number"
,
fallBack
=
true
)
shouldBe
Try
(
"I'm not a number"
)
}
}
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