use of org.sonar.server.es.BaseDoc in project sonarqube by SonarSource.
the class BaseDocTest method getNullableFieldAsDate.
@Test
public void getNullableFieldAsDate() {
BaseDoc doc = new BaseDoc(someType, new HashMap<>()) {
@Override
public String getId() {
return null;
}
};
Date now = new Date();
doc.setField("javaDate", now);
assertThat(doc.getNullableFieldAsDate("javaDate")).isEqualToIgnoringMillis(now);
doc.setField("stringDate", EsUtils.formatDateTime(now));
assertThat(doc.getNullableFieldAsDate("stringDate")).isEqualToIgnoringMillis(now);
doc.setField("noValue", null);
assertThat(doc.getNullableFieldAsDate("noValue")).isNull();
}