Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
DARIAH-DE
TextGridRep Portal
Commits
6bdaca6c
Commit
6bdaca6c
authored
May 16, 2020
by
Ubbo Veentjer
Browse files
more tests, remove unused code
parent
0fe626b5
Pipeline
#135172
passed with stages
in 9 minutes and 46 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/info/textgrid/rep/service/tgsearch/AggregatorClientService.java
View file @
6bdaca6c
...
...
@@ -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
=
""
;
...
...
src/test/java/info/textgrid/rep/search/BrowseFacetControllerTest.java
0 → 100644
View file @
6bdaca6c
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
());
}
}
src/test/java/info/textgrid/rep/shared/UtilsTest.java
0 → 100644
View file @
6bdaca6c
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"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment