diff options
author | Renu Kumari <renu.kumari@bell.ca> | 2021-05-26 08:47:52 -0400 |
---|---|---|
committer | Renu Kumari <renu.kumari@bell.ca> | 2021-05-28 10:03:15 -0400 |
commit | 9de3b68373dd8554e64f34bb3093403521f8759f (patch) | |
tree | 4300cf19312da7d4cf30b43c73d3ff990bf62517 | |
parent | eef2e112d1f447b47f2f19d24e9dfd9a76550333 (diff) |
Load only required components in the application contexts
Issue-ID: CPS-434
Signed-off-by: Renu Kumari <renu.kumari@bell.ca>
Change-Id: Iacc12946495b9e6ec42b4b7d4e3b5b010fecceb5
4 files changed, 13 insertions, 13 deletions
diff --git a/.gitignore b/.gitignore index 8fff710922..3ab10191f4 100755 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ log/ *.iml *.ipr *.iws +*.DS_Store .settings/ bin/ diff --git a/cps-ri/src/test/java/org/onap/cps/TestApplication.java b/cps-ri/src/test/java/org/onap/cps/TestApplication.java index 5e0e3679ee..0d1df456ee 100644 --- a/cps-ri/src/test/java/org/onap/cps/TestApplication.java +++ b/cps-ri/src/test/java/org/onap/cps/TestApplication.java @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Pantheon.tech + * Modifications Copyright (C) 2021 Bell Canada. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +26,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; * The @SpringBootApplication annotated class is required in order to run tests * marked with @SpringBootTest annotation. */ -@SpringBootApplication +@SpringBootApplication(scanBasePackages = "org.onap.cps.spi") public class TestApplication { } diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy index d20149bc4e..0af0334d54 100644 --- a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy +++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy @@ -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' diff --git a/cps-service/src/test/groovy/org/onap/cps/utils/YangTextSchemaSourceSetSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/utils/YangTextSchemaSourceSetSpec.groovy index e58f442129..be5610cb34 100644 --- a/cps-service/src/test/groovy/org/onap/cps/utils/YangTextSchemaSourceSetSpec.groovy +++ b/cps-service/src/test/groovy/org/onap/cps/utils/YangTextSchemaSourceSetSpec.groovy @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Nordix Foundation + * Modifications Copyright (C) 2021 Bell Canada. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +32,7 @@ class YangTextSchemaSourceSetSpec extends Specification { given: 'a yang model (file)' def yangResourceNameToContent = [filename: TestUtils.getResourceFileContent('bookstore.yang')] when: 'the content is parsed' - def result = YangTextSchemaSourceSetBuilder.of(yangResourceNameToContent).getSchemaContext(); + def result = YangTextSchemaSourceSetBuilder.of(yangResourceNameToContent).getSchemaContext() then: 'the result contains 1 module of the correct name and revision' result.modules.size() == 1 def optionalModule = result.findModule('stores', Revision.of('2020-09-15')) |