| margaretha | a8c364b | 2021-02-19 13:00:31 +0100 | [diff] [blame] | 1 | package de.ids_mannheim.korap.web.service; |
| 2 | |
| 3 | import static org.junit.Assert.assertEquals; |
| 4 | |
| 5 | import org.junit.Test; |
| 6 | import org.springframework.beans.factory.annotation.Autowired; |
| 7 | |
| 8 | import com.fasterxml.jackson.databind.JsonNode; |
| 9 | import com.sun.jersey.api.client.ClientResponse; |
| 10 | import com.sun.jersey.api.client.ClientResponse.Status; |
| 11 | |
| 12 | import de.ids_mannheim.korap.config.KustvaktConfiguration; |
| 13 | import de.ids_mannheim.korap.config.LiteJerseyTest; |
| 14 | import de.ids_mannheim.korap.exceptions.KustvaktException; |
| 15 | import de.ids_mannheim.korap.utils.JsonUtils; |
| 16 | import de.ids_mannheim.korap.utils.ServiceInfo; |
| margaretha | e1228ab | 2021-02-22 11:51:38 +0100 | [diff] [blame] | 17 | import de.ids_mannheim.korap.web.SearchKrill; |
| margaretha | a8c364b | 2021-02-19 13:00:31 +0100 | [diff] [blame] | 18 | |
| 19 | public class InfoControllerTest extends LiteJerseyTest { |
| 20 | |
| 21 | @Autowired |
| 22 | private KustvaktConfiguration config; |
| 23 | |
| margaretha | e1228ab | 2021-02-22 11:51:38 +0100 | [diff] [blame] | 24 | @Autowired |
| 25 | private SearchKrill krill; |
| 26 | |
| margaretha | a8c364b | 2021-02-19 13:00:31 +0100 | [diff] [blame] | 27 | @Test |
| 28 | public void testInfo () throws KustvaktException { |
| 29 | ClientResponse response = resource().path(API_VERSION).path("info") |
| abcpro1 | 241bc4f | 2022-11-07 20:13:57 +0000 | [diff] [blame^] | 30 | .request() |
| margaretha | a8c364b | 2021-02-19 13:00:31 +0100 | [diff] [blame] | 31 | .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()); |
| margaretha | e1228ab | 2021-02-22 11:51:38 +0100 | [diff] [blame] | 44 | assertEquals(krill.getIndex().getVersion(), |
| margaretha | a8c364b | 2021-02-19 13:00:31 +0100 | [diff] [blame] | 45 | node.at("/krill_version").asText()); |
| 46 | assertEquals(ServiceInfo.getInfo().getKoralVersion(), |
| 47 | node.at("/koral_version").asText()); |
| 48 | } |
| 49 | } |