/*
* ============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.
* 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 {
}
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
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
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'
/*
* ============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.
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'))