インジェクタを作成してAPIをテストしようとしています。Guice、インジェクタを作成できません
The test binding are as follows
class ApiTestModule extends AbstractModule {
def configure(): Unit = {
bind(classOf[Client]).in(classOf[Singleton])
bind(classOf[ApiGetController]).in(classOf[Singleton])
bind(classOf[ApiPostController]).in(classOf[Singleton])
bind(classOf[IndexService]).in(classOf[Singleton])
bind(classOf[PanelService]).in(classOf[Singleton])
bind(classOf[EntitiesService]).in(classOf[Singleton])
bind(classOf[AuthenticatedPublicApiAction]).in(classOf[Singleton])
bind(classOf[RateLimitedApiAction]).in(classOf[Singleton])
bind(classOf[ApiKeyValidatorUpdaterThread]).in(classOf[Singleton])
bind(classOf[ApiKeyValidatorService]).in(classOf[Singleton])
bind(classOf[ArticleFrontService]).in(classOf[Singleton])
}
私はコード
val testModule = new AbstractModule() {
def configure() = {
new ApiTestModule().configure(binder())
}
}
val injector = new GuiceApplicationBuilder()
.overrides(testModule).injector()
val apiGetController = injector.instanceOf(classOf[ApiGetController])
のTEインジェクターを作成しましたそして、私は
例外やエラーは、実行を中断させる原因となった、次のエラーを取得しています:参照、インジェクターを作成することができません。次のエラー:
1) No implementation for org.elasticsearch.client.Client annotated with @com.google.inject.name.Named(value=SpikeClient) was bound.
while locating org.elasticsearch.client.Client annotated with @com.google.inject.name.Named(value=SpikeClient)
for parameter 2 at com.newswhip.api.service.ApiArticleService.<init>(ApiArticleService.scala:19)
while locating com.newswhip.api.service.ApiArticleService
for parameter 1 at com.newswhip.api.controllers.ApiGetController.<init>(ApiGetController.scala:57)
at com.newswhip.spike.inject.TestBindings$ApiTestModule.configure(TestBindings.scala:133) (via modules: com.google.inject.util.Modules$OverrideModule -> com.newswhip.api.service.ApiArticleServiceTest$$anon$1)
2) No implementation for org.elasticsearch.client.Client annotated with @com.google.inject.name.Named(value=SpikeClient) was bound.
while locating org.elasticsearch.client.Client annotated with @com.google.inject.name.Named(value=SpikeClient)
for parameter 2 at com.newswhip.api.service.ApiArticleService.<init>(ApiArticleService.scala:19)
while locating com.newswhip.api.service.ApiArticleService
for parameter 1 at com.newswhip.api.controllers.ApiPostController.<init>(ApiPostController.scala:17)
at com.newswhip.spike.inject.TestBindings$ApiTestModule.configure(TestBindings.scala:134) (via modules: com.google.inject.util.Modules$OverrideModule -> com.newswhip.api.service.ApiArticleServiceTest$$anon$1)
3) No implementation for org.elasticsearch.client.Client annotated with @com.google.inject.name.Named(value=SpikeClient) was bound.
while locating org.elasticsearch.client.Client annotated with @com.google.inject.name.Named(value=SpikeClient)
for parameter 0 at com.newswhip.spike.article.service.SpikeEsQueryBuilder.<init>(SpikeEsQueryBuilder.scala:20)
while locating com.newswhip.spike.article.service.SpikeEsQueryBuilder
for parameter 2 at com.newswhip.spike.article.service.EntitiesService.<init>(EntitiesService.scala:30)
at com.newswhip.spike.inject.TestBindings$ApiTestModule.configure(TestBindings.scala:137) (via modules: com.google.inject.util.Modules$OverrideModule -> com.newswhip.api.service.ApiArticleServiceTest$$anon$1)
4) No implementation for org.elasticsearch.client.Client was bound.
at com.newswhip.spike.inject.TestBindings$ApiTestModule.configure(TestBindings.scala:131) (via modules: com.google.inject.util.Modules$OverrideModule -> com.newswhip.api.service.ApiArticleServiceTest$$anon$1)
5) No implementation for play.api.db.Database was bound.
at com.newswhip.spike.inject.TestBindings$ApiTestModule.configure(TestBindings.scala:132) (via modules: com.google.inject.util.Modules$OverrideModule -> com.newswhip.api.service.ApiArticleServiceTest$$anon$1
)
私の問題は私のバインディングモジュールにあると思いますが、問題が何であるか把握できません。どんな助けでも大歓迎です。