Reputation: 267000
I have a class that I use in playframework that automatically injects the dependency.
How can I create this class "manually" in my test code:
class AppConfog @Inject()(c: Configuration) {
val supportEmail = c.getString("app.email").get
...
}
I'm not sure how to get a Configuration class to pass into it.
I know I can create an inline config like:
val config =
"""
akka {
loglevel = "WARNING"
}
"""
ConfigFactory.parseString(config)
How do I get a Configuration from a config?
Upvotes: 0
Views: 116
Reputation: 3921
I think that Play's Configuration
just wraps Typesafe Config
that you get with your ConfigFactory.parseString(config)
. See here.
So you should be able to do this:
val underlying = ConfigFactory.parseString(config)
val configuration = Configuration(underlying)
val mockAppConfog = new AppConfog(configuration)
Upvotes: 2