new_model_for_communities #15

Merged
michele.artini merged 81 commits from new_model_for_communities into master 2023-10-24 08:12:26 +02:00
2 changed files with 14 additions and 5 deletions
Showing only changes of commit 4c6134bc83 - Show all commits

View File

@ -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,

View File

@ -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)));
}
}