Merge branch 'master' into new_model_for_communities
This commit is contained in:
commit
4c6134bc83
|
@ -8,6 +8,7 @@ public interface JdbcInfoDao {
|
|||
claim_load_date,
|
||||
oaf_load_date,
|
||||
odf_load_date,
|
||||
db_load_date,
|
||||
inference_date,
|
||||
stats_update_date,
|
||||
crossref_update_date,
|
||||
|
|
|
@ -7,6 +7,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
|
@ -17,19 +18,18 @@ import org.junit.jupiter.api.BeforeEach;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
@SpringBootTest
|
||||
|
||||
@WebMvcTest(InfoController.class)
|
||||
public class InfoControllerTest {
|
||||
|
||||
public static final MediaType APPLICATION_JSON_UTF8 = new MediaType(
|
||||
MediaType.APPLICATION_JSON.getType(),
|
||||
MediaType.APPLICATION_JSON.getSubtype(),
|
||||
Charset.forName("utf8"));
|
||||
StandardCharsets.UTF_8);
|
||||
|
||||
@Autowired
|
||||
private MockMvc mvc;
|
||||
|
@ -37,18 +37,18 @@ public class InfoControllerTest {
|
|||
@MockBean
|
||||
private InfoController infoController;
|
||||
|
||||
private LocalDate expectedDate;
|
||||
private String formattedDate;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
expectedDate = LocalDate.now();
|
||||
LocalDate expectedDate = LocalDate.now();
|
||||
formattedDate = expectedDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
given(infoController.getDate(JdbcInfoDao.DATE_INFO.claim_load_date.name())).willReturn(expectedDate);
|
||||
given(infoController.getDate(JdbcInfoDao.DATE_INFO.oaf_load_date.name())).willReturn(expectedDate);
|
||||
given(infoController.getDate(JdbcInfoDao.DATE_INFO.odf_load_date.name())).willReturn(expectedDate);
|
||||
given(infoController.getDate(JdbcInfoDao.DATE_INFO.inference_date.name())).willReturn(expectedDate);
|
||||
given(infoController.getDate(JdbcInfoDao.DATE_INFO.stats_update_date.name())).willReturn(expectedDate);
|
||||
given(infoController.getDate(JdbcInfoDao.DATE_INFO.db_load_date.name())).willReturn(expectedDate);
|
||||
given(infoController.listInfo()).willReturn(Maps.newHashMap(JdbcInfoDao.DATE_INFO.inference_date.name(), LocalDate.now()));
|
||||
given(infoController.listInfoKeys())
|
||||
.willReturn(Arrays.stream(JdbcInfoDao.DATE_INFO.values()).map(JdbcInfoDao.DATE_INFO::name).collect(Collectors.toList()));
|
||||
|
@ -116,4 +116,12 @@ public class InfoControllerTest {
|
|||
.getContentAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDbLoadDate() throws Exception {
|
||||
mvc.perform(get("/info/db_load_date")
|
||||
.contentType(APPLICATION_JSON_UTF8))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$", is(formattedDate)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue