shop_decoration_test.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. package test
  2. import (
  3. "ecos/application/domain/shop_decoration"
  4. "git.sxidc.com/go-framework/baize/framework/core/api/request"
  5. "git.sxidc.com/go-framework/baize/framework/core/api/response"
  6. "git.sxidc.com/go-tools/utils/strutils"
  7. "net/http"
  8. "testing"
  9. )
  10. func TestShopDecoration(t *testing.T) {
  11. Init()
  12. defer Destroy()
  13. var shopDecorationID string
  14. var totalCount int64
  15. shopDecorationInfo := new(shop_decoration.Info)
  16. shopDecorationInfos := make([]shop_decoration.Info, 0)
  17. tenantID := strutils.SimpleUUID()
  18. createUserID := strutils.SimpleUUID()
  19. updateUserID := strutils.SimpleUUID()
  20. deleteUserID := strutils.SimpleUUID()
  21. operatorUserName := strutils.SimpleUUID()
  22. name := strutils.SimpleUUID()
  23. pageClientType := strutils.SimpleUUID()
  24. pageData := strutils.SimpleUUID()
  25. pageType := strutils.SimpleUUID()
  26. pageShow := strutils.SimpleUUID()
  27. newName := strutils.SimpleUUID()
  28. newPageClientType := strutils.SimpleUUID()
  29. newPageData := strutils.SimpleUUID()
  30. newPageType := strutils.SimpleUUID()
  31. newPageShow := strutils.SimpleUUID()
  32. NewToolKit(t).CreateShopDecoration(tenantID, name, pageClientType, pageData, pageType, pageShow, createUserID, operatorUserName, &shopDecorationID).
  33. GetShopDecoration(tenantID, shopDecorationID, shopDecorationInfo).
  34. AssertEqual(tenantID, shopDecorationInfo.TenantID, "店铺装修列表租户ID不一致").
  35. AssertEqual(shopDecorationID, shopDecorationInfo.ID, "店铺装修列表ID不一致").
  36. AssertEqual(name, shopDecorationInfo.Name, "店铺装修列表页面名称不一致").
  37. AssertEqual(pageClientType, shopDecorationInfo.PageClientType, "店铺装修列表客户端类型不一致").
  38. AssertEqual(pageData, shopDecorationInfo.PageData, "店铺装修列表页面数据不一致").
  39. AssertEqual(pageType, shopDecorationInfo.PageType, "店铺装修列表页面类型不一致").
  40. AssertEqual(pageShow, shopDecorationInfo.PageShow, "店铺装修列表页面开关状态不一致").
  41. AssertEqual(createUserID, shopDecorationInfo.CreateUserID, "创建用户ID不一致").
  42. AssertEqual(createUserID, shopDecorationInfo.LastUpdateUserID, "最近更新用户ID不一致").
  43. AssertNotEmpty(shopDecorationInfo.CreatedTime, "创建时间为空").
  44. AssertNotEmpty(shopDecorationInfo.LastUpdatedTime, "最近更新时间为空").
  45. GetShopDecorations(tenantID, name, pageClientType, pageData, pageType, pageShow, "1", "1", &shopDecorationInfos, &totalCount).
  46. AssertEqual(int(totalCount), len(shopDecorationInfos), "总数不一致").
  47. AssertEqual(tenantID, shopDecorationInfos[0].TenantID, "店铺装修列表租户ID不一致").
  48. AssertEqual(shopDecorationID, shopDecorationInfos[0].ID, "店铺装修列表ID不一致").
  49. AssertEqual(name, shopDecorationInfos[0].Name, "店铺装修列表页面名称不一致").
  50. AssertEqual(pageClientType, shopDecorationInfos[0].PageClientType, "店铺装修列表客户端类型不一致").
  51. AssertEqual(pageData, shopDecorationInfos[0].PageData, "店铺装修列表页面数据不一致").
  52. AssertEqual(pageType, shopDecorationInfos[0].PageType, "店铺装修列表页面类型不一致").
  53. AssertEqual(pageShow, shopDecorationInfos[0].PageShow, "店铺装修列表页面开关状态不一致").
  54. AssertEqual(createUserID, shopDecorationInfos[0].CreateUserID, "创建用户ID不一致").
  55. AssertEqual(createUserID, shopDecorationInfos[0].LastUpdateUserID, "最近更新用户ID不一致").
  56. AssertNotEmpty(shopDecorationInfos[0].CreatedTime, "创建时间为空").
  57. AssertNotEmpty(shopDecorationInfos[0].LastUpdatedTime, "最近更新时间为空").
  58. GetShopDecorations(tenantID, name, pageClientType, pageData, pageType, pageShow, "0", "0", &shopDecorationInfos, &totalCount).
  59. AssertEqual(int(totalCount), len(shopDecorationInfos), "总数不一致").
  60. AssertEqual(1, len(shopDecorationInfos), "店铺装修列表数应当为1").
  61. AssertEqual(tenantID, shopDecorationInfos[0].TenantID, "店铺装修列表租户ID不一致").
  62. AssertEqual(shopDecorationID, shopDecorationInfos[0].ID, "店铺装修列表ID不一致").
  63. AssertEqual(name, shopDecorationInfos[0].Name, "店铺装修列表页面名称不一致").
  64. AssertEqual(pageClientType, shopDecorationInfos[0].PageClientType, "店铺装修列表客户端类型不一致").
  65. AssertEqual(pageData, shopDecorationInfos[0].PageData, "店铺装修列表页面数据不一致").
  66. AssertEqual(pageType, shopDecorationInfos[0].PageType, "店铺装修列表页面类型不一致").
  67. AssertEqual(pageShow, shopDecorationInfos[0].PageShow, "店铺装修列表页面开关状态不一致").
  68. AssertEqual(createUserID, shopDecorationInfos[0].CreateUserID, "创建用户ID不一致").
  69. AssertEqual(createUserID, shopDecorationInfos[0].LastUpdateUserID, "最近更新用户ID不一致").
  70. AssertNotEmpty(shopDecorationInfos[0].CreatedTime, "创建时间为空").
  71. AssertNotEmpty(shopDecorationInfos[0].LastUpdatedTime, "最近更新时间为空").
  72. UpdateShopDecoration(shopDecorationID, newName, newPageClientType, newPageData, newPageType, newPageShow, updateUserID, operatorUserName).
  73. GetShopDecorations(tenantID, newName, newPageClientType, newPageData, newPageType, newPageShow, "1", "1", &shopDecorationInfos, &totalCount).
  74. AssertEqual(int(totalCount), len(shopDecorationInfos), "总数不一致").
  75. AssertEqual(tenantID, shopDecorationInfos[0].TenantID, "店铺装修列表租户ID不一致").
  76. AssertEqual(shopDecorationID, shopDecorationInfos[0].ID, "店铺装修列表ID不一致").
  77. AssertEqual(newName, shopDecorationInfos[0].Name, "店铺装修列表页面名称不一致").
  78. AssertEqual(newPageClientType, shopDecorationInfos[0].PageClientType, "店铺装修列表客户端类型不一致").
  79. AssertEqual(newPageData, shopDecorationInfos[0].PageData, "店铺装修列表页面数据不一致").
  80. AssertEqual(newPageType, shopDecorationInfos[0].PageType, "店铺装修列表页面类型不一致").
  81. AssertEqual(newPageShow, shopDecorationInfos[0].PageShow, "店铺装修列表页面开关状态不一致").
  82. AssertEqual(createUserID, shopDecorationInfos[0].CreateUserID, "创建用户ID不一致").
  83. AssertEqual(updateUserID, shopDecorationInfos[0].LastUpdateUserID, "最近更新用户ID不一致").
  84. AssertNotEmpty(shopDecorationInfos[0].CreatedTime, "创建时间为空").
  85. AssertNotEmpty(shopDecorationInfos[0].LastUpdatedTime, "最近更新时间为空").
  86. DeleteShopDecoration(shopDecorationID, deleteUserID, operatorUserName).
  87. GetShopDecorations(tenantID, newName, newPageClientType, newPageData, newPageType, newPageShow, "1", "1", &shopDecorationInfos, &totalCount).
  88. AssertEqual(int(totalCount), len(shopDecorationInfos), "总数不一致").
  89. AssertEqual(0, len(shopDecorationInfos), "删除店铺装修列表失败")
  90. }
  91. /* HAC: TEST RELATION FUNCTIONS */
  92. /* HAC: END TEST RELATION FUNCTIONS */
  93. func (toolKit *ToolKit) CreateShopDecoration(tenantID string, name string, pageClientType string, pageData string, pageType string, pageShow string, createUserID string, operatorUserName string, shopDecorationID *string) *ToolKit {
  94. idResponse := new(response.IDResponse)
  95. toolKit.SetHeader("Content-Type", "application/json").
  96. SetJsonBody(&shop_decoration.CreateShopDecorationJsonBody{
  97. Name: name, PageClientType: pageClientType, PageData: pageData, PageType: pageType, PageShow: pageShow,
  98. TenantIDJsonBody: request.TenantIDJsonBody{TenantID: tenantID},
  99. CreateUserIDJsonBody: request.CreateUserIDJsonBody{CreateUserID: createUserID},
  100. OperatorUserNameJsonBody: request.OperatorUserNameJsonBody{OperatorUserName: operatorUserName},
  101. }).
  102. SetJsonResponse(idResponse).
  103. Request("/ecos/api/v1/shopDecoration/create", http.MethodPost).
  104. AssertStatusCode(http.StatusOK).
  105. AssertEqual(true, idResponse.Success, idResponse.Msg).
  106. AssertNotEmpty(idResponse.ID, "店铺装修列表ID为空")
  107. if shopDecorationID != nil {
  108. *shopDecorationID = idResponse.ID
  109. }
  110. return toolKit
  111. }
  112. func (toolKit *ToolKit) DeleteShopDecoration(id string, deleteUserID string, operatorUserName string) *ToolKit {
  113. msgResponse := new(response.MsgResponse)
  114. toolKit.SetHeader("Content-Type", "application/json").
  115. SetJsonResponse(msgResponse).
  116. SetQueryParams("id", id).
  117. SetQueryParams("deleteUserId", deleteUserID).
  118. SetQueryParams("operatorUserName", operatorUserName).
  119. Request("/ecos/api/v1/shopDecoration/delete", http.MethodDelete).
  120. AssertStatusCode(http.StatusOK).
  121. AssertEqual(true, msgResponse.Success, msgResponse.Msg)
  122. return toolKit
  123. }
  124. func (toolKit *ToolKit) UpdateShopDecoration(id string, name string, pageClientType string, pageData string, pageType string, pageShow string, updateUserID string, operatorUserName string) *ToolKit {
  125. msgResponse := new(response.MsgResponse)
  126. toolKit.SetHeader("Content-Type", "application/json").
  127. SetJsonBody(&shop_decoration.UpdateShopDecorationJsonBody{
  128. IDJsonBody: request.IDJsonBody{ID: id},
  129. Name: name,
  130. PageClientType: pageClientType,
  131. PageData: pageData,
  132. PageType: pageType,
  133. PageShow: pageShow,
  134. UpdateUserIDJsonBody: request.UpdateUserIDJsonBody{UpdateUserID: updateUserID},
  135. OperatorUserNameJsonBody: request.OperatorUserNameJsonBody{OperatorUserName: operatorUserName},
  136. }).
  137. SetJsonResponse(msgResponse).
  138. Request("/ecos/api/v1/shopDecoration/update", http.MethodPut).
  139. AssertStatusCode(http.StatusOK).
  140. AssertEqual(true, msgResponse.Success, msgResponse.Msg)
  141. return toolKit
  142. }
  143. func (toolKit *ToolKit) GetShopDecorations(tenantID string, name string, pageClientType string, pageData string, pageType string, pageShow string, pageNo string, pageSize string, retInfos *[]shop_decoration.Info, retTotalCount *int64) *ToolKit {
  144. infosResponse := new(response.InfosResponse[shop_decoration.Info])
  145. toolKit.SetHeader("Content-Type", "application/json").
  146. SetJsonResponse(infosResponse).
  147. SetQueryParams("tenantId", tenantID).
  148. SetQueryParams("name", name).
  149. SetQueryParams("pageClientType", pageClientType).
  150. SetQueryParams("pageData", pageData).
  151. SetQueryParams("pageType", pageType).
  152. SetQueryParams("pageShow", pageShow).
  153. SetQueryParams("pageNo", pageNo).
  154. SetQueryParams("pageSize", pageSize).
  155. Request("/ecos/api/v1/shopDecoration/query", http.MethodGet).
  156. AssertStatusCode(http.StatusOK).
  157. AssertEqual(true, infosResponse.Success, infosResponse.Msg)
  158. if retInfos != nil {
  159. *retInfos = make([]shop_decoration.Info, 0)
  160. *retInfos = append(*retInfos, infosResponse.Infos...)
  161. }
  162. if retTotalCount != nil {
  163. *retTotalCount = infosResponse.TotalCount
  164. }
  165. return toolKit
  166. }
  167. func (toolKit *ToolKit) GetShopDecoration(tenantID string, id string, retInfo *shop_decoration.Info) *ToolKit {
  168. infoResponse := new(response.InfoResponse[*shop_decoration.Info])
  169. toolKit.SetHeader("Content-Type", "application/json").
  170. SetJsonResponse(infoResponse).
  171. SetQueryParams("tenantId", tenantID).
  172. SetQueryParams("id", id).
  173. Request("/ecos/api/v1/shopDecoration/get", http.MethodGet).
  174. AssertStatusCode(http.StatusOK).
  175. AssertEqual(true, infoResponse.Success, infoResponse.Msg)
  176. if retInfo != nil {
  177. *retInfo = shop_decoration.Info{}
  178. *retInfo = *infoResponse.Info
  179. }
  180. return toolKit
  181. }
  182. /* HAC: TEST RELATION METHODS */
  183. /* HAC: END TEST RELATION METHODS */