Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
customer-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SuperHive
back-end
customer-service
Commits
dbcbaa07
Commit
dbcbaa07
authored
Apr 27, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
承运商接口:审核车辆
parent
487cd38d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
283 additions
and
7 deletions
+283
-7
ErrorMessageComponent.java
...ight/customer/common/component/ErrorMessageComponent.java
+5
-0
CommonConstants.java
...sv/freight/customer/common/constants/CommonConstants.java
+23
-0
VehicleController.java
...customer/module/vehicle/controller/VehicleController.java
+19
-0
VehicleAuditForm.java
...reight/customer/module/vehicle/form/VehicleAuditForm.java
+46
-0
VehicleService.java
...eight/customer/module/vehicle/service/VehicleService.java
+10
-0
VehicleServiceImpl.java
...tomer/module/vehicle/service/impl/VehicleServiceImpl.java
+51
-5
application-dev.yml
src/main/resources/application-dev.yml
+4
-1
VehicleControllerTest.java
...omer/module/vehicle/controller/VehicleControllerTest.java
+125
-1
No files found.
src/main/java/com/esv/freight/customer/common/component/ErrorMessageComponent.java
View file @
dbcbaa07
...
@@ -149,4 +149,9 @@ public class ErrorMessageComponent {
...
@@ -149,4 +149,9 @@ public class ErrorMessageComponent {
@Value
(
"${error-message.carrier.vehicle.detail.1001}"
)
@Value
(
"${error-message.carrier.vehicle.detail.1001}"
)
private
String
carrierVehicleDetail1001
;
private
String
carrierVehicleDetail1001
;
@Value
(
"${error-message.carrier.vehicle.audit.1001}"
)
private
String
carrierVehicleAudit1001
;
@Value
(
"${error-message.carrier.vehicle.audit.1002}"
)
private
String
carrierVehicleAudit1002
;
}
}
src/main/java/com/esv/freight/customer/common/constants/CommonConstants.java
0 → 100644
View file @
dbcbaa07
package
com
.
esv
.
freight
.
customer
.
common
.
constants
;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.common.constants.CommonConstants
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/27 16:03
* @version:1.0
*/
public
class
CommonConstants
{
/**
* 访问端来源:1-浏览器端、2-Android端、3-iOS端、4-后台服务端
**/
public
static
final
String
REQ_SOURCE_TYPE_KEY
=
"Source-Type"
;
public
static
final
String
REQ_SOURCE_TYPE_WEB
=
"1"
;
public
static
final
String
REQ_SOURCE_TYPE_ANDROID
=
"2"
;
public
static
final
String
REQ_SOURCE_TYPE_IOS
=
"3"
;
public
static
final
String
REQ_SOURCE_TYPE_SERVICE
=
"4"
;
}
src/main/java/com/esv/freight/customer/module/vehicle/controller/VehicleController.java
View file @
dbcbaa07
...
@@ -9,7 +9,9 @@ import com.esv.freight.customer.common.validator.groups.ValidatorDetail;
...
@@ -9,7 +9,9 @@ import com.esv.freight.customer.common.validator.groups.ValidatorDetail;
import
com.esv.freight.customer.common.validator.groups.ValidatorInsert
;
import
com.esv.freight.customer.common.validator.groups.ValidatorInsert
;
import
com.esv.freight.customer.common.validator.groups.ValidatorUpdate
;
import
com.esv.freight.customer.common.validator.groups.ValidatorUpdate
;
import
com.esv.freight.customer.module.carrier.service.CarrierInfoService
;
import
com.esv.freight.customer.module.carrier.service.CarrierInfoService
;
import
com.esv.freight.customer.module.vehicle.VehicleConstants
;
import
com.esv.freight.customer.module.vehicle.dto.VehicleDetailDto
;
import
com.esv.freight.customer.module.vehicle.dto.VehicleDetailDto
;
import
com.esv.freight.customer.module.vehicle.form.VehicleAuditForm
;
import
com.esv.freight.customer.module.vehicle.form.VehicleInfoForm
;
import
com.esv.freight.customer.module.vehicle.form.VehicleInfoForm
;
import
com.esv.freight.customer.module.vehicle.form.VehicleQueryForm
;
import
com.esv.freight.customer.module.vehicle.form.VehicleQueryForm
;
import
com.esv.freight.customer.module.vehicle.service.VehicleService
;
import
com.esv.freight.customer.module.vehicle.service.VehicleService
;
...
@@ -114,4 +116,21 @@ public class VehicleController {
...
@@ -114,4 +116,21 @@ public class VehicleController {
return
EResponse
.
ok
(
vo
);
return
EResponse
.
ok
(
vo
);
}
}
/**
* description 审核车辆
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/27 15:48
**/
@PostMapping
(
"/audit"
)
public
EResponse
audit
(
@RequestBody
VehicleAuditForm
form
)
throws
EException
{
if
(
VehicleConstants
.
VEHICLE_AUDIT_STATUS_FAILURE
.
equals
(
form
.
getAuditState
())
&&
StringUtils
.
isBlank
(
form
.
getRemark
()))
{
throw
new
EException
(
ECode
.
PARAM_ERROR
.
code
(),
"审核不通过时remark不能为空"
);
}
vehicleService
.
auditVehicle
(
form
);
return
EResponse
.
ok
();
}
}
}
src/main/java/com/esv/freight/customer/module/vehicle/form/VehicleAuditForm.java
0 → 100644
View file @
dbcbaa07
package
com
.
esv
.
freight
.
customer
.
module
.
vehicle
.
form
;
import
lombok.Data
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
org.hibernate.validator.constraints.Length
;
import
org.hibernate.validator.constraints.Range
;
import
javax.validation.constraints.NotNull
;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.vehicle.form.VehicleAuditForm
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/26 14:35
* @version:1.0
*/
@Data
public
class
VehicleAuditForm
{
/**
*
*/
@NotNull
(
message
=
"参数id不能为空"
)
private
Long
id
;
/**
* 审核状态(字典表):1-审核成功,2-审核失败
*/
@Range
(
min
=
1
,
max
=
2
,
message
=
"参数auditState不合法"
)
@NotNull
(
message
=
"参数auditState不能为空"
)
private
Integer
auditState
;
/**
* 备注,审核不通过时必填
*/
@Length
(
max
=
100
,
message
=
"参数remark长度不合法"
)
private
String
remark
;
@Override
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
}
}
src/main/java/com/esv/freight/customer/module/vehicle/service/VehicleService.java
View file @
dbcbaa07
...
@@ -3,6 +3,7 @@ package com.esv.freight.customer.module.vehicle.service;
...
@@ -3,6 +3,7 @@ package com.esv.freight.customer.module.vehicle.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.esv.freight.customer.module.vehicle.dto.VehicleDetailDto
;
import
com.esv.freight.customer.module.vehicle.dto.VehicleDetailDto
;
import
com.esv.freight.customer.module.vehicle.entity.VehicleEntity
;
import
com.esv.freight.customer.module.vehicle.entity.VehicleEntity
;
import
com.esv.freight.customer.module.vehicle.form.VehicleAuditForm
;
import
com.esv.freight.customer.module.vehicle.form.VehicleInfoForm
;
import
com.esv.freight.customer.module.vehicle.form.VehicleInfoForm
;
/**
/**
...
@@ -41,5 +42,14 @@ public interface VehicleService extends IService<VehicleEntity> {
...
@@ -41,5 +42,14 @@ public interface VehicleService extends IService<VehicleEntity> {
**/
**/
VehicleDetailDto
getVehicleDetail
(
Long
id
);
VehicleDetailDto
getVehicleDetail
(
Long
id
);
/**
* description 审核车辆
* param [form]
* return void
* author Administrator
* createTime 2020/04/27 15:38
**/
void
auditVehicle
(
VehicleAuditForm
form
);
}
}
src/main/java/com/esv/freight/customer/module/vehicle/service/impl/VehicleServiceImpl.java
View file @
dbcbaa07
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.esv.freight.customer.common.component.ErrorMessageComponent
;
import
com.esv.freight.customer.common.component.ErrorMessageComponent
;
import
com.esv.freight.customer.common.constants.CommonConstants
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.response.ECode
;
import
com.esv.freight.customer.common.response.ECode
;
import
com.esv.freight.customer.common.util.ReqUtils
;
import
com.esv.freight.customer.common.util.ReqUtils
;
...
@@ -15,6 +16,7 @@ import com.esv.freight.customer.module.vehicle.dto.VehicleDetailDto;
...
@@ -15,6 +16,7 @@ import com.esv.freight.customer.module.vehicle.dto.VehicleDetailDto;
import
com.esv.freight.customer.module.vehicle.entity.AttachmentEntity
;
import
com.esv.freight.customer.module.vehicle.entity.AttachmentEntity
;
import
com.esv.freight.customer.module.vehicle.entity.VehicleAuditHistoryEntity
;
import
com.esv.freight.customer.module.vehicle.entity.VehicleAuditHistoryEntity
;
import
com.esv.freight.customer.module.vehicle.entity.VehicleEntity
;
import
com.esv.freight.customer.module.vehicle.entity.VehicleEntity
;
import
com.esv.freight.customer.module.vehicle.form.VehicleAuditForm
;
import
com.esv.freight.customer.module.vehicle.form.VehicleInfoForm
;
import
com.esv.freight.customer.module.vehicle.form.VehicleInfoForm
;
import
com.esv.freight.customer.module.vehicle.service.AttachmentService
;
import
com.esv.freight.customer.module.vehicle.service.AttachmentService
;
import
com.esv.freight.customer.module.vehicle.service.VehicleAuditHistoryService
;
import
com.esv.freight.customer.module.vehicle.service.VehicleAuditHistoryService
;
...
@@ -78,9 +80,19 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleDao, VehicleEntity> i
...
@@ -78,9 +80,19 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleDao, VehicleEntity> i
VehicleEntity
vehicleEntity
=
new
VehicleEntity
();
VehicleEntity
vehicleEntity
=
new
VehicleEntity
();
BeanUtils
.
copyProperties
(
form
,
vehicleEntity
);
BeanUtils
.
copyProperties
(
form
,
vehicleEntity
);
vehicleEntity
.
setId
(
null
);
vehicleEntity
.
setId
(
null
);
vehicleEntity
.
setVehicleStatus
(
VehicleConstants
.
VEHICLE_ACCOUNT_STATUS_UNBLOCK
);
// 判断创建来源
vehicleEntity
.
setAuditStatus
(
VehicleConstants
.
VEHICLE_AUDIT_STATUS_SUCCESS
);
String
sourceType
=
ReqUtils
.
getRequestHeader
(
CommonConstants
.
REQ_SOURCE_TYPE_KEY
);
vehicleEntity
.
setSourceType
(
VehicleConstants
.
VEHICLE_SOURCE_TYPE_PLATFORM
);
if
(
CommonConstants
.
REQ_SOURCE_TYPE_ANDROID
.
equals
(
sourceType
)
||
CommonConstants
.
REQ_SOURCE_TYPE_IOS
.
equals
(
sourceType
)
)
{
// 用户通过终端APP添加车辆
vehicleEntity
.
setAuditStatus
(
VehicleConstants
.
VEHICLE_AUDIT_STATUS_UNAUDITED
);
vehicleEntity
.
setSourceType
(
VehicleConstants
.
VEHICLE_SOURCE_TYPE_REGISTER
);
vehicleEntity
.
setVehicleStatus
(
VehicleConstants
.
VEHICLE_ACCOUNT_STATUS_BLOCK
);
}
else
{
vehicleEntity
.
setAuditStatus
(
VehicleConstants
.
VEHICLE_AUDIT_STATUS_SUCCESS
);
vehicleEntity
.
setSourceType
(
VehicleConstants
.
VEHICLE_SOURCE_TYPE_PLATFORM
);
vehicleEntity
.
setVehicleStatus
(
VehicleConstants
.
VEHICLE_ACCOUNT_STATUS_UNBLOCK
);
}
this
.
baseMapper
.
insert
(
vehicleEntity
);
this
.
baseMapper
.
insert
(
vehicleEntity
);
Long
vehicleId
=
vehicleEntity
.
getId
();
Long
vehicleId
=
vehicleEntity
.
getId
();
...
@@ -95,8 +107,14 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleDao, VehicleEntity> i
...
@@ -95,8 +107,14 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleDao, VehicleEntity> i
VehicleAuditHistoryEntity
vehicleAuditHistoryEntity
=
new
VehicleAuditHistoryEntity
();
VehicleAuditHistoryEntity
vehicleAuditHistoryEntity
=
new
VehicleAuditHistoryEntity
();
vehicleAuditHistoryEntity
.
setCarrierId
(
form
.
getCarrierId
());
vehicleAuditHistoryEntity
.
setCarrierId
(
form
.
getCarrierId
());
vehicleAuditHistoryEntity
.
setVehicleId
(
vehicleId
);
vehicleAuditHistoryEntity
.
setVehicleId
(
vehicleId
);
vehicleAuditHistoryEntity
.
setAuditStatus
(
VehicleConstants
.
VEHICLE_AUDIT_STATUS_SUCCESS
);
if
(
CommonConstants
.
REQ_SOURCE_TYPE_ANDROID
.
equals
(
sourceType
)
vehicleAuditHistoryEntity
.
setRemark
(
"平台创建自动审核"
);
||
CommonConstants
.
REQ_SOURCE_TYPE_IOS
.
equals
(
sourceType
)
)
{
vehicleAuditHistoryEntity
.
setAuditStatus
(
VehicleConstants
.
VEHICLE_AUDIT_STATUS_UNAUDITED
);
vehicleAuditHistoryEntity
.
setRemark
(
"用户通过终端APP添加车辆"
);
}
else
{
vehicleAuditHistoryEntity
.
setAuditStatus
(
VehicleConstants
.
VEHICLE_AUDIT_STATUS_SUCCESS
);
vehicleAuditHistoryEntity
.
setRemark
(
"平台创建自动审核"
);
}
vehicleAuditHistoryEntity
.
setOperateUser
(
ReqUtils
.
getRequestHeader
(
GatewayHeaders
.
USER_ACCOUNT
));
vehicleAuditHistoryEntity
.
setOperateUser
(
ReqUtils
.
getRequestHeader
(
GatewayHeaders
.
USER_ACCOUNT
));
this
.
vehicleAuditHistoryService
.
getBaseMapper
().
insert
(
vehicleAuditHistoryEntity
);
this
.
vehicleAuditHistoryService
.
getBaseMapper
().
insert
(
vehicleAuditHistoryEntity
);
...
@@ -166,4 +184,32 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleDao, VehicleEntity> i
...
@@ -166,4 +184,32 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleDao, VehicleEntity> i
public
VehicleDetailDto
getVehicleDetail
(
Long
id
)
{
public
VehicleDetailDto
getVehicleDetail
(
Long
id
)
{
return
this
.
baseMapper
.
selectVehicleDetail
(
id
);
return
this
.
baseMapper
.
selectVehicleDetail
(
id
);
}
}
@Override
public
void
auditVehicle
(
VehicleAuditForm
form
)
{
// 1:校验
// 1.1校验车辆ID是否有效
VehicleEntity
vehicleEntity
=
this
.
baseMapper
.
selectById
(
form
.
getId
());
if
(
null
==
vehicleEntity
)
{
throw
new
EException
(
1001
,
errorMessageComponent
.
getCarrierVehicleAudit1001
());
}
// 1.2校验车辆是否审核通过
if
(
VehicleConstants
.
VEHICLE_AUDIT_STATUS_SUCCESS
.
equals
(
vehicleEntity
.
getAuditStatus
()))
{
throw
new
EException
(
1002
,
errorMessageComponent
.
getCarrierVehicleAudit1002
());
}
// 2:更新车辆审核状态
VehicleEntity
updateEntity
=
new
VehicleEntity
();
updateEntity
.
setId
(
form
.
getId
());
updateEntity
.
setAuditStatus
(
form
.
getAuditState
());
this
.
baseMapper
.
updateById
(
vehicleEntity
);
// 3:更新车辆审核记录
VehicleAuditHistoryEntity
vehicleAuditHistoryEntity
=
new
VehicleAuditHistoryEntity
();
vehicleAuditHistoryEntity
.
setCarrierId
(
vehicleEntity
.
getCarrierId
());
vehicleAuditHistoryEntity
.
setVehicleId
(
form
.
getId
());
vehicleAuditHistoryEntity
.
setAuditStatus
(
form
.
getAuditState
());
vehicleAuditHistoryEntity
.
setRemark
(
form
.
getRemark
());
this
.
vehicleAuditHistoryService
.
getBaseMapper
().
insert
(
vehicleAuditHistoryEntity
);
}
}
}
\ No newline at end of file
src/main/resources/application-dev.yml
View file @
dbcbaa07
...
@@ -132,4 +132,7 @@ error-message:
...
@@ -132,4 +132,7 @@ error-message:
1003
:
行驶证档案编号已存在
1003
:
行驶证档案编号已存在
1004
:
道路运输证号已存在
1004
:
道路运输证号已存在
detail
:
detail
:
1001
:
无效的车辆ID
1001
:
无效的车辆ID
\ No newline at end of file
audit
:
1001
:
无效的车辆ID
1002
:
车辆已审核通过
\ No newline at end of file
src/test/java/com/esv/freight/customer/module/vehicle/controller/VehicleControllerTest.java
View file @
dbcbaa07
...
@@ -3,7 +3,8 @@ package com.esv.freight.customer.module.vehicle.controller;
...
@@ -3,7 +3,8 @@ package com.esv.freight.customer.module.vehicle.controller;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.esv.freight.customer.BaseTestController
;
import
com.esv.freight.customer.BaseTestController
;
import
com.esv.freight.customer.common.response.ECode
;
import
com.esv.freight.customer.common.response.ECode
;
import
com.esv.freight.customer.module.vehicle.form.VehicleInfoForm
;
import
com.esv.freight.customer.module.vehicle.VehicleConstants
;
import
com.esv.freight.customer.module.vehicle.form.VehicleAuditForm
;
import
com.esv.freight.customer.module.vehicle.form.VehicleQueryForm
;
import
com.esv.freight.customer.module.vehicle.form.VehicleQueryForm
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Assert
;
import
org.junit.Assert
;
...
@@ -94,4 +95,127 @@ public class VehicleControllerTest extends BaseTestController {
...
@@ -94,4 +95,127 @@ public class VehicleControllerTest extends BaseTestController {
JSONObject
result
=
JSONObject
.
parseObject
(
responseStr
);
JSONObject
result
=
JSONObject
.
parseObject
(
responseStr
);
Assert
.
assertEquals
(
1001
,
result
.
getIntValue
(
"code"
));
Assert
.
assertEquals
(
1001
,
result
.
getIntValue
(
"code"
));
}
}
/**
* 审核车辆
**/
@Test
@Rollback
public
void
b1_audit_success_test
()
throws
Exception
{
String
url
=
"/carrier/vehicle/audit"
;
// 构造数据
VehicleAuditForm
form
=
new
VehicleAuditForm
();
form
.
setId
(
1L
);
form
.
setAuditState
(
VehicleConstants
.
VEHICLE_AUDIT_STATUS_FAILURE
);
form
.
setRemark
(
"审核不通过test"
);
JSONObject
reqJson
=
JSONObject
.
parseObject
(
form
.
toString
());
MvcResult
mvcResult
=
this
.
getMockMvc
().
perform
(
MockMvcRequestBuilders
.
post
(
url
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
.
headers
(
this
.
getDefaultHttpHeaders
())
.
content
(
reqJson
.
toJSONString
()))
.
andDo
(
MockMvcResultHandlers
.
print
())
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
())
.
andReturn
();
String
responseStr
=
mvcResult
.
getResponse
().
getContentAsString
();
log
.
info
(
responseStr
);
JSONObject
result
=
JSONObject
.
parseObject
(
responseStr
);
Assert
.
assertEquals
(
ECode
.
SUCCESS
.
code
(),
result
.
getIntValue
(
"code"
));
}
/**
* 审核车辆:无效的车辆ID
**/
@Test
@Rollback
public
void
b2_audit_wrong_id_failure_test
()
throws
Exception
{
String
url
=
"/carrier/vehicle/audit"
;
// 构造数据
VehicleAuditForm
form
=
new
VehicleAuditForm
();
form
.
setId
(
99999L
);
form
.
setAuditState
(
VehicleConstants
.
VEHICLE_AUDIT_STATUS_FAILURE
);
form
.
setRemark
(
"审核不通过test"
);
JSONObject
reqJson
=
JSONObject
.
parseObject
(
form
.
toString
());
MvcResult
mvcResult
=
this
.
getMockMvc
().
perform
(
MockMvcRequestBuilders
.
post
(
url
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
.
headers
(
this
.
getDefaultHttpHeaders
())
.
content
(
reqJson
.
toJSONString
()))
.
andDo
(
MockMvcResultHandlers
.
print
())
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
())
.
andReturn
();
String
responseStr
=
mvcResult
.
getResponse
().
getContentAsString
();
log
.
info
(
responseStr
);
JSONObject
result
=
JSONObject
.
parseObject
(
responseStr
);
Assert
.
assertEquals
(
1001
,
result
.
getIntValue
(
"code"
));
}
/**
* 审核车辆:车辆已审核通过
**/
@Test
@Rollback
public
void
b3_audit_has_audit_failure_test
()
throws
Exception
{
String
url
=
"/carrier/vehicle/audit"
;
// 构造数据
VehicleAuditForm
form
=
new
VehicleAuditForm
();
form
.
setId
(
1L
);
form
.
setAuditState
(
VehicleConstants
.
VEHICLE_AUDIT_STATUS_SUCCESS
);
form
.
setRemark
(
"审核通过test"
);
JSONObject
reqJson
=
JSONObject
.
parseObject
(
form
.
toString
());
MvcResult
mvcResult
=
this
.
getMockMvc
().
perform
(
MockMvcRequestBuilders
.
post
(
url
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
.
headers
(
this
.
getDefaultHttpHeaders
())
.
content
(
reqJson
.
toJSONString
()))
.
andDo
(
MockMvcResultHandlers
.
print
())
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
())
.
andReturn
();
String
responseStr
=
mvcResult
.
getResponse
().
getContentAsString
();
log
.
info
(
responseStr
);
JSONObject
result
=
JSONObject
.
parseObject
(
responseStr
);
Assert
.
assertEquals
(
1002
,
result
.
getIntValue
(
"code"
));
}
/**
* 审核车辆:审核未通过,备注为空
**/
@Test
@Rollback
public
void
b4_audit_remark_is_null_failure_test
()
throws
Exception
{
String
url
=
"/carrier/vehicle/audit"
;
// 构造数据
VehicleAuditForm
form
=
new
VehicleAuditForm
();
form
.
setId
(
1L
);
form
.
setAuditState
(
VehicleConstants
.
VEHICLE_AUDIT_STATUS_FAILURE
);
JSONObject
reqJson
=
JSONObject
.
parseObject
(
form
.
toString
());
MvcResult
mvcResult
=
this
.
getMockMvc
().
perform
(
MockMvcRequestBuilders
.
post
(
url
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
.
headers
(
this
.
getDefaultHttpHeaders
())
.
content
(
reqJson
.
toJSONString
()))
.
andDo
(
MockMvcResultHandlers
.
print
())
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
())
.
andReturn
();
String
responseStr
=
mvcResult
.
getResponse
().
getContentAsString
();
log
.
info
(
responseStr
);
JSONObject
result
=
JSONObject
.
parseObject
(
responseStr
);
Assert
.
assertEquals
(
ECode
.
PARAM_ERROR
.
code
(),
result
.
getIntValue
(
"code"
));
}
}
}
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