</dependency>\r
\r
<dependency>\r
+ <!-- required for processing yang data in json format -->\r
<groupId>org.opendaylight.yangtools</groupId>\r
- <artifactId>yang-data-codec-xml</artifactId>\r
+ <artifactId>yang-data-codec-gson</artifactId>\r
<version>${org.opendaylight.yangtools.version}</version>\r
</dependency>\r
\r
<artifactId>gson</artifactId>\r
</dependency>\r
\r
+ <!-- T E S T D E P E N D E N C I E S -->\r
+\r
+ <dependency>\r
+ <groupId>org.codehaus.groovy</groupId>\r
+ <artifactId>groovy</artifactId>\r
+ <version>${version.groovy}</version>\r
+ <scope>test</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.spockframework</groupId>\r
+ <artifactId>spock-core</artifactId>\r
+ <version>${version.spock-core}</version>\r
+ <scope>test</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>cglib</groupId>\r
+ <artifactId>cglib-nodep</artifactId>\r
+ <version>3.1</version>\r
+ <scope>test</scope>\r
+ </dependency>\r
</dependencies>\r
\r
-</project>
\ No newline at end of file
+</project>\r
--- /dev/null
+package org.onap.cps.api.impl
+
+import org.onap.cps.spi.DataPersistencyService
+import spock.lang.Specification;
+
+
+class CpServiceImplSpec extends Specification {
+
+ def dataPersistencyService = Mock(DataPersistencyService)
+ def objectUnderTest = new CpServiceImpl()
+
+ def setup() {
+ // Insert mocked dependencies
+ objectUnderTest.dataPersistencyService = dataPersistencyService;
+ }
+
+ def 'Storing a json object'() {
+ given: 'that the data persistency service returns an id of 123'
+ dataPersistencyService.storeJsonStructure(_) >> 123
+
+ when: 'a json structure is stored using the data persistency service'
+ def result = objectUnderTest.storeJsonStructure('')
+
+ then: ' the same id is returned'
+ result == 123
+ }
+}
<springboot.version>2.3.3.RELEASE</springboot.version>\r
<oparent.version>3.1.0</oparent.version>\r
<org.opendaylight.yangtools.version>5.0.5</org.opendaylight.yangtools.version>\r
+ <version.groovy>3.0.6</version.groovy>\r
+ <version.spock-core>2.0-M2-groovy-3.0</version.spock-core>\r
</properties>\r
\r
<dependencyManagement>\r
</dependencies>\r
\r
</plugin>\r
+\r
+ <!-- Mandatory plugins for using Spock -->\r
+ <plugin>\r
+ <!-- The gmavenplus plugin is used to compile Groovy code. To learn more about this plugin,\r
+ visit https://github.com/groovy/GMavenPlus/wiki -->\r
+ <groupId>org.codehaus.gmavenplus</groupId>\r
+ <artifactId>gmavenplus-plugin</artifactId>\r
+ <version>1.9.0</version>\r
+ <executions>\r
+ <execution>\r
+ <goals>\r
+ <goal>compileTests</goal>\r
+ </goals>\r
+ </execution>\r
+ </executions>\r
+ </plugin>\r
+ <!-- Required because names of spec classes don't match default Surefire patterns (`*Test` etc.) -->\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-surefire-plugin</artifactId>\r
+ <version>3.0.0-M5</version>\r
+ <configuration>\r
+ <useFile>false</useFile>\r
+ <includes>\r
+ <include>**/*Spec.java</include>\r
+ <include>**/*Test.java</include> <!-- Just in case of having also "normal" JUnit tests -->\r
+ </includes>\r
+ </configuration>\r
+ </plugin>\r
+\r
</plugins>\r
</build>\r
\r