Skip to content

Commit

Permalink
fix: revert changes in the chaincode
Browse files Browse the repository at this point in the history
Signed-off-by: osamamagdy <[email protected]>
  • Loading branch information
osamamagdy committed Oct 18, 2024
1 parent 6eccc1b commit 061e0e9
Show file tree
Hide file tree
Showing 13 changed files with 1,007 additions and 39 deletions.
25 changes: 12 additions & 13 deletions chaincode/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,44 @@ go 1.21
require (
github.com/cucumber/godog v0.12.6
github.com/hyperledger-labs/cc-tools v1.0.0
github.com/hyperledger/fabric-chaincode-go v0.0.0-20230228194215-b84622ba6a7a
github.com/hyperledger/fabric-private-chaincode v1.0.0-rc3.0.20240522085958-35685169c680
github.com/hyperledger/fabric-protos-go v0.3.0
github.com/hyperledger/fabric-chaincode-go v0.0.0-20210603161043-af0e3898842a
github.com/hyperledger/fabric-protos-go v0.0.0-20210528200356-82833ecdac31
)

require (
github.com/cucumber/gherkin-go/v19 v19.0.3 // indirect
github.com/cucumber/messages-go/v16 v16.0.1 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-memdb v1.3.4 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hyperledger/fabric v2.1.1+incompatible // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/miekg/pkcs11 v1.1.1 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/miekg/pkcs11 v1.0.3 // indirect
github.com/mitchellh/mapstructure v1.3.2 // indirect
github.com/pelletier/go-toml v1.8.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/sykesm/zap-logfmt v0.0.4 // indirect
go.uber.org/atomic v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.25.0 // indirect
go.uber.org/multierr v1.5.0 // indirect
go.uber.org/zap v1.16.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect
google.golang.org/grpc v1.57.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
honnef.co/go/tools v0.4.3 // indirect
honnef.co/go/tools v0.0.1-2020.1.4 // indirect
)
22 changes: 0 additions & 22 deletions chaincode/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
Expand All @@ -160,15 +158,9 @@ github.com/hyperledger/fabric v2.1.1+incompatible h1:cYYRv3vVg4kA6DmrixLxwn1nwBE
github.com/hyperledger/fabric v2.1.1+incompatible/go.mod h1:tGFAOCT696D3rG0Vofd2dyWYLySHlh0aQjf7Q1HAju0=
github.com/hyperledger/fabric-chaincode-go v0.0.0-20210603161043-af0e3898842a h1:W3NE4+0cxLe/EK/VyhtLpR8kOBkkXCKDv8Ixy93YRjo=
github.com/hyperledger/fabric-chaincode-go v0.0.0-20210603161043-af0e3898842a/go.mod h1:N7H3sA7Tx4k/YzFq7U0EPdqJtqvM4Kild0JoCc7C0Dc=
github.com/hyperledger/fabric-chaincode-go v0.0.0-20230228194215-b84622ba6a7a h1:HwSCxEeiBthwcazcAykGATQ36oG9M+HEQvGLvB7aLvA=
github.com/hyperledger/fabric-chaincode-go v0.0.0-20230228194215-b84622ba6a7a/go.mod h1:TDSu9gxURldEnaGSFbH1eMlfSQBWQcMQfnDBcpQv5lU=
github.com/hyperledger/fabric-private-chaincode v1.0.0-rc3.0.20240522085958-35685169c680 h1:1xTkPZMFg/gJGIAKrI7wlKIBo/YM02zjEDX/7c8thcg=
github.com/hyperledger/fabric-private-chaincode v1.0.0-rc3.0.20240522085958-35685169c680/go.mod h1:2VMIOOrqLYixMciM3cFeIr/3fW9IEHHfCX0+NEiWMqg=
github.com/hyperledger/fabric-protos-go v0.0.0-20190919234611-2a87503ac7c9/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0=
github.com/hyperledger/fabric-protos-go v0.0.0-20210528200356-82833ecdac31 h1:T/uwoFIUioDDLffuJ/XgMLOWCUcx95/xXidv5igafl8=
github.com/hyperledger/fabric-protos-go v0.0.0-20210528200356-82833ecdac31/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0=
github.com/hyperledger/fabric-protos-go v0.3.0 h1:MXxy44WTMENOh5TI8+PCK2x6pMj47Go2vFRKDHB2PZs=
github.com/hyperledger/fabric-protos-go v0.3.0/go.mod h1:WWnyWP40P2roPmmvxsUXSvVI/CF6vwY1K1UFidnKBys=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
Expand All @@ -186,14 +178,10 @@ github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0V
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/miekg/pkcs11 v1.0.3 h1:iMwmD7I5225wv84WxIG/bmxz9AXjWvTWIbM/TYHvWtw=
github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs=
github.com/miekg/pkcs11 v1.1.1 h1:Ugu9pdy6vAYku5DEpVWVFPYnzV+bxB+iRdbuFSu7TvU=
github.com/miekg/pkcs11 v1.1.1/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs=
github.com/mitchellh/mapstructure v1.3.2 h1:mRS76wmkOn3KkKAyXDu42V+6ebnXWIztFSYGN7GeoRg=
github.com/mitchellh/mapstructure v1.3.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/pelletier/go-toml v1.8.0 h1:Keo9qb7iRJs2voHvunFtuuYFsbWeOBh8/P9v/kVMFtw=
github.com/pelletier/go-toml v1.8.0/go.mod h1:D6yutnOGMveHEPV7VQOuvI/gXY61bv+9bAOTRnLElKs=
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand All @@ -211,7 +199,6 @@ github.com/spf13/afero v1.9.2 h1:j49Hj62F0n+DaZ1dDCvhABaPNSGNkt32oRFxI33IEMw=
github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y=
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g=
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
Expand Down Expand Up @@ -248,15 +235,11 @@ go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A=
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4=
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
go.uber.org/zap v1.12.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
go.uber.org/zap v1.16.0 h1:uFRZXykJGK9lLY4HtgSw44DnIcAM+kRBP7x5m+NpAOM=
go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ=
go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c=
go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand Down Expand Up @@ -525,8 +508,6 @@ google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6D
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 h1:0nDDozoAU19Qb2HwhXadU8OcsiO/09cnTqhUtq2MEOM=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b h1:ZlWIi1wSK56/8hn4QcBp/j9M7Gt3U/3hZw3mC7vDICo=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:swOH3j0KzcDDgGUWr+SNpyTen5YrXjS3eyPzFYKc6lc=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
Expand All @@ -545,8 +526,6 @@ google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA5
google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw=
google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo=
google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk=
google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
Expand Down Expand Up @@ -582,7 +561,6 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.4.3/go.mod h1:36ZgoUOrqOk1GxwHhyryEkq8FQWkUO2xGuSMhUCcdvA=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
7 changes: 3 additions & 4 deletions chaincode/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/hyperledger-labs/cc-tools/events"
sw "github.com/hyperledger-labs/cc-tools/stubwrapper"
tx "github.com/hyperledger-labs/cc-tools/transactions"
fpc "github.com/hyperledger/fabric-private-chaincode/ecc_go/chaincode"

"github.com/hyperledger/fabric-chaincode-go/shim"
pb "github.com/hyperledger/fabric-protos-go/peer"
Expand Down Expand Up @@ -68,7 +67,7 @@ func main() {
if os.Getenv("RUN_CCAAS") == "true" {
err = runCCaaS()
} else {
err = shim.Start(fpc.NewPrivateChaincode(new(CCDemo)))
err = shim.Start(new(CCDemo))
}

if err != nil {
Expand All @@ -78,7 +77,7 @@ func main() {

func runCCaaS() error {
address := os.Getenv("CHAINCODE_SERVER_ADDRESS")
ccid := os.Getenv("CHAINCODE_PKG_ID")
ccid := os.Getenv("CHAINCODE_ID")

tlsProps, err := getTLSProperties()
if err != nil {
Expand All @@ -88,7 +87,7 @@ func runCCaaS() error {
server := &shim.ChaincodeServer{
CCID: ccid,
Address: address,
CC: fpc.NewPrivateChaincode(new(CCDemo)),
CC: new(CCDemo),
TLSProps: *tlsProps,
}

Expand Down
28 changes: 28 additions & 0 deletions chaincode/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package main

import (
"log"
"os"
"testing"

"github.com/hyperledger-labs/cc-tools/mock"
)

func TestMain(m *testing.M) {
log.SetFlags(log.Lshortfile)

err := SetupCC()
if err != nil {
log.Println(err)
os.Exit(1)
}

stub := mock.NewMockStub("org1MSP", new(CCDemo))
res := stub.MockInit("testInit", [][]byte{[]byte("init")})
if res.GetStatus() != 200 {
log.Println(res.GetMessage())
os.Exit(1)
}

os.Exit(m.Run())
}
35 changes: 35 additions & 0 deletions chaincode/tests/features/createNewLibrary.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Feature: Create New Library
In order to create a new library
As an API client
I want to make a request with the name of the desired library

Scenario: Create a new library
Given there is a running "" test network from scratch
When I make a "POST" request to "/api/invoke/createNewLibrary" on port 80 with:
"""
{
"name": "Elizabeth's Library"
}
"""
Then the response code should be 200
And the response should have:
"""
{
"@key": "library:9cf6726a-a327-568a-baf1-5881393073bf",
"@lastTouchBy": "orgMSP",
"@lastTx": "createNewLibrary",
"@assetType": "library",
"name": "Elizabeth's Library"
}
"""

Scenario: Try to create a new library with a name that already exists
Given there is a running "" test network
Given there is a library with name "John's Library"
When I make a "POST" request to "/api/invoke/createNewLibrary" on port 80 with:
"""
{
"name": "John's Library"
}
"""
Then the response code should be 409
41 changes: 41 additions & 0 deletions chaincode/tests/features/getBooksByAuthor.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Feature: Get Books By Author
In order to get all the books by an author
As an API client
I want to make a request to the getBooksByAuthor transaction
And receive the appropriate books

Scenario: Request an author with multiple books
Given there is a running "" test network
And there are 3 books with prefix "book" by author "Jack"
When I make a "GET" request to "/api/query/getBooksByAuthor" on port 80 with:
"""
{
"authorName": "Jack"
}
"""
Then the response code should be 200
And the "result" field should have size 3

Scenario: Request an author with no books
Given there is a running "" test network
When I make a "GET" request to "/api/query/getBooksByAuthor" on port 80 with:
"""
{
"authorName": "Mary"
}
"""
Then the response code should be 200
And the "result" field should have size 0

Scenario: Request an author with 2 books while there are other authors with more books
Given there is a running "" test network
Given there are 1 books with prefix "fantasy" by author "Missy"
Given there are 2 books with prefix "cook" by author "John"
When I make a "GET" request to "/api/query/getBooksByAuthor" on port 80 with:
"""
{
"authorName": "John"
}
"""
Then the response code should be 200
And the "result" field should have size 2
63 changes: 63 additions & 0 deletions chaincode/tests/features/getNumberOfBooksFromLibrary.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
Feature: Get Number Of Books From Library
In order to create the number of books from library
As an API client
I want to make a request

Scenario: Query Get Number Of Books From Library that Exists
Given there is a running "" test network
And I make a "POST" request to "/api/invoke/createAsset" on port 80 with:
"""
{
"asset": [
{
"@assetType": "book",
"title": "Meu Nome é Maria",
"author": "Maria Viana"
}
]
}
"""
And I make a "POST" request to "/api/invoke/createAsset" on port 80 with:
"""
{
"asset": [{
"@assetType": "library",
"name": "Maria's Library",
"books": [
{
"@assetType": "book",
"@key": "book:a36a2920-c405-51c3-b584-dcd758338cb5"
}
]
}]
}
"""
When I make a "GET" request to "/api/query/getNumberOfBooksFromLibrary" on port 80 with:
"""
{
"library": {
"@key": "library:3cab201f-9e2b-579d-b7b2-72297ed17f49",
"@assetType": "library"
}
}
"""
Then the response code should be 200
And the response should have:
"""
{
"numberOfBooks": 1.0
}
"""

Scenario: Query Get Number Of Books From Library that Does Not Exists
Given there is a running "" test network
When I make a "GET" request to "/api/query/getNumberOfBooksFromLibrary" on port 80 with:
"""
{
"library": {
"@key": "library:5c5b201f-9e4c-579d-b7b2-72297ed17f78",
"@assetType": "library"
}
}
"""
Then the response code should be 400
Loading

0 comments on commit 061e0e9

Please sign in to comment.