summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]cps-ri/src/main/java/org/onap/cps/spi/entities/Fragment.java2
-rwxr-xr-x[-rw-r--r--]cps-ri/src/main/java/org/onap/cps/spi/entities/Module.java (renamed from cps-ri/src/main/java/org/onap/cps/spi/entities/ModuleEntity.java)7
-rwxr-xr-x[-rw-r--r--]cps-ri/src/main/java/org/onap/cps/spi/impl/DataPersistenceServiceImpl.java (renamed from cps-ri/src/main/java/org/onap/cps/spi/impl/DataPersistencyServiceImpl.java)4
-rwxr-xr-xcps-ri/src/main/java/org/onap/cps/spi/impl/FragmentPersistenceServiceImpl.java6
-rwxr-xr-xcps-ri/src/main/java/org/onap/cps/spi/impl/ModelPersistenceServiceImpl.java (renamed from cps-ri/src/main/java/org/onap/cps/spi/impl/ModelPersistencyServiceImpl.java)12
-rwxr-xr-xcps-ri/src/main/java/org/onap/cps/spi/repository/ModuleRepository.java14
-rwxr-xr-xcps-service/src/main/java/org/onap/cps/api/impl/CpServiceImpl.java17
-rwxr-xr-x[-rw-r--r--]cps-service/src/main/java/org/onap/cps/spi/DataPersistenceService.java (renamed from cps-service/src/main/java/org/onap/cps/spi/DataPersistencyService.java)2
-rwxr-xr-x[-rw-r--r--]cps-service/src/main/java/org/onap/cps/spi/ModelPersistenceService.java (renamed from cps-service/src/main/java/org/onap/cps/spi/ModelPersistencyService.java)2
-rwxr-xr-xcps-service/src/test/groovy/org/onap/cps/api/impl/CpServiceImplSpec.groovy19
10 files changed, 43 insertions, 42 deletions
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/Fragment.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/Fragment.java
index 4d8a90b733..7afdb3e092 100644..100755
--- a/cps-ri/src/main/java/org/onap/cps/spi/entities/Fragment.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/entities/Fragment.java
@@ -85,5 +85,5 @@ public class Fragment implements Serializable {
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "module_id")
- private ModuleEntity module;
+ private Module module;
}
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/ModuleEntity.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/Module.java
index d2130aeec1..ef6895c7d4 100644..100755
--- a/cps-ri/src/main/java/org/onap/cps/spi/entities/ModuleEntity.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/entities/Module.java
@@ -20,6 +20,7 @@
package org.onap.cps.spi.entities;
+import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
@@ -45,7 +46,9 @@ import lombok.Setter;
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "module")
-public class ModuleEntity {
+public class Module implements Serializable {
+
+ private static final long serialVersionUID = -748666970938314895L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -75,7 +78,7 @@ public class ModuleEntity {
* @param revision the revision number of the module.
* @param dataspace the dataspace related to the module.
*/
- public ModuleEntity(String namespace, String moduleContent, String revision, Dataspace dataspace) {
+ public Module(String namespace, String moduleContent, String revision, Dataspace dataspace) {
this.namespace = namespace;
this.moduleContent = moduleContent;
this.revision = revision;
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/DataPersistencyServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/DataPersistenceServiceImpl.java
index 2b4f1357de..9ed111271a 100644..100755
--- a/cps-ri/src/main/java/org/onap/cps/spi/impl/DataPersistencyServiceImpl.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/DataPersistenceServiceImpl.java
@@ -19,7 +19,7 @@
package org.onap.cps.spi.impl;
-import org.onap.cps.spi.DataPersistencyService;
+import org.onap.cps.spi.DataPersistenceService;
import org.onap.cps.spi.entities.JsonDataEntity;
import org.onap.cps.spi.repository.DataRepository;
import org.springframework.beans.factory.annotation.Autowired;
@@ -27,7 +27,7 @@ import org.springframework.stereotype.Component;
@Component
-public class DataPersistencyServiceImpl implements DataPersistencyService {
+public class DataPersistenceServiceImpl implements DataPersistenceService {
@Autowired
private DataRepository dataRepository;
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/FragmentPersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/FragmentPersistenceServiceImpl.java
index 47d98c92b5..0ecf72d772 100755
--- a/cps-ri/src/main/java/org/onap/cps/spi/impl/FragmentPersistenceServiceImpl.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/FragmentPersistenceServiceImpl.java
@@ -26,7 +26,7 @@ import org.onap.cps.exceptions.CpsValidationException;
import org.onap.cps.spi.FragmentPersistenceService;
import org.onap.cps.spi.entities.Dataspace;
import org.onap.cps.spi.entities.Fragment;
-import org.onap.cps.spi.entities.ModuleEntity;
+import org.onap.cps.spi.entities.Module;
import org.onap.cps.spi.repository.DataspaceRepository;
import org.onap.cps.spi.repository.FragmentRepository;
import org.onap.cps.spi.repository.ModuleRepository;
@@ -50,13 +50,13 @@ public class FragmentPersistenceServiceImpl implements FragmentPersistenceServic
public String createAnchor(final AnchorDetails anchorDetails) {
try {
final Dataspace dataspace = dataspaceRepository.getByName(anchorDetails.getDataspace());
- final ModuleEntity moduleEntity =
+ final Module module =
moduleRepository.getByDataspaceAndNamespaceAndRevision(dataspace,
anchorDetails.getNamespace(), anchorDetails.getRevision());
final Fragment fragment = Fragment.builder().xpath(anchorDetails.getAnchorName())
.anchorName(anchorDetails.getAnchorName())
- .dataspace(dataspace).module(moduleEntity).build();
+ .dataspace(dataspace).module(module).build();
fragmentRepository.save(fragment);
return anchorDetails.getAnchorName();
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/ModelPersistencyServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/ModelPersistenceServiceImpl.java
index 56bba04b73..a54e506466 100755
--- a/cps-ri/src/main/java/org/onap/cps/spi/impl/ModelPersistencyServiceImpl.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/ModelPersistenceServiceImpl.java
@@ -20,16 +20,16 @@
package org.onap.cps.spi.impl;
-import org.onap.cps.spi.ModelPersistencyService;
+import org.onap.cps.spi.ModelPersistenceService;
import org.onap.cps.spi.entities.Dataspace;
-import org.onap.cps.spi.entities.ModuleEntity;
+import org.onap.cps.spi.entities.Module;
import org.onap.cps.spi.repository.DataspaceRepository;
import org.onap.cps.spi.repository.ModuleRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
-public class ModelPersistencyServiceImpl implements ModelPersistencyService {
+public class ModelPersistenceServiceImpl implements ModelPersistenceService {
@Autowired
private ModuleRepository moduleRepository;
@@ -45,7 +45,7 @@ public class ModelPersistencyServiceImpl implements ModelPersistencyService {
dataspaceRepository.save(dataspace);
}
dataspace.setId(dataspaceRepository.getByName(dataspaceName).getId());
- final ModuleEntity moduleEntity = new ModuleEntity(namespace, moduleContent, revision, dataspace);
- moduleRepository.save(moduleEntity);
+ final Module module = new Module(namespace, moduleContent, revision, dataspace);
+ moduleRepository.save(module);
}
-}
+} \ No newline at end of file
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/ModuleRepository.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/ModuleRepository.java
index fe27c8ec3e..d3a8bc1f09 100755
--- a/cps-ri/src/main/java/org/onap/cps/spi/repository/ModuleRepository.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/repository/ModuleRepository.java
@@ -24,27 +24,27 @@ import java.util.Optional;
import javax.validation.constraints.NotNull;
import org.onap.cps.exceptions.CpsNotFoundException;
import org.onap.cps.spi.entities.Dataspace;
-import org.onap.cps.spi.entities.ModuleEntity;
+import org.onap.cps.spi.entities.Module;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
-public interface ModuleRepository extends JpaRepository<ModuleEntity, Integer> {
+public interface ModuleRepository extends JpaRepository<Module, Integer> {
- Optional<ModuleEntity> findByDataspaceAndNamespaceAndRevision(@NotNull Dataspace dataspace,
+ Optional<Module> findByDataspaceAndNamespaceAndRevision(@NotNull Dataspace dataspace,
@NotNull String namespace,
@NotNull String revision);
/**
- * This method gets a ModuleEntity by dataspace, namespace and revision.
+ * This method gets a Module by dataspace, namespace and revision.
*
* @param dataspace the dataspace
* @param namespace the namespace
* @param revision the revision
- * @return the ModuleEntity
- * @throws CpsNotFoundException if ModuleEntity not found
+ * @return the Module
+ * @throws CpsNotFoundException if Module not found
*/
- default ModuleEntity getByDataspaceAndNamespaceAndRevision(@NotNull Dataspace dataspace, @NotNull String namespace,
+ default Module getByDataspaceAndNamespaceAndRevision(@NotNull Dataspace dataspace, @NotNull String namespace,
@NotNull String revision) {
return findByDataspaceAndNamespaceAndRevision(dataspace, namespace,
revision)
diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpServiceImpl.java
index 8cdadbeb55..93ed8b8468 100755
--- a/cps-service/src/main/java/org/onap/cps/api/impl/CpServiceImpl.java
+++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpServiceImpl.java
@@ -29,9 +29,9 @@ import org.onap.cps.api.CpService;
import org.onap.cps.api.model.AnchorDetails;
import org.onap.cps.exceptions.CpsException;
import org.onap.cps.exceptions.CpsValidationException;
-import org.onap.cps.spi.DataPersistencyService;
+import org.onap.cps.spi.DataPersistenceService;
import org.onap.cps.spi.FragmentPersistenceService;
-import org.onap.cps.spi.ModelPersistencyService;
+import org.onap.cps.spi.ModelPersistenceService;
import org.onap.cps.utils.YangUtils;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.model.api.Module;
@@ -40,15 +40,14 @@ import org.opendaylight.yangtools.yang.model.parser.api.YangParserException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-
@Component
public class CpServiceImpl implements CpService {
@Autowired
- private ModelPersistencyService modelPersistencyService;
+ private ModelPersistenceService modelPersistenceService;
@Autowired
- private DataPersistencyService dataPersistencyService;
+ private DataPersistenceService dataPersistenceService;
@Autowired
private FragmentPersistenceService fragmentPersistenceService;
@@ -80,17 +79,17 @@ public class CpServiceImpl implements CpService {
@Override
public final Integer storeJsonStructure(final String jsonStructure) {
- return dataPersistencyService.storeJsonStructure(jsonStructure);
+ return dataPersistenceService.storeJsonStructure(jsonStructure);
}
@Override
public final String getJsonById(final int jsonObjectId) {
- return dataPersistencyService.getJsonById(jsonObjectId);
+ return dataPersistenceService.getJsonById(jsonObjectId);
}
@Override
public void deleteJsonById(int jsonObjectId) {
- dataPersistencyService.deleteJsonById(jsonObjectId);
+ dataPersistenceService.deleteJsonById(jsonObjectId);
}
@Override
@@ -98,7 +97,7 @@ public class CpServiceImpl implements CpService {
for (final Module module : schemaContext.getModules()) {
final Optional<Revision> optionalRevision = module.getRevision();
final String revisionValue = optionalRevision.map(Object::toString).orElse(null);
- modelPersistencyService.storeModule(module.getNamespace().toString(), module.toString(),
+ modelPersistenceService.storeModule(module.getNamespace().toString(), module.toString(),
revisionValue, dataspaceName);
}
}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/DataPersistencyService.java b/cps-service/src/main/java/org/onap/cps/spi/DataPersistenceService.java
index ce51f40ac6..a3cbc28c55 100644..100755
--- a/cps-service/src/main/java/org/onap/cps/spi/DataPersistencyService.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/DataPersistenceService.java
@@ -22,7 +22,7 @@ package org.onap.cps.spi;
/**
* Defines methods to access and manipulate data using the chosen database solution.
*/
-public interface DataPersistencyService {
+public interface DataPersistenceService {
/**
* Store the JSON structure in the database.
diff --git a/cps-service/src/main/java/org/onap/cps/spi/ModelPersistencyService.java b/cps-service/src/main/java/org/onap/cps/spi/ModelPersistenceService.java
index 2afdaa82a8..3f0b3c1109 100644..100755
--- a/cps-service/src/main/java/org/onap/cps/spi/ModelPersistencyService.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/ModelPersistenceService.java
@@ -23,7 +23,7 @@ package org.onap.cps.spi;
/**
* Defines methods to access and manipulate data using the chosen database solution.
*/
-public interface ModelPersistencyService {
+public interface ModelPersistenceService {
/**
* Store the module from a yang model in the database.
diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpServiceImplSpec.groovy
index 3c51cca597..709378ebee 100755
--- a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpServiceImplSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpServiceImplSpec.groovy
@@ -22,9 +22,8 @@ package org.onap.cps.api.impl
import org.onap.cps.TestUtils
import org.onap.cps.api.model.AnchorDetails
-import org.onap.cps.exceptions.CpsNotFoundException
import org.onap.cps.exceptions.CpsValidationException
-import org.onap.cps.spi.DataPersistencyService
+import org.onap.cps.spi.DataPersistenceService
import org.onap.cps.spi.FragmentPersistenceService
import org.opendaylight.yangtools.yang.common.Revision
import org.opendaylight.yangtools.yang.model.api.SchemaContext
@@ -32,18 +31,18 @@ import spock.lang.Specification
class CpServiceImplSpec extends Specification {
- def mockDataPersistencyService = Mock(DataPersistencyService)
+ def mockDataPersistenceService = Mock(DataPersistenceService)
def mockFragmentPersistenceService = Mock(FragmentPersistenceService)
def objectUnderTest = new CpServiceImpl()
def setup() {
- objectUnderTest.dataPersistencyService = mockDataPersistencyService
+ objectUnderTest.dataPersistenceService = mockDataPersistenceService
objectUnderTest.fragmentPersistenceService = mockFragmentPersistenceService
}
def 'Cps Service provides to its client the id assigned by the system when storing a data structure'() {
- given: 'that data persistency service is giving id 123 to a data structure it is asked to store'
- mockDataPersistencyService.storeJsonStructure(_) >> 123
+ given: 'that data persistence service is giving id 123 to a data structure it is asked to store'
+ mockDataPersistenceService.storeJsonStructure(_) >> 123
expect: 'Cps service returns the same id when storing data structure'
objectUnderTest.storeJsonStructure('') == 123
}
@@ -88,7 +87,7 @@ class CpServiceImplSpec extends Specification {
def 'Read a JSON object with a valid identifier'(){
given: 'that the data persistence service returns a JSON structure for identifier 1'
- mockDataPersistencyService.getJsonById(1) >> '{name : hello}'
+ mockDataPersistenceService.getJsonById(1) >> '{name : hello}'
expect: 'that the same JSON structure is returned by CPS'
objectUnderTest.getJsonById(1) == '{name : hello}'
}
@@ -96,7 +95,7 @@ class CpServiceImplSpec extends Specification {
def 'Read a JSON object with an identifier that does not exist'(){
given: 'that the data persistence service throws an exception'
def exceptionThrownByPersistenceService = new IllegalStateException()
- mockDataPersistencyService.getJsonById(_) >> {throw exceptionThrownByPersistenceService}
+ mockDataPersistenceService.getJsonById(_) >> {throw exceptionThrownByPersistenceService}
when: 'we try to get the JSON structure'
objectUnderTest.getJsonById(1);
then: 'the same exception is thrown by CPS'
@@ -105,14 +104,14 @@ class CpServiceImplSpec extends Specification {
def 'Delete a JSON object with a valid identifier'(){
given: 'that the data persistence service can delete a JSON structure for identifier 1'
- mockDataPersistencyService.deleteJsonById(1)
+ mockDataPersistenceService.deleteJsonById(1)
expect: 'No exception is thrown when we delete a JSON structure with identifier 1'
objectUnderTest.deleteJsonById(1)
}
def 'Delete a JSON object with an identifier that does not exist'(){
given: 'that the data persistence service throws an exception'
- mockDataPersistencyService.deleteJsonById(_) >> {throw new IllegalStateException()}
+ mockDataPersistenceService.deleteJsonById(_) >> {throw new IllegalStateException()}
when: 'we try to delete a JSON structure'
objectUnderTest.deleteJsonById(100);
then: 'the same exception is thrown by CPS'