Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
test-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
马博
test-platform
Commits
8830a136
Commit
8830a136
authored
Nov 08, 2018
by
chenjianfang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hmx
parent
db0c8570
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
252 additions
and
0 deletions
+252
-0
商品管理操作_DuibaTest.java
...t/java/http/cases/SaasDeveloperTest/商品管理操作_DuibaTest.java
+104
-0
SpglczService.java
src/test/java/http/service/Saas/SpglczService.java
+148
-0
No files found.
src/test/java/http/cases/SaasDeveloperTest/商品管理操作_DuibaTest.java
0 → 100644
View file @
8830a136
package
http
.
cases
.
SaasDeveloperTest
;
import
base.Config
;
import
utils.PublicMethod
;
import
http.service.Saas.DeveloperVirtualService
;
import
http.service.Saas.SpglczService
;
import
base.DuibaLog
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.testng.AbstractTestNGSpringContextTests
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
/**
* Created by humengxin on 2018/11/02.
*/
@ContextConfiguration
(
classes
=
Config
.
class
)
public
class
商品管理操作
_DuibaTest
extends
AbstractTestNGSpringContextTests
{
@Autowired
SpglczService
czService
;
@Autowired
DeveloperVirtualService
developerVirtualService
;
private
static
DuibaLog
logger
=
DuibaLog
.
getLogger
();
@Test
(
description
=
"批量上架"
)
public
void
a_
批量上架
()
throws
Exception
{
String
data
=
PublicMethod
.
data
();
//先添加2个商品
developerVirtualService
.
doUpdateVirtual
(
"【自动化】加钱购自有虚拟商品"
+
data
,
"标识符100=10+1"
);
developerVirtualService
.
doUpdateVirtual
(
"【自动化】加钱购自有虚拟商品"
+
data
,
"标识符100=10+1"
);
//查询实物商品集合
Response
response
=
czService
.
appItems
();
// 获取到上架商品id
String
ids
=
response
.
jsonPath
().
getString
(
"data.list[0].id"
);
String
ids2
=
response
.
jsonPath
().
getString
(
"data.list[1].id"
);
czService
.
batchStandUpOrDown
(
ids
,
ids2
);
//刷新查询商品集合
Response
response2
=
czService
.
appItems
();
//查看商品列表确认是否上架成功
Assert
.
assertEquals
(
response2
.
jsonPath
().
getString
(
"data.list[0].statusText"
),
"上架"
,
"校验商品上架失败"
);
Assert
.
assertEquals
(
response2
.
jsonPath
().
getString
(
"data.list[1].statusText"
),
"上架"
,
"校验商品上架失败"
);
logger
.
info
(
"校验商品上架成功"
);
}
@Test
(
description
=
"批量复制"
)
public
void
b_
批量复制
()
throws
Exception
{
String
data
=
PublicMethod
.
data
();
//查询实物商品集合
Response
response
=
czService
.
appItems
();
// 获取到上架商品id
String
ids
=
response
.
jsonPath
().
getString
(
"data.list[0].id"
);
String
ids2
=
response
.
jsonPath
().
getString
(
"data.list[1].id"
);
//复制到另一个app
czService
.
batchCopy
(
ids
,
ids2
);
//查看另一个app下是否存在该商品
Response
response2
=
czService
.
appItems2
();
Assert
.
assertEquals
(
response2
.
jsonPath
().
getString
(
"data.list[0].itemType"
),
"直充"
,
"校验商品类型失败"
);
Assert
.
assertEquals
(
response2
.
jsonPath
().
getString
(
"data.list[0].belong"
),
"自有"
,
"校验商品belong失败"
);
Assert
.
assertEquals
(
response2
.
jsonPath
().
getString
(
"data.list[1].itemType"
),
"直充"
,
"校验商品类型失败"
);
Assert
.
assertEquals
(
response2
.
jsonPath
().
getString
(
"data.list[1].belong"
),
"自有"
,
"校验商品belong失败"
);
logger
.
info
(
"校验title,belong成功"
);
}
@Test
(
description
=
"批量删除"
)
public
void
c_
批量删除
()
throws
Exception
{
String
data
=
PublicMethod
.
data
();
//查询实物商品集合
Response
response
=
czService
.
appItems
();
// 获取到上架商品id
String
ids
=
response
.
jsonPath
().
getString
(
"data.list[0].id"
);
String
ids2
=
response
.
jsonPath
().
getString
(
"data.list[1].id"
);
czService
.
doBatchDel
(
ids
,
ids2
);
}
}
src/test/java/http/service/Saas/SpglczService.java
0 → 100644
View file @
8830a136
package
http
.
service
.
Saas
;
import
http.service.Authorization
;
import
base.DuibaLog
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.testng.Assert
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
io
.
restassured
.
RestAssured
.
given
;
/**
* Created by asus on 2018/11/2.
*/
@Service
public
class
SpglczService
{
@Value
(
"${hdserver.host}"
)
String
hdHost
;
@Autowired
Authorization
authorization
;
private
DuibaLog
logger
=
DuibaLog
.
getLogger
();
//查询商品管理列表数据
public
Response
appItems
()
throws
Exception
{
String
url
=
hdHost
+
"/devItem/appItems"
;
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"appId"
,
"19515"
);
map
.
put
(
"rowId"
,
"1"
);
map
.
put
(
"itemType"
,
""
);
map
.
put
(
"status"
,
""
);
map
.
put
(
"itemName"
,
""
);
map
.
put
(
"belong"
,
""
);
map
.
put
(
"priceType"
,
""
);
logger
.
info
(
"请求查询商品url:"
+
url
);
Response
response
=
given
().
contentType
(
"application/x-www-form-urlencoded;charset=UTF-8"
).
cookies
(
authorization
.
hdLoginSaas
()).
params
(
map
).
post
(
"http://"
+
url
);
response
.
prettyPrint
();
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"desc"
),
"成功"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"查询商品管理列表数据接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"查询商品管理列表数据接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
//查询要复制的app数据
public
Response
appItems2
()
throws
Exception
{
String
url
=
hdHost
+
"/devItem/appItems"
;
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"appId"
,
"20979"
);
map
.
put
(
"rowId"
,
"1"
);
map
.
put
(
"itemType"
,
""
);
map
.
put
(
"status"
,
""
);
map
.
put
(
"itemName"
,
""
);
map
.
put
(
"belong"
,
""
);
map
.
put
(
"priceType"
,
""
);
logger
.
info
(
"请求查询商品url:"
+
url
);
Response
response
=
given
().
contentType
(
"application/x-www-form-urlencoded;charset=UTF-8"
).
cookies
(
authorization
.
hdLoginSaas
()).
params
(
map
).
post
(
"http://"
+
url
);
response
.
prettyPrint
();
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"desc"
),
"成功"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"查询商品管理列表数据接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"查询商品管理列表数据接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
// 批量上架
public
Response
batchStandUpOrDown
(
String
ids
,
String
ids2
)
throws
Exception
{
String
url
=
hdHost
+
"/devItem/batchStandUpOrDown"
;
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"appId"
,
"19515"
);
map
.
put
(
"ids"
,
ids
+
","
+
ids2
);
logger
.
info
(
"请求批量上架商品url:"
+
url
);
Response
response
=
given
().
contentType
(
"application/x-www-form-urlencoded;charset=UTF-8"
).
cookies
(
authorization
.
hdLoginSaas
()).
params
(
map
).
post
(
"http://"
+
url
);
response
.
prettyPrint
();
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"desc"
),
"成功"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"批量上架接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"批量上架接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
//批量复制
public
Response
batchCopy
(
String
ids
,
String
ids2
)
throws
Exception
{
String
url
=
hdHost
+
"/devItem/batchCopy"
;
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"appId"
,
"19515"
);
map
.
put
(
"ids"
,
ids
+
","
+
ids2
);
map
.
put
(
"toAppIds"
,
"20979"
);
logger
.
info
(
"请求批量商品url:"
+
url
);
Response
response
=
given
().
contentType
(
"application/x-www-form-urlencoded;charset=UTF-8"
).
cookies
(
authorization
.
hdLoginSaas
()).
params
(
map
).
post
(
"http://"
+
url
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"批量复制 接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"批量复制 接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
//批量删除
public
Response
doBatchDel
(
String
ids
,
String
ids2
)
throws
Exception
{
String
url
=
hdHost
+
"/devItem/doBatchDel"
;
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"appId"
,
"19515"
);
map
.
put
(
"ids"
,
ids
+
","
+
ids2
);
logger
.
info
(
"请求批量商品url:"
+
url
);
Response
response
=
given
().
contentType
(
"application/x-www-form-urlencoded;charset=UTF-8"
).
cookies
(
authorization
.
hdLoginSaas
()).
params
(
map
).
post
(
"http://"
+
url
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"批量删除 接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"批量删除 接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment