diff options
author | 2021-12-08 18:16:44 +0000 | |
---|---|---|
committer | 2021-12-14 16:13:40 +0000 | |
commit | 82ebf531110deba98086f8f7cb9c745519bbc4f4 (patch) | |
tree | 6a64017dc6986dc4d2e042ea33e09e1ffdcd495f /cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java | |
parent | 4207fab422760b17187d37776ebc1867b995bba1 (diff) |
Changing putOperationWithJson to postOperationWithJson
-Modified responseEntity<String> to reesponseEntity<Object>
-Changed behaviour of sync to use new repsonses and removed JSON parsing
-Updated tests to use new responsess
-Tests have been updated and added jira to docs
-Added messageConverters to RestTemplate to support plain text with
ResponseEntity<Object>
-Added docker log output for cps & dmi containers during CSIT teardown
-Moved reponse conversion from service into DMIModelOperations class
-Added response handling test (edgecases)
-Updated response request body for passthrough-running CSIT test to pass
Issue-ID: CPS-777
Signed-off-by: JosephKeenan <joseph.keenan@est.tech>
Change-Id: If2acf83a97b8aad5aa2c342154d807a47cace6a0
Diffstat (limited to 'cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java')
-rwxr-xr-x | cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java | 51 |
1 files changed, 2 insertions, 49 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java index faa2efe3a..bd86cd0c3 100755 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java @@ -28,10 +28,6 @@ import static org.onap.cps.spi.CascadeDeleteAllowed.CASCADE_DELETE_ALLOWED; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.Collection; @@ -52,7 +48,6 @@ import org.onap.cps.ncmp.api.models.CmHandle; import org.onap.cps.ncmp.api.models.DmiPluginRegistration; import org.onap.cps.ncmp.api.models.PersistenceCmHandle; import org.onap.cps.ncmp.api.models.PersistenceCmHandlesList; -import org.onap.cps.ncmp.api.models.YangResource; import org.onap.cps.spi.FetchDescendantsOption; import org.onap.cps.spi.exceptions.DataNodeNotFoundException; import org.onap.cps.spi.exceptions.DataValidationException; @@ -308,9 +303,8 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService } private void syncAndCreateSchemaSet(final PersistenceCmHandle persistenceCmHandle) { - final List<ModuleReference> moduleReferencesFromCmHandle = - toModuleReferences(dmiModelOperations.getModuleReferences(persistenceCmHandle)); + dmiModelOperations.getModuleReferences(persistenceCmHandle); final List<ModuleReference> existingModuleReferences = new ArrayList<>(); final List<ModuleReference> unknownModuleReferences = new ArrayList<>(); prepareModuleSubsets(moduleReferencesFromCmHandle, existingModuleReferences, unknownModuleReferences); @@ -319,7 +313,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService if (unknownModuleReferences.isEmpty()) { newYangResourcesModuleNameToContentMap = new HashMap<>(); } else { - newYangResourcesModuleNameToContentMap = getNewYangResourcesFromDmi(persistenceCmHandle, + newYangResourcesModuleNameToContentMap = dmiModelOperations.getNewYangResourcesFromDmi(persistenceCmHandle, unknownModuleReferences); } cpsModuleService @@ -348,47 +342,6 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService persistenceCmHandle.getId()); } - private Map<String, String> getNewYangResourcesFromDmi(final PersistenceCmHandle persistenceCmHandle, - final List<ModuleReference> unknownModuleReferences) { - final ResponseEntity<String> responseEntity = - dmiModelOperations.getNewYangResourcesFromDmi(persistenceCmHandle, unknownModuleReferences); - - final JsonArray moduleResources = new Gson().fromJson(responseEntity.getBody(), - JsonArray.class); - final Map<String, String> newYangResourcesModuleNameToContentMap = new HashMap<>(); - - for (final JsonElement moduleResource : moduleResources) { - final YangResource yangResource = toYangResource((JsonObject) moduleResource); - newYangResourcesModuleNameToContentMap.put(yangResource.getModuleName(), yangResource.getYangSource()); - } - return newYangResourcesModuleNameToContentMap; - } - - private static YangResource toYangResource(final JsonObject yangResourceAsJson) { - final YangResource yangResource = new YangResource(); - yangResource.setModuleName(yangResourceAsJson.get("moduleName").getAsString()); - yangResource.setRevision(yangResourceAsJson.get("revision").getAsString()); - yangResource.setYangSource(yangResourceAsJson.get("yangSource").getAsString()); - return yangResource; - } - private static List<ModuleReference> toModuleReferences( - final ResponseEntity<String> dmiFetchModulesResponseEntity) { - final List<ModuleReference> moduleReferences = new ArrayList<>(); - final JsonObject bodyAsJsonObject = new Gson().fromJson(dmiFetchModulesResponseEntity.getBody(), - JsonObject.class); - final JsonArray moduleReferencesAsJson = bodyAsJsonObject.getAsJsonArray("schemas"); - for (final JsonElement moduleReferenceAsJson : moduleReferencesAsJson) { - final ModuleReference moduleReference = toModuleReference((JsonObject) moduleReferenceAsJson); - moduleReferences.add(moduleReference); - } - return moduleReferences; - } - private static ModuleReference toModuleReference(final JsonObject moduleReferenceAsJson) { - final ModuleReference moduleReference = new ModuleReference(); - moduleReference.setModuleName(moduleReferenceAsJson.get("moduleName").getAsString()); - moduleReference.setRevision(moduleReferenceAsJson.get("revision").getAsString()); - return moduleReference; - } } |