From 0850f44d0eb2dfb231072e2a3728af01f047cb5d Mon Sep 17 00:00:00 2001 From: Nitu Gupta Date: Thu, 17 Feb 2022 14:34:33 +0530 Subject: [PATCH] [CloudSync] Renaming the function from CloudSyncMgrPost to CloudSyncPublish Signed-off-by: Nitu Gupta --- internal/controller/cloudsyncmgr/cloudsync.go | 6 +++--- .../cloudsyncmgr/mocks/mocks_cloudsync.go | 8 ++++---- .../orchestrationapi/mocks/mock_orchestration.go | 8 ++++---- internal/orchestrationapi/orchestration.go | 2 +- internal/orchestrationapi/orchestrationapi.go | 8 ++++---- .../externalhandler/externalhandler.go | 14 +++++++------- .../externalhandler/externalhandler_test.go | 12 ++++++------ 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/internal/controller/cloudsyncmgr/cloudsync.go b/internal/controller/cloudsyncmgr/cloudsync.go index 10643362..f8e0b68e 100644 --- a/internal/controller/cloudsyncmgr/cloudsync.go +++ b/internal/controller/cloudsyncmgr/cloudsync.go @@ -36,7 +36,7 @@ const ( type CloudSync interface { InitiateCloudSync(isCloudSet string) error //implemented by external REST API - RequestCloudSyncConf(host string, clientID string, message mqttmgr.Message, topic string) string + RequestCloudSyncPublish(host string, clientID string, message mqttmgr.Message, topic string) string } //CloudSyncImpl struct @@ -81,8 +81,8 @@ func (c *CloudSyncImpl) InitiateCloudSync(isCloudSet string) (err error) { return nil } -// RequestCloudSyncConf is configuration request handler -func (c *CloudSyncImpl) RequestCloudSyncConf(host string, clientID string, message mqttmgr.Message, topic string) string { +// RequestCloudSyncPublish is configuration request handler +func (c *CloudSyncImpl) RequestCloudSyncPublish(host string, clientID string, message mqttmgr.Message, topic string) string { log.Info(logPrefix, "Publishing the data to the cloud") resp := "" var wg sync.WaitGroup diff --git a/internal/controller/cloudsyncmgr/mocks/mocks_cloudsync.go b/internal/controller/cloudsyncmgr/mocks/mocks_cloudsync.go index 298225ca..f319ff77 100644 --- a/internal/controller/cloudsyncmgr/mocks/mocks_cloudsync.go +++ b/internal/controller/cloudsyncmgr/mocks/mocks_cloudsync.go @@ -62,13 +62,13 @@ func (_mr *MockCloudSyncMockRecorder) InitiateCloudSync(arg0 interface{}) *gomoc } // StartCloudSync mocks base method -func (_m *MockCloudSync) RequestCloudSyncConf(host string, clientID string, message mqttmgr.Message, topic string) string { - ret := _m.ctrl.Call(_m, "RequestCloudSyncConf", host) +func (_m *MockCloudSync) RequestCloudSyncPublish(host string, clientID string, message mqttmgr.Message, topic string) string { + ret := _m.ctrl.Call(_m, "RequestCloudSyncPublish", host) ret0, _ := ret[0].(string) return ret0 } // StartCloudSync indicates an expected call of StartCloudSync -func (_mr *MockCloudSyncMockRecorder) RequestCloudSyncConfloudSync(arg0 interface{}) *gomock.Call { - return _mr.mock.ctrl.RecordCallWithMethodType(_mr.mock, "RequestCloudSyncConf", reflect.TypeOf((*MockCloudSync)(nil).RequestCloudSyncConf), arg0) +func (_mr *MockCloudSyncMockRecorder) RequestCloudSyncPublish(arg0 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCallWithMethodType(_mr.mock, "RequestCloudSyncPublish", reflect.TypeOf((*MockCloudSync)(nil).RequestCloudSyncPublish), arg0) } diff --git a/internal/orchestrationapi/mocks/mock_orchestration.go b/internal/orchestrationapi/mocks/mock_orchestration.go index be037840..d696965e 100644 --- a/internal/orchestrationapi/mocks/mock_orchestration.go +++ b/internal/orchestrationapi/mocks/mock_orchestration.go @@ -105,17 +105,17 @@ func (mr *MockOrcheExternalAPIMockRecorder) RequestService(arg0 interface{}) *go } // RequestCloudSync mocks base method. -func (m *MockOrcheExternalAPI) RequestCloudSync(arg0 string, arg1 string, arg2 mqtt.Message, arg3 string) string { +func (m *MockOrcheExternalAPI) RequestCloudSyncPublish(arg0 string, arg1 string, arg2 mqtt.Message, arg3 string) string { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RequestCloudSync", arg0, arg1, arg2, arg3) + ret := m.ctrl.Call(m, "RequestCloudSyncPublish", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(string) return ret0 } // RequestCloudSync indicates an expected call of RequestService. -func (mr *MockOrcheExternalAPIMockRecorder) RequestCloudSync(arg0, arg1 interface{}, arg2 interface{}, arg3 interface{}) *gomock.Call { +func (mr *MockOrcheExternalAPIMockRecorder) RequestCloudSyncPublish(arg0, arg1 interface{}, arg2 interface{}, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RequestCloudSync", reflect.TypeOf((*MockOrcheExternalAPI)(nil).RequestCloudSync), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RequestCloudSyncPublish", reflect.TypeOf((*MockOrcheExternalAPI)(nil).RequestCloudSyncPublish), arg0, arg1, arg2, arg3) } // RequestVerifierConf mocks base method. diff --git a/internal/orchestrationapi/orchestration.go b/internal/orchestrationapi/orchestration.go index b27b5d2a..e099cb2b 100644 --- a/internal/orchestrationapi/orchestration.go +++ b/internal/orchestrationapi/orchestration.go @@ -53,7 +53,7 @@ type Orche interface { type OrcheExternalAPI interface { RequestService(serviceInfo ReqeustService) ResponseService verifier.Conf - RequestCloudSync(host string, clientID string, message mqtt.Message, topic string) string + RequestCloudSyncPublish(host string, clientID string, message mqtt.Message, topic string) string } // OrcheInternalAPI is the interface implemented by internal REST API diff --git a/internal/orchestrationapi/orchestrationapi.go b/internal/orchestrationapi/orchestrationapi.go index 04e76f7c..a92c5f37 100644 --- a/internal/orchestrationapi/orchestrationapi.go +++ b/internal/orchestrationapi/orchestrationapi.go @@ -130,10 +130,10 @@ func init() { helper = dbhelper.GetInstance() } -//RequestCloudSync handles the request for cloud syncing -func (orcheEngine *orcheImpl) RequestCloudSync(host string, clientID string, message mqtt.Message, topic string) string { - log.Info("[RequestCloudSync]", "Requesting cloud sync") - return orcheEngine.cloudsyncIns.RequestCloudSyncConf(host, clientID, message, topic) +//RequestCloudSyncPublish handles the request for cloud syncing +func (orcheEngine *orcheImpl) RequestCloudSyncPublish(host string, clientID string, message mqtt.Message, topic string) string { + log.Info("[RequestCloudSync]", "Requesting cloud sync publish") + return orcheEngine.cloudsyncIns.RequestCloudSyncPublish(host, clientID, message, topic) } // RequestService handles service request (ex. offloading) from service application diff --git a/internal/restinterface/externalhandler/externalhandler.go b/internal/restinterface/externalhandler/externalhandler.go index fedfae50..737c8a47 100644 --- a/internal/restinterface/externalhandler/externalhandler.go +++ b/internal/restinterface/externalhandler/externalhandler.go @@ -83,10 +83,10 @@ func init() { HandlerFunc: handler.APIV1RequestSecuremgrPost, }, restinterface.Route{ - Name: "APIV1RequestCloudSyncmgrPost", + Name: "APIV1RequestCloudSyncmgrPublish", Method: strings.ToUpper("Post"), - Pattern: "/api/v1/orchestration/cloudsyncmgr", - HandlerFunc: handler.APIV1RequestCloudSyncmgrPost, + Pattern: "/api/v1/orchestration/cloudsyncmgr/publish", + HandlerFunc: handler.APIV1RequestCloudSyncmgrPublish, }, } handler.netHelper = networkhelper.GetInstance() @@ -374,9 +374,9 @@ SEND_RESP: h.helper.Response(w, respEncryptBytes, http.StatusOK) } -// APIV1RequestCloudSyncmgrPost handles cloudsync publish request from service application -func (h *Handler) APIV1RequestCloudSyncmgrPost(w http.ResponseWriter, r *http.Request) { - log.Info(logPrefix, "APIV1RequestCloudSyncmgrPost") +// APIV1RequestCloudSyncmgrPublish handles cloudsync publish request from service application +func (h *Handler) APIV1RequestCloudSyncmgrPublish(w http.ResponseWriter, r *http.Request) { + log.Info(logPrefix, "APIV1RequestCloudSyncmgrPublish") if !h.isSetAPI { log.Error(logPrefix, doesNotSetAPI) h.helper.Response(w, nil, http.StatusServiceUnavailable) @@ -448,7 +448,7 @@ func (h *Handler) APIV1RequestCloudSyncmgrPost(w http.ResponseWriter, r *http.Re goto SEND_RESP } - responseMsg = h.api.RequestCloudSync(host, appID, publishMessage, topic) + responseMsg = h.api.RequestCloudSyncPublish(host, appID, publishMessage, topic) SEND_RESP: respJSONMsg := make(map[string]interface{}) diff --git a/internal/restinterface/externalhandler/externalhandler_test.go b/internal/restinterface/externalhandler/externalhandler_test.go index 01656d08..fba9695b 100644 --- a/internal/restinterface/externalhandler/externalhandler_test.go +++ b/internal/restinterface/externalhandler/externalhandler_test.go @@ -314,7 +314,7 @@ func TestAPIV1RequestCloudSyncmgrPost(t *testing.T) { mockHelper.EXPECT().Response(gomock.Any(), gomock.Any(), gomock.Eq(http.StatusServiceUnavailable)) handler.isSetAPI = false - handler.APIV1RequestCloudSyncmgrPost(w, r) + handler.APIV1RequestCloudSyncmgrPublish(w, r) }) t.Run("IsNotSetKey", func(t *testing.T) { handler.SetOrchestrationAPI(mockOrchestration) @@ -322,7 +322,7 @@ func TestAPIV1RequestCloudSyncmgrPost(t *testing.T) { mockHelper.EXPECT().Response(gomock.Any(), gomock.Any(), gomock.Eq(http.StatusServiceUnavailable)) handler.IsSetKey = false - handler.APIV1RequestCloudSyncmgrPost(w, r) + handler.APIV1RequestCloudSyncmgrPublish(w, r) }) t.Run("DecryptionFail", func(t *testing.T) { handler.SetCipher(mockCipher) @@ -335,7 +335,7 @@ func TestAPIV1RequestCloudSyncmgrPost(t *testing.T) { mockHelper.EXPECT().Response(gomock.Any(), gomock.Any(), gomock.Eq(http.StatusServiceUnavailable)), ) - handler.APIV1RequestCloudSyncmgrPost(w, r) + handler.APIV1RequestCloudSyncmgrPublish(w, r) }) t.Run("InvalidParam", func(t *testing.T) { t.Run("ServiceName", func(t *testing.T) { @@ -358,7 +358,7 @@ func TestAPIV1RequestCloudSyncmgrPost(t *testing.T) { mockHelper.EXPECT().Response(gomock.Any(), gomock.Any(), gomock.Eq(http.StatusOK)), ) - handler.APIV1RequestCloudSyncmgrPost(w, r) + handler.APIV1RequestCloudSyncmgrPublish(w, r) }) t.Run("topic", func(t *testing.T) { handler.SetCipher(mockCipher) @@ -380,7 +380,7 @@ func TestAPIV1RequestCloudSyncmgrPost(t *testing.T) { mockHelper.EXPECT().Response(gomock.Any(), gomock.Any(), gomock.Eq(http.StatusOK)), ) - handler.APIV1RequestCloudSyncmgrPost(w, r) + handler.APIV1RequestCloudSyncmgrPublish(w, r) }) t.Run("url", func(t *testing.T) { handler.SetCipher(mockCipher) @@ -403,7 +403,7 @@ func TestAPIV1RequestCloudSyncmgrPost(t *testing.T) { mockHelper.EXPECT().Response(gomock.Any(), gomock.Any(), gomock.Eq(http.StatusOK)), ) - handler.APIV1RequestCloudSyncmgrPost(w, r) + handler.APIV1RequestCloudSyncmgrPublish(w, r) }) }) })