Load only required components in the application contexts
[cps.git] / cps-service / src / test / groovy / org / onap / cps / api / impl / CpsModuleServiceImplSpec.groovy
index d20149b..0af0334 100644 (file)
@@ -21,8 +21,6 @@
 package org.onap.cps.api.impl
 
 import org.onap.cps.TestUtils
-import org.onap.cps.api.CpsAdminService
-import org.onap.cps.spi.CpsDataPersistenceService
 import org.onap.cps.spi.CpsModulePersistenceService
 import org.onap.cps.spi.exceptions.ModelValidationException
 import org.onap.cps.spi.model.ModuleReference
@@ -30,8 +28,8 @@ import org.spockframework.spring.SpringBean
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.boot.test.context.SpringBootTest
 import org.springframework.cache.CacheManager
+import org.springframework.cache.annotation.EnableCaching
 import org.springframework.cache.caffeine.CaffeineCacheManager
-import org.springframework.context.annotation.ComponentScan
 import org.springframework.test.context.ContextConfiguration
 import spock.lang.Specification
 
@@ -39,19 +37,18 @@ import static org.onap.cps.spi.CascadeDeleteAllowed.CASCADE_DELETE_ALLOWED
 import static org.onap.cps.spi.CascadeDeleteAllowed.CASCADE_DELETE_PROHIBITED
 
 @SpringBootTest
-@ComponentScan("org.onap.cps")
-@ContextConfiguration(classes = CpsModuleServiceImplSpec.class)
+@EnableCaching
+@ContextConfiguration(classes = [YangTextSchemaSourceSetCache.class, CpsModuleServiceImpl.class])
 class CpsModuleServiceImplSpec extends Specification {
+
     @SpringBean
     CpsModulePersistenceService mockModuleStoreService = Mock()
+
     @SpringBean
-    CpsAdminService mockCpsAdminService = Mock()
-    @SpringBean
-    CpsDataPersistenceService mockDataPersistenceService = Mock()
+    CacheManager cacheManager = new CaffeineCacheManager("yangSchema")
+
     @Autowired
-    CpsModuleServiceImpl objectUnderTest = new CpsModuleServiceImpl()
-    @SpringBean
-    CacheManager cacheManager = new CaffeineCacheManager("yangSchema");
+    CpsModuleServiceImpl objectUnderTest
 
     def 'Create schema set'() {
         given: 'Valid yang resource as name-to-content map'