123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- package test
- import (
- "erpims/application/domain/common_use_website"
- "git.sxidc.com/go-framework/baize/framework/core/api/request"
- "git.sxidc.com/go-framework/baize/framework/core/api/response"
- "git.sxidc.com/go-tools/utils/strutils"
- "math/rand"
- "net/http"
- "strconv"
- "testing"
- )
- func TestCommonUseWebsite(t *testing.T) {
- Init()
- defer Destroy()
- var commonUseWebsiteID string
- var totalCount int64
- commonUseWebsiteInfo := new(common_use_website.Info)
- commonUseWebsiteInfos := make([]common_use_website.Info, 0)
- createUserID := strutils.SimpleUUID()
- updateUserID := strutils.SimpleUUID()
- deleteUserID := strutils.SimpleUUID()
- operatorUserName := strutils.SimpleUUID()
- title := strutils.SimpleUUID()
- iconUrl := strutils.SimpleUUID()
- accessUrl := strutils.SimpleUUID()
- sort := int(rand.Int())
- newTitle := strutils.SimpleUUID()
- newIconUrl := strutils.SimpleUUID()
- newAccessUrl := strutils.SimpleUUID()
- newSort := int(rand.Int())
- NewToolKit(t).CreateCommonUseWebsite(title, iconUrl, accessUrl, sort, createUserID, operatorUserName, &commonUseWebsiteID).
- GetCommonUseWebsite(commonUseWebsiteID, commonUseWebsiteInfo).
- AssertEqual(commonUseWebsiteID, commonUseWebsiteInfo.ID, "常用网站ID不一致").
- AssertEqual(title, commonUseWebsiteInfo.Title, "常用网站标题不一致").
- AssertEqual(iconUrl, commonUseWebsiteInfo.IconUrl, "常用网站图标路径不一致").
- AssertEqual(accessUrl, commonUseWebsiteInfo.AccessUrl, "常用网站访问路径不一致").
- AssertEqual(sort, commonUseWebsiteInfo.Sort, "常用网站排序不一致").
- AssertEqual(createUserID, commonUseWebsiteInfo.CreateUserID, "创建用户ID不一致").
- AssertEqual(createUserID, commonUseWebsiteInfo.LastUpdateUserID, "最近更新用户ID不一致").
- AssertNotEmpty(commonUseWebsiteInfo.CreatedTime, "创建时间为空").
- AssertNotEmpty(commonUseWebsiteInfo.LastUpdatedTime, "最近更新时间为空").
- GetCommonUseWebsites(title, iconUrl, accessUrl, sort, "1", "1", &commonUseWebsiteInfos, &totalCount).
- AssertEqual(int(totalCount), len(commonUseWebsiteInfos), "总数不一致").
- AssertEqual(commonUseWebsiteID, commonUseWebsiteInfos[0].ID, "常用网站ID不一致").
- AssertEqual(title, commonUseWebsiteInfos[0].Title, "常用网站标题不一致").
- AssertEqual(iconUrl, commonUseWebsiteInfos[0].IconUrl, "常用网站图标路径不一致").
- AssertEqual(accessUrl, commonUseWebsiteInfos[0].AccessUrl, "常用网站访问路径不一致").
- AssertEqual(sort, commonUseWebsiteInfos[0].Sort, "常用网站排序不一致").
- AssertEqual(createUserID, commonUseWebsiteInfos[0].CreateUserID, "创建用户ID不一致").
- AssertEqual(createUserID, commonUseWebsiteInfos[0].LastUpdateUserID, "最近更新用户ID不一致").
- AssertNotEmpty(commonUseWebsiteInfos[0].CreatedTime, "创建时间为空").
- AssertNotEmpty(commonUseWebsiteInfos[0].LastUpdatedTime, "最近更新时间为空").
- GetCommonUseWebsites(title, iconUrl, accessUrl, sort, "0", "0", &commonUseWebsiteInfos, &totalCount).
- AssertEqual(int(totalCount), len(commonUseWebsiteInfos), "总数不一致").
- AssertEqual(1, len(commonUseWebsiteInfos), "常用网站数应当为1").
- AssertEqual(commonUseWebsiteID, commonUseWebsiteInfos[0].ID, "常用网站ID不一致").
- AssertEqual(title, commonUseWebsiteInfos[0].Title, "常用网站标题不一致").
- AssertEqual(iconUrl, commonUseWebsiteInfos[0].IconUrl, "常用网站图标路径不一致").
- AssertEqual(accessUrl, commonUseWebsiteInfos[0].AccessUrl, "常用网站访问路径不一致").
- AssertEqual(sort, commonUseWebsiteInfos[0].Sort, "常用网站排序不一致").
- AssertEqual(createUserID, commonUseWebsiteInfos[0].CreateUserID, "创建用户ID不一致").
- AssertEqual(createUserID, commonUseWebsiteInfos[0].LastUpdateUserID, "最近更新用户ID不一致").
- AssertNotEmpty(commonUseWebsiteInfos[0].CreatedTime, "创建时间为空").
- AssertNotEmpty(commonUseWebsiteInfos[0].LastUpdatedTime, "最近更新时间为空").
- UpdateCommonUseWebsite(commonUseWebsiteID, newTitle, newIconUrl, newAccessUrl, newSort, updateUserID, operatorUserName).
- GetCommonUseWebsites(newTitle, newIconUrl, newAccessUrl, newSort, "1", "1", &commonUseWebsiteInfos, &totalCount).
- AssertEqual(int(totalCount), len(commonUseWebsiteInfos), "总数不一致").
- AssertEqual(commonUseWebsiteID, commonUseWebsiteInfos[0].ID, "常用网站ID不一致").
- AssertEqual(newTitle, commonUseWebsiteInfos[0].Title, "常用网站标题不一致").
- AssertEqual(newIconUrl, commonUseWebsiteInfos[0].IconUrl, "常用网站图标路径不一致").
- AssertEqual(newAccessUrl, commonUseWebsiteInfos[0].AccessUrl, "常用网站访问路径不一致").
- AssertEqual(newSort, commonUseWebsiteInfos[0].Sort, "常用网站排序不一致").
- AssertEqual(createUserID, commonUseWebsiteInfos[0].CreateUserID, "创建用户ID不一致").
- AssertEqual(updateUserID, commonUseWebsiteInfos[0].LastUpdateUserID, "最近更新用户ID不一致").
- AssertNotEmpty(commonUseWebsiteInfos[0].CreatedTime, "创建时间为空").
- AssertNotEmpty(commonUseWebsiteInfos[0].LastUpdatedTime, "最近更新时间为空").
- DeleteCommonUseWebsite(commonUseWebsiteID, deleteUserID, operatorUserName).
- GetCommonUseWebsites(newTitle, newIconUrl, newAccessUrl, newSort, "1", "1", &commonUseWebsiteInfos, &totalCount).
- AssertEqual(int(totalCount), len(commonUseWebsiteInfos), "总数不一致").
- AssertEqual(0, len(commonUseWebsiteInfos), "删除常用网站失败")
- }
- /* HAC: TEST RELATION FUNCTIONS */
- /* HAC: END TEST RELATION FUNCTIONS */
- func (toolKit *ToolKit) CreateCommonUseWebsite(title string, iconUrl string, accessUrl string, sort int, createUserID string, operatorUserName string, commonUseWebsiteID *string) *ToolKit {
- idResponse := new(response.IDResponse)
- toolKit.SetHeader("Content-Type", "application/json").
- SetJsonBody(&common_use_website.CreateCommonUseWebsiteJsonBody{
- Title: title, IconUrl: iconUrl, AccessUrl: accessUrl, Sort: sort,
- CreateUserIDJsonBody: request.CreateUserIDJsonBody{CreateUserID: createUserID},
- OperatorUserNameJsonBody: request.OperatorUserNameJsonBody{OperatorUserName: operatorUserName},
- }).
- SetJsonResponse(idResponse).
- Request("/erpims/api/v1/commonUseWebsite/create", http.MethodPost).
- AssertStatusCode(http.StatusOK).
- AssertEqual(true, idResponse.Success, idResponse.Msg).
- AssertNotEmpty(idResponse.ID, "常用网站ID为空")
- if commonUseWebsiteID != nil {
- *commonUseWebsiteID = idResponse.ID
- }
- return toolKit
- }
- func (toolKit *ToolKit) DeleteCommonUseWebsite(id string, deleteUserID string, operatorUserName string) *ToolKit {
- msgResponse := new(response.MsgResponse)
- toolKit.SetHeader("Content-Type", "application/json").
- SetJsonResponse(msgResponse).
- SetQueryParams("id", id).
- SetQueryParams("deleteUserId", deleteUserID).
- SetQueryParams("operatorUserName", operatorUserName).
- Request("/erpims/api/v1/commonUseWebsite/delete", http.MethodDelete).
- AssertStatusCode(http.StatusOK).
- AssertEqual(true, msgResponse.Success, msgResponse.Msg)
- return toolKit
- }
- func (toolKit *ToolKit) UpdateCommonUseWebsite(id string, title string, iconUrl string, accessUrl string, sort int, updateUserID string, operatorUserName string) *ToolKit {
- msgResponse := new(response.MsgResponse)
- toolKit.SetHeader("Content-Type", "application/json").
- SetJsonBody(&common_use_website.UpdateCommonUseWebsiteJsonBody{
- IDJsonBody: request.IDJsonBody{ID: id},
- Title: title,
- IconUrl: iconUrl,
- AccessUrl: accessUrl,
- Sort: sort,
- UpdateUserIDJsonBody: request.UpdateUserIDJsonBody{UpdateUserID: updateUserID},
- OperatorUserNameJsonBody: request.OperatorUserNameJsonBody{OperatorUserName: operatorUserName},
- }).
- SetJsonResponse(msgResponse).
- Request("/erpims/api/v1/commonUseWebsite/update", http.MethodPut).
- AssertStatusCode(http.StatusOK).
- AssertEqual(true, msgResponse.Success, msgResponse.Msg)
- return toolKit
- }
- func (toolKit *ToolKit) GetCommonUseWebsites(title string, iconUrl string, accessUrl string, sort int, pageNo string, pageSize string, retInfos *[]common_use_website.Info, retTotalCount *int64) *ToolKit {
- infosResponse := new(response.InfosResponse[common_use_website.Info])
- toolKit.SetHeader("Content-Type", "application/json").
- SetJsonResponse(infosResponse).
- SetQueryParams("title", title).
- SetQueryParams("iconUrl", iconUrl).
- SetQueryParams("accessUrl", accessUrl).
- SetQueryParams("sort", strconv.FormatInt(int64(sort), 10)).
- SetQueryParams("pageNo", pageNo).
- SetQueryParams("pageSize", pageSize).
- Request("/erpims/api/v1/commonUseWebsite/query", http.MethodGet).
- AssertStatusCode(http.StatusOK).
- AssertEqual(true, infosResponse.Success, infosResponse.Msg)
- if retInfos != nil {
- *retInfos = make([]common_use_website.Info, 0)
- *retInfos = append(*retInfos, infosResponse.Infos...)
- }
- if retTotalCount != nil {
- *retTotalCount = infosResponse.TotalCount
- }
- return toolKit
- }
- func (toolKit *ToolKit) GetCommonUseWebsite(id string, retInfo *common_use_website.Info) *ToolKit {
- infoResponse := new(response.InfoResponse[*common_use_website.Info])
- toolKit.SetHeader("Content-Type", "application/json").
- SetJsonResponse(infoResponse).
- SetQueryParams("id", id).
- Request("/erpims/api/v1/commonUseWebsite/get", http.MethodGet).
- AssertStatusCode(http.StatusOK).
- AssertEqual(true, infoResponse.Success, infoResponse.Msg)
- if retInfo != nil {
- *retInfo = common_use_website.Info{}
- *retInfo = *infoResponse.Info
- }
- return toolKit
- }
- /* HAC: TEST RELATION METHODS */
- /* HAC: END TEST RELATION METHODS */
|