blob: ded687111be186a441a520f7ce20d61e64d12614 [file] [log] [blame]
margarethaa8c364b2021-02-19 13:00:31 +01001package de.ids_mannheim.korap.web.service;
2
3import static org.junit.Assert.assertEquals;
4
5import org.junit.Test;
6import org.springframework.beans.factory.annotation.Autowired;
7
8import com.fasterxml.jackson.databind.JsonNode;
9import com.sun.jersey.api.client.ClientResponse;
10import com.sun.jersey.api.client.ClientResponse.Status;
11
12import de.ids_mannheim.korap.config.KustvaktConfiguration;
13import de.ids_mannheim.korap.config.LiteJerseyTest;
14import de.ids_mannheim.korap.exceptions.KustvaktException;
15import de.ids_mannheim.korap.utils.JsonUtils;
16import de.ids_mannheim.korap.utils.ServiceInfo;
margarethae1228ab2021-02-22 11:51:38 +010017import de.ids_mannheim.korap.web.SearchKrill;
margarethaa8c364b2021-02-19 13:00:31 +010018
19public class InfoControllerTest extends LiteJerseyTest {
20
21 @Autowired
22 private KustvaktConfiguration config;
23
margarethae1228ab2021-02-22 11:51:38 +010024 @Autowired
25 private SearchKrill krill;
26
margarethaa8c364b2021-02-19 13:00:31 +010027 @Test
28 public void testInfo () throws KustvaktException {
29 ClientResponse response = resource().path(API_VERSION).path("info")
abcpro1241bc4f2022-11-07 20:13:57 +000030 .request()
margarethaa8c364b2021-02-19 13:00:31 +010031 .get(ClientResponse.class);
32
33 assertEquals(Status.OK.getStatusCode(), response.getStatus());
34
35 String entity = response.getEntity(String.class);
36 JsonNode node = JsonUtils.readTree(entity);
37 assertEquals(config.getCurrentVersion(),
38 node.at("/latest_api_version").asText());
39 assertEquals(config.getSupportedVersions().size(),
40 node.at("/supported_api_versions").size());
41
42 assertEquals(ServiceInfo.getInfo().getVersion(),
43 node.at("/kustvakt_version").asText());
margarethae1228ab2021-02-22 11:51:38 +010044 assertEquals(krill.getIndex().getVersion(),
margarethaa8c364b2021-02-19 13:00:31 +010045 node.at("/krill_version").asText());
46 assertEquals(ServiceInfo.getInfo().getKoralVersion(),
47 node.at("/koral_version").asText());
48 }
49}