Merge "Tested with fetching a file over https."
diff --git a/capifcorejava/src/main/java/org/oransc/nonrtric/plt/capifcore/controller/ProviderManager.java b/capifcorejava/src/main/java/org/oransc/nonrtric/plt/capifcore/controller/ProviderManager.java
index 0eafaab..eeb501e 100644
--- a/capifcorejava/src/main/java/org/oransc/nonrtric/plt/capifcore/controller/ProviderManager.java
+++ b/capifcorejava/src/main/java/org/oransc/nonrtric/plt/capifcore/controller/ProviderManager.java
@@ -24,6 +24,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.oransc.capif.model.APIProviderEnrolmentDetails;
 import org.oransc.capif.model.APIProviderEnrolmentDetailsPatch;
@@ -59,6 +60,8 @@
 
     }
 
+
+
     @Override
     public ResponseEntity<APIProviderEnrolmentDetails> registrationsPost(
             APIProviderEnrolmentDetails apIProviderEnrolmentDetails) {
@@ -96,6 +99,42 @@
     }
 
     @Override
+    public ResponseEntity<APIProviderEnrolmentDetails> registrationsRegistrationIdPut(String registrationId,
+            APIProviderEnrolmentDetails registeredProvider) {
+
+
+        if (registeredProvider != onboardedProviders.get(registrationId)) {
+            throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Provider must be onboarded before updating it");
+        }
+
+
+        List<APIProviderFunctionDetails> registeredFuncs;
+
+        APIProviderEnrolmentDetails updatedProvider = onboardedProviders.get(registrationId);
+        updatedProvider.getApiProvDomInfo();
+
+
+        if (updatedProvider == null) {
+            throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Invalid format for provider");
+        }
+        List<APIProviderFunctionDetails> myList = new CopyOnWriteArrayList<APIProviderFunctionDetails>();
+        myList = updatedProvider.getApiProvFuncs();
+        for (APIProviderFunctionDetails function : myList) {
+
+            if (function.getApiProvFuncId() == null) {
+                function.setApiProvFuncId(getFuncId(function.getApiProvFuncRole(), function.getApiProvFuncInfo()));
+                registeredFuncs = registeredProvider.getApiProvFuncs();
+
+                registeredProvider.setApiProvFuncs(registeredFuncs);
+                onboardedProviders.put(registeredProvider.getApiProvDomId(), registeredProvider);
+            }
+
+        }
+
+        return ResponseEntity.ok(registeredProvider);
+    }
+
+    @Override
     public ResponseEntity<APIProviderEnrolmentDetails> modifyIndApiProviderEnrolment(String registrationId,
             APIProviderEnrolmentDetailsPatch apIProviderEnrolmentDetailsPatch) {
 
diff --git a/capifcorejava/src/test/java/org/oransc/nonrtric/plt/capifcore/controller/ProviderManagerTest.java b/capifcorejava/src/test/java/org/oransc/nonrtric/plt/capifcore/controller/ProviderManagerTest.java
index df7180d..3fcbd38 100644
--- a/capifcorejava/src/test/java/org/oransc/nonrtric/plt/capifcore/controller/ProviderManagerTest.java
+++ b/capifcorejava/src/test/java/org/oransc/nonrtric/plt/capifcore/controller/ProviderManagerTest.java
@@ -27,11 +27,15 @@
 import static org.oransc.capif.model.ApiProviderFuncRole.APF;

 

 import java.net.URI;

+import java.util.ArrayList;

+import java.util.List;

 

+import org.junit.jupiter.api.BeforeEach;

 import org.junit.jupiter.api.DisplayName;

 import org.junit.jupiter.api.Test;

 import org.junit.jupiter.api.extension.ExtendWith;

 import org.oransc.capif.model.APIProviderEnrolmentDetails;

+import org.oransc.capif.model.APIProviderFunctionDetails;

 import org.springframework.http.HttpStatus;

 import org.springframework.http.ResponseEntity;

 import org.springframework.mock.web.MockHttpServletRequest;

@@ -41,16 +45,24 @@
 

 @ExtendWith(SpringExtension.class)

 class ProviderManagerTest {

+    ProviderManager managerUnderTest;

+    APIProviderEnrolmentDetails apiProviderEnrolmentDetails;

+

+

+    @BeforeEach

+    void init() {

+        MockHttpServletRequest request = new MockHttpServletRequest();

+        RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));

+        managerUnderTest = new ProviderManager();

+

+        apiProviderEnrolmentDetails = new APIProviderEnrolmentDetails();

+        apiProviderEnrolmentDetails.apiProvDomInfo("apiProvDomInfo");

+

+    }

 

     @Test

     @DisplayName("Post Registration API Should Get apiProvDomId And Response Should Include Location Header")

     void testResgistrationPostAndResponseLocationHeader() throws Exception {

-        MockHttpServletRequest request = new MockHttpServletRequest();

-        RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));

-

-        ProviderManager managerUnderTest = new ProviderManager();

-        APIProviderEnrolmentDetails apiProviderEnrolmentDetails = new APIProviderEnrolmentDetails();

-        apiProviderEnrolmentDetails.apiProvDomInfo("apiProvDomInfo");

 

         ResponseEntity<APIProviderEnrolmentDetails> response =

                 managerUnderTest.registrationsPost(apiProviderEnrolmentDetails);

@@ -64,20 +76,31 @@
     @Test

     @DisplayName("Delete the provider")

     void testRegistrationsRegistrationIdDelete() {

-        MockHttpServletRequest request = new MockHttpServletRequest();

-        RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));

 

-        ProviderManager managerUnderTest = new ProviderManager();

-        APIProviderEnrolmentDetails apiProviderEnrolmentDetails = new APIProviderEnrolmentDetails();

-        apiProviderEnrolmentDetails.apiProvDomInfo("apiProvDomInfo");

         managerUnderTest.registrationsPost(apiProviderEnrolmentDetails);

-

-

         ResponseEntity<Void> response = managerUnderTest.registrationsRegistrationIdDelete("domain_id_apiProvDomInfo");

         assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);

 

     }

 

+    @Test

+    @DisplayName("Update the provider")

+    void testRegistrationsRegistrationIdPut() {

+

+        managerUnderTest.registrationsPost(apiProviderEnrolmentDetails);

+        List<APIProviderFunctionDetails> registeredFuncs = new ArrayList<>();

+        APIProviderFunctionDetails apiProviderFunctionDetails = new APIProviderFunctionDetails();

+        apiProviderFunctionDetails.setApiProvFuncInfo("apiProvFuncInfo");

+        apiProviderFunctionDetails.setApiProvFuncRole(APF);

+        registeredFuncs.add(apiProviderFunctionDetails);

+        apiProviderEnrolmentDetails.setApiProvFuncs(registeredFuncs);

+        ResponseEntity<APIProviderEnrolmentDetails> response = managerUnderTest

+                .registrationsRegistrationIdPut("domain_id_apiProvDomInfo", apiProviderEnrolmentDetails);

+        assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);

+

+    }

+

+

 

     @Test

     void testGetFuncId() {

diff --git a/rapp-manager/config/keystore.jks b/rapp-manager/config/keystore.jks
index 122997a..563c67b 100644
--- a/rapp-manager/config/keystore.jks
+++ b/rapp-manager/config/keystore.jks
Binary files differ
diff --git a/rapp-manager/config/truststore.jks b/rapp-manager/config/truststore.jks
index 60d6288..50a0f9e 100644
--- a/rapp-manager/config/truststore.jks
+++ b/rapp-manager/config/truststore.jks
Binary files differ
diff --git a/rapp-manager/pom.xml b/rapp-manager/pom.xml
index 54e90e8..d532900 100644
--- a/rapp-manager/pom.xml
+++ b/rapp-manager/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>2.4.2</version>
+        <version>2.6.6</version>
         <relativePath/>
     </parent>
     <groupId>org.o-ran-sc.nonrtric</groupId>