use of org.molgenis.emx2.web.service.CatalogueSiteMap in project molgenis-emx2 by molgenis.
the class SiteMapService method getSiteMapForSchema.
public static String getSiteMapForSchema(Request request, Response response) {
response.type("text/xml, application/xml");
Schema schema = getSchema(request);
final String baseUrl = request.scheme() + "://" + request.host() + "/" + schema.getName();
return new CatalogueSiteMap(schema, baseUrl).buildSiteMap();
}
use of org.molgenis.emx2.web.service.CatalogueSiteMap in project molgenis-emx2 by molgenis.
the class CatalogueSiteMapTest method buildSiteMap.
@Test
public void buildSiteMap() {
Schema schema = mock(Schema.class);
Table table = mock(Table.class);
Query query = mock(Query.class);
List<Row> row = Collections.singletonList(new Row("pid", "my-cohort-pid"));
when(schema.getTable("Cohorts")).thenReturn(table);
when(table.select(any())).thenReturn(query);
when(query.retrieveRows()).thenReturn(row);
CatalogueSiteMap catalogueSiteMap = new CatalogueSiteMap(schema, "https://my/base/url");
String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" >\n" + " <url>\n" + " <loc>https://my/base/url/ssr-catalogue/Cohorts/my-cohort-pid</loc>\n" + " </url>\n" + "</urlset>";
assertEquals(expected, catalogueSiteMap.buildSiteMap());
}
Aggregations