Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
biopet.biopet
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirrors
biopet.biopet
Commits
913d16ec
Commit
913d16ec
authored
10 years ago
by
Peter van 't Hof
Browse files
Options
Downloads
Patches
Plain Diff
Added unit tests to Configurable
parent
199f0693
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/core/config/ConfigurableTest.scala
+71
-0
71 additions, 0 deletions
...la/nl/lumc/sasc/biopet/core/config/ConfigurableTest.scala
with
71 additions
and
0 deletions
public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/core/config/ConfigurableTest.scala
0 → 100644
+
71
−
0
View file @
913d16ec
package
nl.lumc.sasc.biopet.core.config
import
nl.lumc.sasc.biopet.utils.
{
ConfigUtils
,
ConfigUtilsTest
}
import
org.scalatest.Matchers
import
org.scalatest.mock.MockitoSugar
import
org.scalatest.testng.TestNGSuite
import
org.testng.annotations.Test
/**
* Created by pjvan_thof on 1/8/15.
*/
class
ConfigurableTest
extends
TestNGSuite
with
MockitoSugar
with
Matchers
{
@Test
def
testConfigurable
:
Unit
=
{
Config
.
global
.
map
=
Map
()
Config
.
global
.
loadConfigFile
(
ConfigurableTest
.
file
)
val
classC
=
new
ClassC
classC
.
configPath
shouldBe
Nil
classC
.
configFullPath
shouldBe
List
(
"classc"
)
classC
.
classB
.
configPath
shouldBe
List
(
"classc"
)
classC
.
classB
.
configFullPath
shouldBe
List
(
"classc"
,
"classb"
)
classC
.
classB
.
classA
.
configPath
shouldBe
List
(
"classc"
,
"classb"
)
classC
.
classB
.
classA
.
configFullPath
shouldBe
List
(
"classc"
,
"classb"
,
"classa"
)
classC
.
get
(
"k1"
).
asString
shouldBe
"c1"
classC
.
classB
.
get
(
"k1"
).
asString
shouldBe
"c1"
classC
.
classB
.
classA
.
get
(
"k1"
).
asString
shouldBe
"c1"
classC
.
get
(
"notexist"
)
shouldBe
null
intercept
[
IllegalStateException
]
{
classC
.
get
(
"notexist"
,
required
=
true
)
}
classC
.
get
(
"k1"
,
freeVar
=
false
).
asString
shouldBe
"c1"
classC
.
classB
.
get
(
"k1"
,
freeVar
=
false
).
asString
shouldBe
"b1"
classC
.
classB
.
classA
.
get
(
"k1"
,
freeVar
=
false
).
asString
shouldBe
"a1"
}
}
abstract
class
Cfg
extends
Configurable
{
def
get
(
key
:
String
,
default
:
String
=
null
,
submodule
:
String
=
null
,
required
:
Boolean
=
false
,
freeVar
:
Boolean
=
true
)
=
{
config
(
key
,
default
,
submodule
,
required
,
freeVar
=
freeVar
)
}
}
class
ClassA
(
val
root
:
Configurable
)
extends
Cfg
class
ClassB
(
val
root
:
Configurable
)
extends
Cfg
{
val
classA
=
new
ClassA
(
this
)
}
class
ClassC
(
val
root
:
Configurable
)
extends
Cfg
{
def
this
()
=
this
(
null
)
val
classB
=
new
ClassB
(
this
)
}
object
ConfigurableTest
{
val
map
=
Map
(
"classa"
->
Map
(
"k1"
->
"a1"
),
"classb"
->
Map
(
"k1"
->
"b1"
),
"classc"
->
Map
(
"k1"
->
"c1"
)
)
val
file
=
ConfigUtilsTest
.
writeTemp
(
ConfigUtils
.
mapToJson
(
map
).
spaces2
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment