Format Java files with google-java-format

Change-Id: Id0cce149584fa4887eaaf4ecfc22da29a9daecfd
This commit is contained in:
David Pursehouse 2017-04-04 11:11:54 +09:00
parent 3490744900
commit 77b0af18c8
3 changed files with 20 additions and 17 deletions

View File

@ -22,8 +22,8 @@ import com.google.gerrit.common.Nullable;
import com.google.template.soy.SoyFileSet;
import com.google.template.soy.data.SanitizedContent;
import com.google.template.soy.data.SoyMapData;
import com.google.template.soy.tofu.SoyTofu;
import com.google.template.soy.data.UnsafeSanitizedContentOrdainer;
import com.google.template.soy.tofu.SoyTofu;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
@ -39,10 +39,13 @@ public class IndexServlet extends HttpServlet {
String resourcePath = "com/google/gerrit/httpd/raw/index.html.soy";
SoyFileSet.Builder builder = SoyFileSet.builder();
builder.add(Resources.getResource(resourcePath));
SoyTofu.Renderer renderer = builder.build().compileToTofu()
.newRenderer("com.google.gerrit.httpd.raw.Index")
.setContentKind(SanitizedContent.ContentKind.HTML)
.setData(getTemplateData(canonicalURL, cdnPath));
SoyTofu.Renderer renderer =
builder
.build()
.compileToTofu()
.newRenderer("com.google.gerrit.httpd.raw.Index")
.setContentKind(SanitizedContent.ContentKind.HTML)
.setData(getTemplateData(canonicalURL, cdnPath));
indexSource = renderer.render().getBytes();
}
@ -75,8 +78,9 @@ public class IndexServlet extends HttpServlet {
// The resource path must be typed as safe for use in a script src.
// TODO(wyatta): Upgrade this to use an appropriate safe URL type.
SanitizedContent sanitizedStaticPath = UnsafeSanitizedContentOrdainer.ordainAsSafe(staticPath,
SanitizedContent.ContentKind.TRUSTED_RESOURCE_URI);
SanitizedContent sanitizedStaticPath =
UnsafeSanitizedContentOrdainer.ordainAsSafe(
staticPath, SanitizedContent.ContentKind.TRUSTED_RESOURCE_URI);
return new SoyMapData(
"canonicalPath", canonicalPath,

View File

@ -33,7 +33,6 @@ import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.config.SitePaths;
import com.google.inject.Inject;
import com.google.inject.Key;
import com.google.inject.Provider;
import com.google.inject.Provides;
import com.google.inject.ProvisionException;
import com.google.inject.Singleton;
@ -252,8 +251,9 @@ public class StaticModule extends ServletModule {
@Provides
@Singleton
@Named(POLYGERRIT_INDEX_SERVLET)
HttpServlet getPolyGerritUiIndexServlet(@CanonicalWebUrl @Nullable String canonicalUrl,
@GerritServerConfig Config cfg) throws URISyntaxException {
HttpServlet getPolyGerritUiIndexServlet(
@CanonicalWebUrl @Nullable String canonicalUrl, @GerritServerConfig Config cfg)
throws URISyntaxException {
String cdnPath = cfg.getString("gerrit", null, "cdnPath");
return new IndexServlet(canonicalUrl, cdnPath);
}

View File

@ -14,13 +14,12 @@
package com.google.gerrit.httpd.raw;
import com.google.gerrit.common.Nullable;
import static com.google.common.truth.Truth.assertThat;
import com.google.template.soy.data.SoyMapData;
import java.net.URISyntaxException;
import org.junit.Test;
import static com.google.common.truth.Truth.assertThat;
public class IndexServletTest {
@Test
public void noPathAndNoCDN() throws URISyntaxException {
@ -38,8 +37,8 @@ public class IndexServletTest {
@Test
public void noPathAndCDN() throws URISyntaxException {
SoyMapData data = IndexServlet.getTemplateData("http://example.com/",
"http://my-cdn.com/foo/bar/");
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/");
@ -47,8 +46,8 @@ public class IndexServletTest {
@Test
public void pathAndCDN() throws URISyntaxException {
SoyMapData data = IndexServlet.getTemplateData("http://example.com/gerrit",
"http://my-cdn.com/foo/bar/");
SoyMapData data =
IndexServlet.getTemplateData("http://example.com/gerrit", "http://my-cdn.com/foo/bar/");
assertThat(data.getSingle("canonicalPath").stringValue()).isEqualTo("/gerrit");
assertThat(data.getSingle("staticResourcePath").stringValue())
.isEqualTo("http://my-cdn.com/foo/bar/");