Commit 6bdaca6c authored by Ubbo Veentjer's avatar Ubbo Veentjer
Browse files

more tests, remove unused code

parent 0fe626b5
Pipeline #135172 passed with stages
in 9 minutes and 46 seconds
......@@ -43,17 +43,6 @@ public class AggregatorClientService {
return result.readEntity(String.class);
}
public String renderFromQuery(String query, List<String> filter, String format) {
WebTarget target = restClient.target(this.tgrepConfig.getTextgridHost());
target = target.path("/1.0/aggregator/html/"+format+"/query")
.queryParam("query", query)
.queryParam("filter", filter);
Invocation.Builder builder = target.request();
return builder.get(String.class);
}
public String renderToc(String id) {
String result="";
......
package info.textgrid.rep.search;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.forwardedUrl;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
@SpringBootTest
@AutoConfigureMockMvc
public class BrowseFacetControllerTest {
@Autowired
private MockMvc mvc;
@Test
public void browseAgentsAscending() throws Exception {
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders
.get("/facet/edition.agent.value?order=term:asc")
.accept(MediaType.TEXT_HTML);
mvc.perform(builder)
.andExpect(view().name("browsefacet"))
.andExpect(forwardedUrl("/WEB-INF/jsp/browsefacet.jsp"))
.andExpect(status().isOk());
}
}
package info.textgrid.rep.shared;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import info.textgrid.clients.SearchClient;
import info.textgrid.namespaces.middleware.tgsearch.Response;
public class UtilsTest {
private static final String TEXTGRIDHOST = "https://textgridlab.org";
private static SearchClient searchClient;
@BeforeAll
public static void setup() {
searchClient = new SearchClient(TEXTGRIDHOST + "/1.0/tgsearch-public")
.enableGzipCompression();
}
@Test
public void testImageUrl() {
Response res = searchClient.infoQuery().getMetadata("textgrid:wtxq.0");
String imageUrl = Utils.getImageUrl(TEXTGRIDHOST, res.getResult().get(0));
Assertions.assertEquals(imageUrl, TEXTGRIDHOST + "/1.0/digilib/rest/IIIF/textgrid:wtxq.0/full/,250/0/native.jpg");
}
@Test
public void testImageUrl2() {
Response res = searchClient.infoQuery().getMetadata("textgrid:16h4p.1");
String imageUrl = Utils.getImageUrl(TEXTGRIDHOST, res.getResult().get(0));
Assertions.assertEquals(imageUrl, TEXTGRIDHOST + "/1.0/digilib/rest/IIIF/textgrid:16h4p.1/full/,250/0/native.jpg");
}
@Test
public void testNoImageUrl() {
Response res = searchClient.infoQuery().getMetadata("textgrid:kv2q.0");
String imageUrl = Utils.getImageUrl(TEXTGRIDHOST, res.getResult().get(0));
Assertions.assertEquals(imageUrl, "/images/no_image.svg");
}
@Test
public void testRootCollectionImageUrl() {
Response res = searchClient.infoQuery().getMetadata("textgrid:mgq5.0");
String imageUrl = Utils.getImageUrl(TEXTGRIDHOST, res.getResult().get(0));
Assertions.assertEquals(imageUrl, TEXTGRIDHOST + "/1.0/digilib/rest/IIIF/textgrid:mgqj.0/full/,250/0/native.jpg");
}
@Test
public void testurlEncode() {
String enc = Utils.urlencode("Bjørnson, Bjørnstjerne");
Assertions.assertEquals(enc, "Bj%C3%B8rnson%2C+Bj%C3%B8rnstjerne");
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment