Skip to content

Commit

Permalink
[CloudSync] Renaming the function from CloudSyncMgrPost to CloudSyncP…
Browse files Browse the repository at this point in the history
…ublish

Signed-off-by: Nitu Gupta <[email protected]>
  • Loading branch information
nitu-s-gupta committed Feb 17, 2022
1 parent 24f810f commit 0850f44
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 29 deletions.
6 changes: 3 additions & 3 deletions internal/controller/cloudsyncmgr/cloudsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions internal/controller/cloudsyncmgr/mocks/mocks_cloudsync.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions internal/orchestrationapi/mocks/mock_orchestration.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/orchestrationapi/orchestration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions internal/orchestrationapi/orchestrationapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions internal/restinterface/externalhandler/externalhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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{})
Expand Down
12 changes: 6 additions & 6 deletions internal/restinterface/externalhandler/externalhandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,15 @@ 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)
handler.setHelper(mockHelper)
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)
Expand All @@ -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) {
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
})
})
})
Expand Down

0 comments on commit 0850f44

Please sign in to comment.