use of com.google.template.soy.data.SoyMapData in project buck by facebook.
the class TracesHandlerDelegate method getTraces.
@VisibleForTesting
SoyListData getTraces() throws IOException {
List<Path> traceFiles = buildTraces.listTraceFilesByLastModified();
SoyListData traces = new SoyListData();
for (Path path : traceFiles) {
String name = path.getFileName().toString();
Matcher matcher = TRACE_FILE_NAME_PATTERN.matcher(name);
if (!matcher.matches()) {
// Could be build.trace or launch.xxx.trace.
continue;
}
SoyMapData trace = new SoyMapData();
trace.put("name", name);
trace.put("id", matcher.group(1));
TraceAttributes traceAttributes = buildTraces.getTraceAttributesFor(path);
trace.put("dateTime", traceAttributes.getFormattedDateTime());
if (traceAttributes.getCommand().isPresent()) {
trace.put("command", traceAttributes.getCommand().get());
} else {
trace.put("command", "");
}
traces.add(trace);
}
return traces;
}
use of com.google.template.soy.data.SoyMapData in project gerrit by GerritCodeReview.
the class IndexServletTest method pathAndNoCDN.
@Test
public void pathAndNoCDN() throws URISyntaxException {
SoyMapData data = IndexServlet.getTemplateData("http://example.com/gerrit/", null);
assertThat(data.getSingle("canonicalPath").stringValue()).isEqualTo("/gerrit");
assertThat(data.getSingle("staticResourcePath").stringValue()).isEqualTo("/gerrit");
}
use of com.google.template.soy.data.SoyMapData in project gerrit by GerritCodeReview.
the class IndexServletTest method noPathAndCDN.
@Test
public void noPathAndCDN() throws URISyntaxException {
SoyMapData data = IndexServlet.getTemplateData("http://example.com/", "http://my-cdn.com/foo/bar/");
assertThat(data.getSingle("canonicalPath").stringValue()).isEqualTo("");
assertThat(data.getSingle("staticResourcePath").stringValue()).isEqualTo("http://my-cdn.com/foo/bar/");
}
use of com.google.template.soy.data.SoyMapData in project gitiles by GerritCodeReview.
the class HostIndexServletTest method rootHtml.
@Test
public void rootHtml() throws Exception {
Map<String, ?> data = buildData("/");
assertThat(data).containsEntry("hostName", URLS.getHostName(null));
assertThat(data).containsEntry("breadcrumbs", NullData.INSTANCE);
assertThat(data).containsEntry("prefix", "");
SoyListData repos = (SoyListData) data.get("repositories");
assertThat(repos).hasSize(1);
SoyMapData ent = (SoyMapData) repos.get(0);
assertThat(ent.get("name").toString()).isEqualTo(NAME);
assertThat(ent.get("url").toString()).isEqualTo("/b/" + NAME + "/");
}
Aggregations