@@ -37,14 +37,97 @@ func (suite *PetStoreSuite) TestApi() {
3737 try .HasHeader ("Access-Control-Allow-Origin" , "*" ))
3838 })
3939
40- suite .T ().Run ("get service" , func (t * testing.T ) {
40+ suite .T ().Run ("get Swagger HTTP service" , func (t * testing.T ) {
4141 try .GetRequest (t , fmt .Sprintf ("http://127.0.0.1:%v/api/services/http/Swagger%%20Petstore" , suite .cfg .Api .Port ),
4242 nil ,
4343 try .HasStatusCode (http .StatusOK ),
4444 try .BodyContains (`{"name":"Swagger Petstore","description":"This is a sample server Petstore server. You can find out more about ` ),
4545 try .BodyMatch (`"configs":\[{"id":".*","url":".*\/acceptance\/petstore\/openapi\.yml","provider":"file","time":".*"}\]` ),
4646 )
4747 })
48+
49+ suite .T ().Run ("get AsyncAPI service" , func (t * testing.T ) {
50+ // ensure scripts are executed
51+ time .Sleep (3 * time .Second )
52+
53+ expected := map [string ]interface {}{
54+ "version" : "1.0.0" ,
55+ "name" : "A sample AsyncApi Kafka streaming api" ,
56+ "description" : "" ,
57+ "servers" : []interface {}{
58+ map [string ]interface {}{
59+ "description" : "" ,
60+ "host" : "127.0.0.1:19092" ,
61+ "name" : "broker" ,
62+ },
63+ },
64+
65+ "topics" : []interface {}{map [string ]interface {}{
66+ "description" : "" ,
67+ "messages" : map [string ]interface {}{
68+ "#/components/messages/order" : map [string ]interface {}{
69+ "contentType" : "application/json" ,
70+ "header" : map [string ]interface {}{
71+ "schema" : map [string ]interface {}{
72+ "properties" : map [string ]interface {}{
73+ "number" : map [string ]interface {}{
74+ "type" : "number" ,
75+ }, "test" : map [string ]interface {}{
76+ "type" : "string" ,
77+ },
78+ }, "type" : "object" ,
79+ },
80+ },
81+ "key" : map [string ]interface {}{
82+ "schema" : map [string ]interface {}{
83+ "type" : "string" ,
84+ },
85+ },
86+ "payload" : map [string ]interface {}{
87+ "schema" : map [string ]interface {}{
88+ "properties" : map [string ]interface {}{
89+ "accepted" : map [string ]interface {}{
90+ "properties" : map [string ]interface {}{
91+ "timestamp" : map [string ]interface {}{"format" : "date-time" , "type" : "string" },
92+ },
93+ "type" : "object" ,
94+ },
95+ "completed" : map [string ]interface {}{
96+ "properties" : map [string ]interface {}{
97+ "timestamp" : map [string ]interface {}{"format" : "date-time" , "type" : "string" },
98+ },
99+ "type" : "object" ,
100+ },
101+ "id" : map [string ]interface {}{"type" : "integer" },
102+ "placed" : map [string ]interface {}{
103+ "properties" : map [string ]interface {}{
104+ "petid" : map [string ]interface {}{"type" : "integer" },
105+ "quantity" : map [string ]interface {}{"format" : "int32" , "type" : "integer" },
106+ "ship-date" : map [string ]interface {}{"format" : "date-time" , "type" : "string" },
107+ },
108+ "type" : "object" ,
109+ },
110+ },
111+ "required" : []interface {}{"id" },
112+ "type" : "object" ,
113+ },
114+ },
115+ },
116+ },
117+ "name" : "petstore.order-event" ,
118+ "partitions" : []interface {}{
119+ map [string ]interface {}{"id" : float64 (0 ), "leader" : map [string ]interface {}{"addr" : "127.0.0.1:19092" , "name" : "broker" }, "offset" : float64 (1 ), "segments" : float64 (1 ), "startOffset" : float64 (0 )},
120+ map [string ]interface {}{"id" : float64 (1 ), "leader" : map [string ]interface {}{"addr" : "127.0.0.1:19092" , "name" : "broker" }, "offset" : float64 (0 ), "segments" : float64 (0 ), "startOffset" : float64 (0 )},
121+ },
122+ }},
123+ }
124+
125+ try .GetRequest (t , fmt .Sprintf ("http://127.0.0.1:%v/api/services/kafka/A%%20sample%%20AsyncApi%%20Kafka%%20streaming%%20api" , suite .cfg .Api .Port ),
126+ nil ,
127+ try .HasStatusCode (http .StatusOK ),
128+ try .BodyContainsData (expected ),
129+ )
130+ })
48131}
49132
50133func (suite * PetStoreSuite ) TestJsHttpHandler () {
@@ -90,12 +173,12 @@ func (suite *PetStoreSuite) TestGetOrderById() {
90173 try .GetRequest (suite .T (), "http://127.0.0.1:18080/store/order/1" ,
91174 map [string ]string {"Accept" : "application/json" },
92175 try .HasStatusCode (http .StatusOK ),
93- try .HasBody (`{"id":98266,"petId":23377,"quantity":92,"shipDate":"1989 -01-30T07:58:01Z","status":"approved","complete":false}` ))
176+ try .HasBody (`{"id":98266,"petId":23377,"quantity":92,"shipDate":"2012 -01-30T07:58:01Z","status":"approved","complete":false}` ))
94177
95178 try .GetRequest (suite .T (), "https://localhost:18443/store/order/10" ,
96179 map [string ]string {"Accept" : "application/json" },
97180 try .HasStatusCode (http .StatusOK ),
98- try .HasBody (`{"id":12545,"petId":20895,"quantity":16,"shipDate":"1989 -11-19T16 :57:16Z","status":"approved","complete":true}` ))
181+ try .HasBody (`{"id":12545,"petId":20895,"quantity":16,"shipDate":"2027 -11-26T16 :57:16Z","status":"approved","complete":true}` ))
99182}
100183
101184func (suite * PetStoreSuite ) TestKafka_TopicConfig () {
0 commit comments