java date cdate fasttime_java - Spring RestTemplate和Spock Test修改日期? - 堆栈内存溢出

我使用Spock测试我的api,它是这样的:

def "更新冲刺部分字段"() {

given: '冲刺DTO对象'

def startDate = new Date()

def endDate = MybatisFunctionTestUtil.dataSubFunction(startDate, 10)

SprintUpdateDTO sprintUpdateDTO = new SprintUpdateDTO()

sprintUpdateDTO.projectId = projectId

sprintUpdateDTO.sprintId = 2

sprintUpdateDTO.objectVersionNumber = 1

sprintUpdateDTO.endDate = endDate

sprintUpdateDTO.sprintName = '测试冲刺1'

sprintUpdateDTO.startDate = startDate

when: '分页过滤查询issue列表提供给测试模块用'

HttpEntity requestEntity = new HttpEntity(sprintUpdateDTO, null)

def entity = restTemplate.exchange('/v1/projects/{project_id}/sprint', HttpMethod.PUT, requestEntity, SprintDetailDTO, projectId)

then: '返回值'

entity.statusCode.is2xxSuccessful()

and: '设置值'

SprintDetailDTO sprintDetailDTO = entity.getBody()

expect: '设置期望值'

sprintDetailDTO.sprintId == 2

sprintDetailDTO.sprintName == '测试冲刺1'

sprintDetailDTO.projectId == projectId

sprintDetailDTO.startDate == startDate

sprintDetailDTO.endDate == endDate

}

我得到的结果是startDate!= startDate。

Condition not satisfied:

sprintDetailDTO.startDate == startDate

| | | |

| | | Mon Aug 20 10:51:56 CST 2018 (java.util.Date)

| | false

| Mon Aug 20 10:51:56 CST 2018 (java.util.Date)

io.choerodon.agile.api.dto.SprintDetailDTO@23488718

预期:

cdate: 2018-08-20T10:51:56.393+0800

defaultCenturyStart: 0

fastTime: 1534733516393

gcal: sun.util.calendar.Gregorian@6697a476

jcal: null

serialVersionUID: 7523967970034938905

ttb: [14, 1, 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 10000, 10000, 10000, 10300, 10240, 10360, 10300, 10420, 10360, 10480, 10420]

wtb: [am, pm, monday, tuesday, wednesday, thursday, friday, saturday, sunday, january, february, march, april, may, june, july, august, september, october, november, december, gmt, ut, utc, est, edt, cst, cdt, mst, mdt, pst, pdt]

实际:

cdate: null

defaultCenturyStart: 0

fastTime: 1534733516000

gcal: sun.util.calendar.Gregorian@6697a476

jcal: null

serialVersionUID: 7523967970034938905

ttb: [14, 1, 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 10000, 10000, 10000, 10300, 10240, 10360, 10300, 10420, 10360, 10480, 10420]

wtb: [am, pm, monday, tuesday, wednesday, thursday, friday, saturday, sunday, january, february, march, april, may, june, july, august, september, october, november, december, gmt, ut, utc, est, edt, cst, cdt, mst, mdt, pst, pdt]

我发现当我使用'restTemplate.exchange'到控制器时,sprint的startDate和endDate是在控制器中修改的。我想知道会发生什么?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值