我的朋友們,誤差校驗(無驗證可以爲類型中找到:java.util.Date)
我有類...
@NotBlank(message = "timesheet.cadastro.horainicio.obrigatorio")
@Temporal(TemporalType.TIME)
@Column(name = "INICIO", nullable = false)
private Date horaInicio;
而且,在我的測試(常規)我把空到 「horaInicio」:
def "Salvar um timesheet sem hora inicio"() {
given:"um timesheet sem data"
def usuario = sessionFactory.getCurrentSession().get(Usuario.class,1L) as Usuario
def dias = sessionFactory.getCurrentSession().get(Dias.class,1L) as Dias
def timeSheet = criarTimeSheet(usuario,dias) as TimeSheet
timeSheet.horaInicio = null
when:"buscar na base"
def timeSheetPersistido = timeSheetService.salvar(timeSheet)
then:"retorna uma lista de timesheet"
def erro = thrown(ConstraintViolationException)
"timesheet.cadastro.horainicio.obrigatorio".equals(erro.getConstraintViolations().asList().get(0).getMessage())
}
但我有錯誤:
Expected exception javax.validation.ConstraintViolationException, but got javax.validation.UnexpectedTypeException
at org.spockframework.lang.SpecInternals.thrownImpl(SpecInternals.java:79)
at br.com.infowhere.service.TimeSheetServiceIt.Salvar um timesheet sem hora inicio(TimeSheetServiceIt.groovy:80)
Caused by: javax.validation.UnexpectedTypeException: HV000030: No validator could be found for type: java.util.Date.
有人可以幫助我嗎?
感謝
我把@NotNull但不:-(@NotNull(消息= 「timesheet.cadastro.horainicio.obrigatorio」) @Temporal(TemporalType.TIME) @Column(name = 「INICIO」 工作,可爲空=假) 私人日期horaInicio; – user812612
嗨,我的朋友,我很抱歉,現在工作!我有另一個屬性,我沒有改變;-)謝謝! – user812612