diff --git a/CHANGELOG.md b/CHANGELOG.md
index 84b3ff5..8c8a7b1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,10 @@
-#
Remote Procedure Calls Golang Changelog
+#
Remote Procedure Calls for Pip.Services in Go Changelog
+
+## 1.3.0 (2021-04-33)
+
+### Breaking Changes
+* **test** Added TestRestClient
+* **test** Added TestCommandableHttpClient
## 1.2.0 (2021-04-04)
@@ -10,8 +16,7 @@
## 1.1.3 (2021-03-15)
### Features
-* **services**
-Add **correlation_id** and **access_token** to CORS headers
+* **services** Added **correlation_id** and **access_token** to CORS headers
## 1.1.0 (2021-02-21)
@@ -21,23 +26,19 @@ Add **correlation_id** and **access_token** to CORS headers
## 1.0.13 (2020-12-10)
### Features
-
* Fix work with CorrelationID in RestService
* Update dependencies
## 1.0.12 (2020-12-10)
### Features
-
* Fix headers in RestClient for properly work with others services
-
## 1.0.8-1.0.11 (2020-12-02)
### Features
-
* Added helper methods to RestOperations
-* Change RegisterWithAuth methods
+* Changed RegisterWithAuth methods
### Bug Fixes
* Fix authorizer
@@ -45,19 +46,16 @@ Add **correlation_id** and **access_token** to CORS headers
## 1.0.7 (2020-11-20)
### Features
-
* Added swagger support
## 1.0.5-1.0.6 (2020-11-13)
### Features
-
* Added helper methods
## 1.0.3-1.0.4 (2020-11-12)
### Features
-
* Added helper methods in RestService
### Bug Fixes
@@ -66,7 +64,6 @@ Add **correlation_id** and **access_token** to CORS headers
## 1.0.1-1.0.2 (2020-08-05)
### Features
-
* Added error handler in Call method of RestClient
### Bug Fixes
@@ -77,7 +74,6 @@ Add **correlation_id** and **access_token** to CORS headers
Initial public release
### Features
-
* **build** HTTP service factory
* **clients** mechanisms for retrieving connection settings
* **connect** helper module to retrieve connections services and clients
diff --git a/Readme.md b/Readme.md
index 5fead58..f126567 100644
--- a/Readme.md
+++ b/Readme.md
@@ -1,4 +1,4 @@
-#
Remote Procedure Calls Golang
+#
Remote Procedure Calls for Pip.Services in Go
This module is a part of the [Pip.Services](http://pipservices.org) polyglot microservices toolkit.
diff --git a/test/IDummyController.go b/test/IDummyController.go
deleted file mode 100644
index 118c21c..0000000
--- a/test/IDummyController.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package test_rpc
-
-import (
- cdata "github.com/pip-services3-go/pip-services3-commons-go/data"
-)
-
-type IDummyController interface {
- GetPageByFilter(correlationId string, filter *cdata.FilterParams, paging *cdata.PagingParams) (result *DummyDataPage, err error)
- GetOneById(correlationId string, id string) (result *Dummy, err error)
- Create(correlationId string, entity Dummy) (result *Dummy, err error)
- Update(correlationId string, entity Dummy) (result *Dummy, err error)
- DeleteById(correlationId string, id string) (result *Dummy, err error)
-
- CheckCorrelationId(correlationId string) (result map[string]string, err error)
-}
diff --git a/test/TestCommandableHttpClient.go b/test/TestCommandableHttpClient.go
new file mode 100644
index 0000000..8df568e
--- /dev/null
+++ b/test/TestCommandableHttpClient.go
@@ -0,0 +1,15 @@
+package test
+
+import (
+ "github.com/pip-services3-go/pip-services3-rpc-go/clients"
+)
+
+type TestCommandableHttpClient struct {
+ clients.CommandableHttpClient
+}
+
+func NewTestCommandableHttpClient(baseRoute string) *TestCommandableHttpClient {
+ c := &TestCommandableHttpClient{}
+ c.CommandableHttpClient = *clients.NewCommandableHttpClient(baseRoute)
+ return c
+}
diff --git a/test/TestRestClient.go b/test/TestRestClient.go
new file mode 100644
index 0000000..8ec5850
--- /dev/null
+++ b/test/TestRestClient.go
@@ -0,0 +1,16 @@
+package test
+
+import (
+ "github.com/pip-services3-go/pip-services3-rpc-go/clients"
+)
+
+type TestRestClient struct {
+ clients.RestClient
+}
+
+func NewTestRestClient(baseRoute string) *TestRestClient {
+ c := &TestRestClient{}
+ c.RestClient = *clients.NewRestClient()
+ c.BaseRoute = baseRoute
+ return c
+}
diff --git a/test/clients/DummyClientFixture.go b/test/clients/DummyClientFixture.go
index d83f93c..8573d47 100644
--- a/test/clients/DummyClientFixture.go
+++ b/test/clients/DummyClientFixture.go
@@ -1,10 +1,10 @@
-package test_rpc_clients
+package test_clients
import (
"testing"
cdata "github.com/pip-services3-go/pip-services3-commons-go/data"
- testrpc "github.com/pip-services3-go/pip-services3-rpc-go/test"
+ tdata "github.com/pip-services3-go/pip-services3-rpc-go/test/data"
"github.com/stretchr/testify/assert"
)
@@ -18,9 +18,8 @@ func NewDummyClientFixture(client IDummyClient) *DummyClientFixture {
}
func (c *DummyClientFixture) TestCrudOperations(t *testing.T) {
-
- dummy1 := testrpc.Dummy{Id: "", Key: "Key 1", Content: "Content 1"}
- dummy2 := testrpc.Dummy{Id: "", Key: "Key 2", Content: "Content 2"}
+ dummy1 := tdata.Dummy{Id: "", Key: "Key 1", Content: "Content 1"}
+ dummy2 := tdata.Dummy{Id: "", Key: "Key 2", Content: "Content 2"}
// Create one dummy
dummy, err := c.client.CreateDummy("ClientFixture", dummy1)
@@ -65,5 +64,4 @@ func (c *DummyClientFixture) TestCrudOperations(t *testing.T) {
values, err := c.client.CheckCorrelationId("test_cor_id")
assert.Nil(t, err)
assert.Equal(t, values["correlationId"], "test_cor_id")
-
}
diff --git a/test/clients/DummyCommandableHttpClient.go b/test/clients/DummyCommandableHttpClient.go
index b3c34b5..0cb8cc3 100644
--- a/test/clients/DummyCommandableHttpClient.go
+++ b/test/clients/DummyCommandableHttpClient.go
@@ -1,11 +1,11 @@
-package test_rpc_clients
+package test_clients
import (
"reflect"
cdata "github.com/pip-services3-go/pip-services3-commons-go/data"
"github.com/pip-services3-go/pip-services3-rpc-go/clients"
- testrpc "github.com/pip-services3-go/pip-services3-rpc-go/test"
+ tdata "github.com/pip-services3-go/pip-services3-rpc-go/test/data"
)
type DummyCommandableHttpClient struct {
@@ -18,7 +18,7 @@ func NewDummyCommandableHttpClient() *DummyCommandableHttpClient {
return &dchc
}
-func (c *DummyCommandableHttpClient) GetDummies(correlationId string, filter *cdata.FilterParams, paging *cdata.PagingParams) (result *testrpc.DummyDataPage, err error) {
+func (c *DummyCommandableHttpClient) GetDummies(correlationId string, filter *cdata.FilterParams, paging *cdata.PagingParams) (result *tdata.DummyDataPage, err error) {
params := cdata.NewEmptyStringValueMap()
c.AddFilterParams(params, filter)
@@ -28,11 +28,11 @@ func (c *DummyCommandableHttpClient) GetDummies(correlationId string, filter *cd
if calErr != nil {
return nil, calErr
}
- result, _ = calValue.(*testrpc.DummyDataPage)
+ result, _ = calValue.(*tdata.DummyDataPage)
return result, err
}
-func (c *DummyCommandableHttpClient) GetDummyById(correlationId string, dummyId string) (result *testrpc.Dummy, err error) {
+func (c *DummyCommandableHttpClient) GetDummyById(correlationId string, dummyId string) (result *tdata.Dummy, err error) {
params := cdata.NewEmptyAnyValueMap()
params.Put("dummy_id", dummyId)
@@ -41,11 +41,11 @@ func (c *DummyCommandableHttpClient) GetDummyById(correlationId string, dummyId
if calErr != nil {
return nil, calErr
}
- result, _ = calValue.(*testrpc.Dummy)
+ result, _ = calValue.(*tdata.Dummy)
return result, err
}
-func (c *DummyCommandableHttpClient) CreateDummy(correlationId string, dummy testrpc.Dummy) (result *testrpc.Dummy, err error) {
+func (c *DummyCommandableHttpClient) CreateDummy(correlationId string, dummy tdata.Dummy) (result *tdata.Dummy, err error) {
params := cdata.NewEmptyAnyValueMap()
params.Put("dummy", dummy)
@@ -54,11 +54,11 @@ func (c *DummyCommandableHttpClient) CreateDummy(correlationId string, dummy tes
if calErr != nil {
return nil, calErr
}
- result, _ = calValue.(*testrpc.Dummy)
+ result, _ = calValue.(*tdata.Dummy)
return result, err
}
-func (c *DummyCommandableHttpClient) UpdateDummy(correlationId string, dummy testrpc.Dummy) (result *testrpc.Dummy, err error) {
+func (c *DummyCommandableHttpClient) UpdateDummy(correlationId string, dummy tdata.Dummy) (result *tdata.Dummy, err error) {
params := cdata.NewEmptyAnyValueMap()
params.Put("dummy", dummy)
@@ -67,11 +67,11 @@ func (c *DummyCommandableHttpClient) UpdateDummy(correlationId string, dummy tes
if calErr != nil {
return nil, calErr
}
- result, _ = calValue.(*testrpc.Dummy)
+ result, _ = calValue.(*tdata.Dummy)
return result, err
}
-func (c *DummyCommandableHttpClient) DeleteDummy(correlationId string, dummyId string) (result *testrpc.Dummy, err error) {
+func (c *DummyCommandableHttpClient) DeleteDummy(correlationId string, dummyId string) (result *tdata.Dummy, err error) {
params := cdata.NewEmptyAnyValueMap()
params.Put("dummy_id", dummyId)
@@ -80,7 +80,7 @@ func (c *DummyCommandableHttpClient) DeleteDummy(correlationId string, dummyId s
if calErr != nil {
return nil, calErr
}
- result, _ = calValue.(*testrpc.Dummy)
+ result, _ = calValue.(*tdata.Dummy)
return result, err
}
diff --git a/test/clients/DummyCommandableHttpClient_test.go b/test/clients/DummyCommandableHttpClient_test.go
index 19e8347..057eb9f 100644
--- a/test/clients/DummyCommandableHttpClient_test.go
+++ b/test/clients/DummyCommandableHttpClient_test.go
@@ -1,4 +1,4 @@
-package test_rpc_clients
+package test_clients
import (
"testing"
diff --git a/test/clients/DummyDirectClient.go b/test/clients/DummyDirectClient.go
index 091df99..de5368e 100644
--- a/test/clients/DummyDirectClient.go
+++ b/test/clients/DummyDirectClient.go
@@ -1,15 +1,16 @@
-package test_rpc_clients
+package test_clients
import (
cdata "github.com/pip-services3-go/pip-services3-commons-go/data"
cref "github.com/pip-services3-go/pip-services3-commons-go/refer"
"github.com/pip-services3-go/pip-services3-rpc-go/clients"
- testrpc "github.com/pip-services3-go/pip-services3-rpc-go/test"
+ tdata "github.com/pip-services3-go/pip-services3-rpc-go/test/data"
+ tlogic "github.com/pip-services3-go/pip-services3-rpc-go/test/logic"
)
type DummyDirectClient struct {
clients.DirectClient
- specificController testrpc.IDummyController
+ specificController tlogic.IDummyController
}
func NewDummyDirectClient() *DummyDirectClient {
@@ -22,7 +23,7 @@ func NewDummyDirectClient() *DummyDirectClient {
func (c *DummyDirectClient) SetReferences(references cref.IReferences) {
c.DirectClient.SetReferences(references)
- specificController, ok := c.Controller.(testrpc.IDummyController)
+ specificController, ok := c.Controller.(tlogic.IDummyController)
if !ok {
panic("DummyDirectClient: Cant't resolv dependency 'controller' to IDummyController")
}
@@ -30,7 +31,7 @@ func (c *DummyDirectClient) SetReferences(references cref.IReferences) {
}
-func (c *DummyDirectClient) GetDummies(correlationId string, filter *cdata.FilterParams, paging *cdata.PagingParams) (result *testrpc.DummyDataPage, err error) {
+func (c *DummyDirectClient) GetDummies(correlationId string, filter *cdata.FilterParams, paging *cdata.PagingParams) (result *tdata.DummyDataPage, err error) {
timing := c.Instrument(correlationId, "dummy.get_page_by_filter")
result, err = c.specificController.GetPageByFilter(correlationId, filter, paging)
@@ -39,7 +40,7 @@ func (c *DummyDirectClient) GetDummies(correlationId string, filter *cdata.Filte
}
-func (c *DummyDirectClient) GetDummyById(correlationId string, dummyId string) (result *testrpc.Dummy, err error) {
+func (c *DummyDirectClient) GetDummyById(correlationId string, dummyId string) (result *tdata.Dummy, err error) {
timing := c.Instrument(correlationId, "dummy.get_one_by_id")
result, err = c.specificController.GetOneById(correlationId, dummyId)
@@ -47,7 +48,7 @@ func (c *DummyDirectClient) GetDummyById(correlationId string, dummyId string) (
return result, err
}
-func (c *DummyDirectClient) CreateDummy(correlationId string, dummy testrpc.Dummy) (result *testrpc.Dummy, err error) {
+func (c *DummyDirectClient) CreateDummy(correlationId string, dummy tdata.Dummy) (result *tdata.Dummy, err error) {
timing := c.Instrument(correlationId, "dummy.create")
result, err = c.specificController.Create(correlationId, dummy)
@@ -55,7 +56,7 @@ func (c *DummyDirectClient) CreateDummy(correlationId string, dummy testrpc.Dumm
return result, err
}
-func (c *DummyDirectClient) UpdateDummy(correlationId string, dummy testrpc.Dummy) (result *testrpc.Dummy, err error) {
+func (c *DummyDirectClient) UpdateDummy(correlationId string, dummy tdata.Dummy) (result *tdata.Dummy, err error) {
timing := c.Instrument(correlationId, "dummy.update")
result, err = c.specificController.Update(correlationId, dummy)
@@ -63,7 +64,7 @@ func (c *DummyDirectClient) UpdateDummy(correlationId string, dummy testrpc.Dumm
return result, err
}
-func (c *DummyDirectClient) DeleteDummy(correlationId string, dummyId string) (result *testrpc.Dummy, err error) {
+func (c *DummyDirectClient) DeleteDummy(correlationId string, dummyId string) (result *tdata.Dummy, err error) {
timing := c.Instrument(correlationId, "dummy.delete_by_id")
result, err = c.specificController.DeleteById(correlationId, dummyId)
diff --git a/test/clients/DummyDirectClient_test.go b/test/clients/DummyDirectClient_test.go
index 712ccd3..1b9282a 100644
--- a/test/clients/DummyDirectClient_test.go
+++ b/test/clients/DummyDirectClient_test.go
@@ -1,4 +1,4 @@
-package test_rpc_clients
+package test_clients
import (
"testing"
diff --git a/test/clients/DummyRestClient.go b/test/clients/DummyRestClient.go
index 9365b36..7a0a280 100644
--- a/test/clients/DummyRestClient.go
+++ b/test/clients/DummyRestClient.go
@@ -1,16 +1,16 @@
-package test_rpc_clients
+package test_clients
import (
"reflect"
cdata "github.com/pip-services3-go/pip-services3-commons-go/data"
"github.com/pip-services3-go/pip-services3-rpc-go/clients"
- testrpc "github.com/pip-services3-go/pip-services3-rpc-go/test"
+ tdata "github.com/pip-services3-go/pip-services3-rpc-go/test/data"
)
var (
- dummyDataPageType = reflect.TypeOf(&testrpc.DummyDataPage{})
- dummyType = reflect.TypeOf(&testrpc.Dummy{})
+ dummyDataPageType = reflect.TypeOf(&tdata.DummyDataPage{})
+ dummyType = reflect.TypeOf(&tdata.Dummy{})
)
type DummyRestClient struct {
@@ -24,7 +24,7 @@ func NewDummyRestClient() *DummyRestClient {
}
func (c *DummyRestClient) GetDummies(correlationId string, filter *cdata.FilterParams,
- paging *cdata.PagingParams) (result *testrpc.DummyDataPage, err error) {
+ paging *cdata.PagingParams) (result *tdata.DummyDataPage, err error) {
params := cdata.NewEmptyStringValueMap()
c.AddFilterParams(params, filter)
@@ -35,52 +35,52 @@ func (c *DummyRestClient) GetDummies(correlationId string, filter *cdata.FilterP
return nil, calErr
}
- result, _ = calValue.(*testrpc.DummyDataPage)
+ result, _ = calValue.(*tdata.DummyDataPage)
c.Instrument(correlationId, "dummy.get_page_by_filter")
return result, nil
}
-func (c *DummyRestClient) GetDummyById(correlationId string, dummyId string) (result *testrpc.Dummy, err error) {
+func (c *DummyRestClient) GetDummyById(correlationId string, dummyId string) (result *tdata.Dummy, err error) {
calValue, calErr := c.Call(dummyType, "get", "/dummies/"+dummyId, correlationId, nil, nil)
if calErr != nil {
return nil, calErr
}
- result, _ = calValue.(*testrpc.Dummy)
+ result, _ = calValue.(*tdata.Dummy)
c.Instrument(correlationId, "dummy.get_one_by_id")
return result, nil
}
-func (c *DummyRestClient) CreateDummy(correlationId string, dummy testrpc.Dummy) (result *testrpc.Dummy, err error) {
+func (c *DummyRestClient) CreateDummy(correlationId string, dummy tdata.Dummy) (result *tdata.Dummy, err error) {
calValue, calErr := c.Call(dummyType, "post", "/dummies", correlationId, nil, dummy)
if calErr != nil {
return nil, calErr
}
- result, _ = calValue.(*testrpc.Dummy)
+ result, _ = calValue.(*tdata.Dummy)
c.Instrument(correlationId, "dummy.create")
return result, nil
}
-func (c *DummyRestClient) UpdateDummy(correlationId string, dummy testrpc.Dummy) (result *testrpc.Dummy, err error) {
+func (c *DummyRestClient) UpdateDummy(correlationId string, dummy tdata.Dummy) (result *tdata.Dummy, err error) {
calValue, calErr := c.Call(dummyType, "put", "/dummies", correlationId, nil, dummy)
if calErr != nil {
return nil, calErr
}
- result, _ = calValue.(*testrpc.Dummy)
+ result, _ = calValue.(*tdata.Dummy)
c.Instrument(correlationId, "dummy.update")
return result, nil
}
-func (c *DummyRestClient) DeleteDummy(correlationId string, dummyId string) (result *testrpc.Dummy, err error) {
+func (c *DummyRestClient) DeleteDummy(correlationId string, dummyId string) (result *tdata.Dummy, err error) {
calValue, calErr := c.Call(dummyType, "delete", "/dummies/"+dummyId, correlationId, nil, nil)
if calErr != nil {
return nil, calErr
}
- result, _ = calValue.(*testrpc.Dummy)
+ result, _ = calValue.(*tdata.Dummy)
c.Instrument(correlationId, "dummy.delete_by_id")
return result, nil
}
diff --git a/test/clients/DummyRestClient_test.go b/test/clients/DummyRestClient_test.go
index 74f304e..0223f8b 100644
--- a/test/clients/DummyRestClient_test.go
+++ b/test/clients/DummyRestClient_test.go
@@ -1,4 +1,4 @@
-package test_rpc_clients
+package test_clients
import (
"testing"
diff --git a/test/clients/IDummyClient.go b/test/clients/IDummyClient.go
index 8fc7c06..7a4ea0c 100644
--- a/test/clients/IDummyClient.go
+++ b/test/clients/IDummyClient.go
@@ -1,16 +1,16 @@
-package test_rpc_clients
+package test_clients
import (
cdata "github.com/pip-services3-go/pip-services3-commons-go/data"
- testrpc "github.com/pip-services3-go/pip-services3-rpc-go/test"
+ tdata "github.com/pip-services3-go/pip-services3-rpc-go/test/data"
)
type IDummyClient interface {
- GetDummies(correlationId string, filter *cdata.FilterParams, paging *cdata.PagingParams) (result *testrpc.DummyDataPage, err error)
- GetDummyById(correlationId string, dummyId string) (result *testrpc.Dummy, err error)
- CreateDummy(correlationId string, dummy testrpc.Dummy) (result *testrpc.Dummy, err error)
- UpdateDummy(correlationId string, dummy testrpc.Dummy) (result *testrpc.Dummy, err error)
- DeleteDummy(correlationId string, dummyId string) (result *testrpc.Dummy, err error)
+ GetDummies(correlationId string, filter *cdata.FilterParams, paging *cdata.PagingParams) (result *tdata.DummyDataPage, err error)
+ GetDummyById(correlationId string, dummyId string) (result *tdata.Dummy, err error)
+ CreateDummy(correlationId string, dummy tdata.Dummy) (result *tdata.Dummy, err error)
+ UpdateDummy(correlationId string, dummy tdata.Dummy) (result *tdata.Dummy, err error)
+ DeleteDummy(correlationId string, dummyId string) (result *tdata.Dummy, err error)
CheckCorrelationId(correlationId string) (result map[string]string, err error)
}
diff --git a/test/clients/RetriesRestClient_test.go b/test/clients/RetriesRestClient_test.go
index 5be8ce0..118efc4 100644
--- a/test/clients/RetriesRestClient_test.go
+++ b/test/clients/RetriesRestClient_test.go
@@ -1,4 +1,4 @@
-package test_rpc_clients
+package test_clients
import (
"testing"
diff --git a/test/connect/HttpConnectionResolver_test.go b/test/connect/HttpConnectionResolver_test.go
index d5d0814..dceb219 100644
--- a/test/connect/HttpConnectionResolver_test.go
+++ b/test/connect/HttpConnectionResolver_test.go
@@ -1,4 +1,4 @@
-package test_connect_rpc
+package test_connect
import (
"testing"
diff --git a/test/Dummy.go b/test/data/Dummy.go
similarity index 93%
rename from test/Dummy.go
rename to test/data/Dummy.go
index 988a463..0adb10a 100644
--- a/test/Dummy.go
+++ b/test/data/Dummy.go
@@ -1,4 +1,4 @@
-package test_rpc
+package test_data
type Dummy struct {
Id string `json:"id"`
diff --git a/test/DumyDataPage.go b/test/data/DummyDataPage.go
similarity index 94%
rename from test/DumyDataPage.go
rename to test/data/DummyDataPage.go
index 03b9e27..f8f336f 100644
--- a/test/DumyDataPage.go
+++ b/test/data/DummyDataPage.go
@@ -1,4 +1,4 @@
-package test_rpc
+package test_data
type DummyDataPage struct {
Total *int64 `json:"total"`
diff --git a/test/DummySchema.go b/test/data/DummySchema.go
similarity index 95%
rename from test/DummySchema.go
rename to test/data/DummySchema.go
index 4d7cfad..20ba882 100644
--- a/test/DummySchema.go
+++ b/test/data/DummySchema.go
@@ -1,4 +1,4 @@
-package test_rpc
+package test_data
import (
cconv "github.com/pip-services3-go/pip-services3-commons-go/convert"
diff --git a/test/DummyCommandSet.go b/test/logic/DummyCommandSet.go
similarity index 91%
rename from test/DummyCommandSet.go
rename to test/logic/DummyCommandSet.go
index 8f1fda8..7364041 100644
--- a/test/DummyCommandSet.go
+++ b/test/logic/DummyCommandSet.go
@@ -1,4 +1,4 @@
-package test_rpc
+package test_logic
import (
"encoding/json"
@@ -8,6 +8,7 @@ import (
cdata "github.com/pip-services3-go/pip-services3-commons-go/data"
crun "github.com/pip-services3-go/pip-services3-commons-go/run"
cvalid "github.com/pip-services3-go/pip-services3-commons-go/validate"
+ tdata "github.com/pip-services3-go/pip-services3-rpc-go/test/data"
)
type DummyCommandSet struct {
@@ -56,10 +57,10 @@ func (c *DummyCommandSet) makeGetOneByIdCommand() ccomand.ICommand {
func (c *DummyCommandSet) makeCreateCommand() ccomand.ICommand {
return ccomand.NewCommand(
"create_dummy",
- cvalid.NewObjectSchema().WithRequiredProperty("dummy", NewDummySchema()),
+ cvalid.NewObjectSchema().WithRequiredProperty("dummy", tdata.NewDummySchema()),
func(correlationId string, args *crun.Parameters) (result interface{}, err error) {
val, _ := json.Marshal(args.Get("dummy"))
- var entity Dummy
+ var entity tdata.Dummy
json.Unmarshal(val, &entity)
return c.controller.Create(correlationId, entity)
@@ -70,10 +71,10 @@ func (c *DummyCommandSet) makeCreateCommand() ccomand.ICommand {
func (c *DummyCommandSet) makeUpdateCommand() ccomand.ICommand {
return ccomand.NewCommand(
"update_dummy",
- cvalid.NewObjectSchema().WithRequiredProperty("dummy", NewDummySchema()),
+ cvalid.NewObjectSchema().WithRequiredProperty("dummy", tdata.NewDummySchema()),
func(correlationId string, args *crun.Parameters) (result interface{}, err error) {
val, _ := json.Marshal(args.Get("dummy"))
- var entity Dummy
+ var entity tdata.Dummy
json.Unmarshal(val, &entity)
return c.controller.Update(correlationId, entity)
},
diff --git a/test/DummyController.go b/test/logic/DummyController.go
similarity index 74%
rename from test/DummyController.go
rename to test/logic/DummyController.go
index e700920..698786b 100644
--- a/test/DummyController.go
+++ b/test/logic/DummyController.go
@@ -1,18 +1,19 @@
-package test_rpc
+package test_logic
import (
ccomand "github.com/pip-services3-go/pip-services3-commons-go/commands"
cdata "github.com/pip-services3-go/pip-services3-commons-go/data"
+ tdata "github.com/pip-services3-go/pip-services3-rpc-go/test/data"
)
type DummyController struct {
commandSet *DummyCommandSet
- entities []Dummy
+ entities []tdata.Dummy
}
func NewDummyController() *DummyController {
dc := DummyController{}
- dc.entities = make([]Dummy, 0)
+ dc.entities = make([]tdata.Dummy, 0)
return &dc
}
@@ -23,7 +24,8 @@ func (c *DummyController) GetCommandSet() *ccomand.CommandSet {
return &c.commandSet.CommandSet
}
-func (c *DummyController) GetPageByFilter(correlationId string, filter *cdata.FilterParams, paging *cdata.PagingParams) (items *DummyDataPage, err error) {
+func (c *DummyController) GetPageByFilter(correlationId string, filter *cdata.FilterParams,
+ paging *cdata.PagingParams) (items *tdata.DummyDataPage, err error) {
if filter == nil {
filter = cdata.NewEmptyFilterParams()
@@ -36,9 +38,9 @@ func (c *DummyController) GetPageByFilter(correlationId string, filter *cdata.Fi
var skip int64 = paging.GetSkip(0)
var take int64 = paging.GetTake(100)
- var result []Dummy
+ var result []tdata.Dummy
for i := 0; i < len(c.entities); i++ {
- var entity Dummy = c.entities[i]
+ var entity tdata.Dummy = c.entities[i]
if key != "" && key != entity.Key {
continue
}
@@ -56,12 +58,12 @@ func (c *DummyController) GetPageByFilter(correlationId string, filter *cdata.Fi
result = append(result, entity)
}
var total int64 = (int64)(len(result))
- return NewDummyDataPage(&total, result), nil
+ return tdata.NewDummyDataPage(&total, result), nil
}
-func (c *DummyController) GetOneById(correlationId string, id string) (result *Dummy, err error) {
+func (c *DummyController) GetOneById(correlationId string, id string) (result *tdata.Dummy, err error) {
for i := 0; i < len(c.entities); i++ {
- var entity Dummy = c.entities[i]
+ var entity tdata.Dummy = c.entities[i]
if id == entity.Id {
return &entity, nil
}
@@ -69,7 +71,7 @@ func (c *DummyController) GetOneById(correlationId string, id string) (result *D
return nil, nil
}
-func (c *DummyController) Create(correlationId string, entity Dummy) (result *Dummy, err error) {
+func (c *DummyController) Create(correlationId string, entity tdata.Dummy) (result *tdata.Dummy, err error) {
if entity.Id == "" {
entity.Id = cdata.IdGenerator.NextLong()
c.entities = append(c.entities, entity)
@@ -77,9 +79,9 @@ func (c *DummyController) Create(correlationId string, entity Dummy) (result *Du
return &entity, nil
}
-func (c *DummyController) Update(correlationId string, newEntity Dummy) (result *Dummy, err error) {
+func (c *DummyController) Update(correlationId string, newEntity tdata.Dummy) (result *tdata.Dummy, err error) {
for index := 0; index < len(c.entities); index++ {
- var entity Dummy = c.entities[index]
+ var entity tdata.Dummy = c.entities[index]
if entity.Id == newEntity.Id {
c.entities[index] = newEntity
return &newEntity, nil
@@ -89,8 +91,8 @@ func (c *DummyController) Update(correlationId string, newEntity Dummy) (result
return nil, nil
}
-func (c *DummyController) DeleteById(correlationId string, id string) (result *Dummy, err error) {
- var entity Dummy
+func (c *DummyController) DeleteById(correlationId string, id string) (result *tdata.Dummy, err error) {
+ var entity tdata.Dummy
for i := 0; i < len(c.entities); {
entity = c.entities[i]
diff --git a/test/logic/IDummyController.go b/test/logic/IDummyController.go
new file mode 100644
index 0000000..03d9b49
--- /dev/null
+++ b/test/logic/IDummyController.go
@@ -0,0 +1,16 @@
+package test_logic
+
+import (
+ cdata "github.com/pip-services3-go/pip-services3-commons-go/data"
+ tdata "github.com/pip-services3-go/pip-services3-rpc-go/test/data"
+)
+
+type IDummyController interface {
+ GetPageByFilter(correlationId string, filter *cdata.FilterParams, paging *cdata.PagingParams) (result *tdata.DummyDataPage, err error)
+ GetOneById(correlationId string, id string) (result *tdata.Dummy, err error)
+ Create(correlationId string, entity tdata.Dummy) (result *tdata.Dummy, err error)
+ Update(correlationId string, entity tdata.Dummy) (result *tdata.Dummy, err error)
+ DeleteById(correlationId string, id string) (result *tdata.Dummy, err error)
+
+ CheckCorrelationId(correlationId string) (result map[string]string, err error)
+}
diff --git a/test/services/DummyCommandableHttpService.go b/test/services/DummyCommandableHttpService.go
index aa03b7d..a1a5fdb 100644
--- a/test/services/DummyCommandableHttpService.go
+++ b/test/services/DummyCommandableHttpService.go
@@ -1,4 +1,4 @@
-package test_rpc_services
+package test_services
import (
cref "github.com/pip-services3-go/pip-services3-commons-go/refer"
diff --git a/test/services/DummyCommandableHttpService_test.go b/test/services/DummyCommandableHttpService_test.go
index d0db99b..6d93473 100644
--- a/test/services/DummyCommandableHttpService_test.go
+++ b/test/services/DummyCommandableHttpService_test.go
@@ -1,4 +1,4 @@
-package test_rpc_services
+package test_services
import (
"bytes"
diff --git a/test/services/DummyRestService.go b/test/services/DummyRestService.go
index 1ab5194..904753c 100644
--- a/test/services/DummyRestService.go
+++ b/test/services/DummyRestService.go
@@ -1,4 +1,4 @@
-package test_rpc_services
+package test_services
import (
"encoding/json"
@@ -13,12 +13,13 @@ import (
crefer "github.com/pip-services3-go/pip-services3-commons-go/refer"
cvalid "github.com/pip-services3-go/pip-services3-commons-go/validate"
"github.com/pip-services3-go/pip-services3-rpc-go/services"
- testrpc "github.com/pip-services3-go/pip-services3-rpc-go/test"
+ tdata "github.com/pip-services3-go/pip-services3-rpc-go/test/data"
+ tlogic "github.com/pip-services3-go/pip-services3-rpc-go/test/logic"
)
type DummyRestService struct {
*services.RestService
- controller testrpc.IDummyController
+ controller tlogic.IDummyController
numberOfCalls int
openApiContent string
openApiFile string
@@ -42,7 +43,7 @@ func (c *DummyRestService) SetReferences(references crefer.IReferences) {
c.RestService.SetReferences(references)
depRes, depErr := c.DependencyResolver.GetOneRequired("controller")
if depErr == nil && depRes != nil {
- c.controller = depRes.(testrpc.IDummyController)
+ c.controller = depRes.(tlogic.IDummyController)
}
}
@@ -91,7 +92,7 @@ func (c *DummyRestService) getOneById(res http.ResponseWriter, req *http.Request
func (c *DummyRestService) create(res http.ResponseWriter, req *http.Request) {
correlationId := c.GetCorrelationId(req)
- var dummy testrpc.Dummy
+ var dummy tdata.Dummy
body, bodyErr := ioutil.ReadAll(req.Body)
if bodyErr != nil {
@@ -118,7 +119,7 @@ func (c *DummyRestService) create(res http.ResponseWriter, req *http.Request) {
func (c *DummyRestService) update(res http.ResponseWriter, req *http.Request) {
correlationId := c.GetCorrelationId(req)
- var dummy testrpc.Dummy
+ var dummy tdata.Dummy
body, bodyErr := ioutil.ReadAll(req.Body)
if bodyErr != nil {
@@ -190,14 +191,14 @@ func (c *DummyRestService) Register() {
c.RegisterRoute(
"post", "/dummies",
&cvalid.NewObjectSchema().
- WithRequiredProperty("body", testrpc.NewDummySchema()).Schema,
+ WithRequiredProperty("body", tdata.NewDummySchema()).Schema,
c.create,
)
c.RegisterRoute(
"put", "/dummies",
&cvalid.NewObjectSchema().
- WithRequiredProperty("body", testrpc.NewDummySchema()).Schema,
+ WithRequiredProperty("body", tdata.NewDummySchema()).Schema,
c.update,
)
diff --git a/test/services/DummyRestService_test.go b/test/services/DummyRestService_test.go
index 2d0a09d..9f2c8bc 100644
--- a/test/services/DummyRestService_test.go
+++ b/test/services/DummyRestService_test.go
@@ -1,4 +1,4 @@
-package test_rpc_services
+package test_services
import (
"bytes"
diff --git a/test/services/HeartbeatRestService_test.go b/test/services/HeartbeatRestService_test.go
index 2e9b94c..38870c1 100644
--- a/test/services/HeartbeatRestService_test.go
+++ b/test/services/HeartbeatRestService_test.go
@@ -1,4 +1,4 @@
-package test_rpc_services
+package test_services
import (
"net/http"
diff --git a/test/services/HttpEndpoint_test.go b/test/services/HttpEndpoint_test.go
index 1dfdf42..681d856 100644
--- a/test/services/HttpEndpoint_test.go
+++ b/test/services/HttpEndpoint_test.go
@@ -1,4 +1,4 @@
-package test_rpc_services
+package test_services
import (
"encoding/json"
diff --git a/test/services/StatusRestService_test.go b/test/services/StatusRestService_test.go
index 736f56e..bbd5f98 100644
--- a/test/services/StatusRestService_test.go
+++ b/test/services/StatusRestService_test.go
@@ -1,4 +1,4 @@
-package test_rpc_services
+package test_services
import (
"net/http"