@@ -0,0 +1,2787 @@
+package com.google.sps;%0A%0Aimport com.google.sps.data.Event;%0Aimport com.google.sps.data.User;%0Aimport com.google.sps.servlets.BlobHandlerEventServlet;%0Aimport com.google.sps.servlets.BlobUrlServlet;%0Aimport com.google.sps.utilities.CommonUtils;%0Aimport com.google.sps.utilities.SpannerClient;%0Aimport com.google.sps.utilities.SpannerTasks;%0Aimport com.google.sps.utilities.SpannerTestTasks;%0Aimport com.google.sps.utilities.TestUtils;%0Aimport java.io.IOException;%0Aimport java.io.PrintWriter;%0Aimport java.io.StringWriter;%0Aimport javax.servlet.ServletContextEvent;%0Aimport javax.servlet.http.HttpServlet;%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0Aimport org.junit.After;%0Aimport org.junit.AfterClass;%0Aimport org.junit.Assert;%0Aimport org.junit.Before;%0Aimport org.junit.BeforeClass;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.junit.runners.JUnit4;%0Aimport org.mockito.Mockito;%0Aimport org.springframework.mock.web.MockServletContext;%0A%0A/** */%0A@RunWith(JUnit4.class)%0Apublic class BlobHandlerEventTest %7B%0A  private static final String EVENT_TYPE = %22event%22;%0A  private static final String EVENT_ID = %22event-id%22;%0A  private static final String INVALID_ID = %22invalid-id%22;%0A  private static final String IMAGE_URL = %22image-url.com%22;%0A  private static final User HOST = TestUtils.newUser();%0A  private static final Event EVENT = TestUtils.newEventWithHost(HOST).toBuilder().setId(EVENT_ID).build();%0A  private static final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);%0A  private static final HttpServletResponse response = Mockito.mock(HttpServletResponse.class);%0A  private static final StringWriter stringWriter = new StringWriter();%0A  private static final PrintWriter printWriter = new PrintWriter(stringWriter);%0A%0A  @BeforeClass%0A  public static void setUp() throws Exception %7B%0A    // Mock a request to trigger the SpannerClient setup to run%0A    MockServletContext mockServletContext = new MockServletContext();%0A    new SpannerClient().contextInitialized(new ServletContextEvent(mockServletContext));%0A    SpannerTestTasks.setup();%0A    Mockito.when(response.getWriter()).thenReturn(printWriter);%0A  %7D%0A%0A  @AfterClass%0A  public static void tearDown() throws Exception %7B%0A    SpannerTestTasks.cleanup();%0A  %7D%0A%0A  @After%0A  public void resetMocks() %7B%0A    Mockito.reset(request);%0A    stringWriter.getBuffer().setLength(0);%0A  %7D%0A%0A  @Test%0A  public void testGetImageUrl() throws Exception %7B%0A    SpannerTasks.insertOrUpdateUser(HOST);%0A    SpannerTasks.insertorUpdateEvent(%0A        EVENT.toBuilder().setImageUrl(IMAGE_URL).build());%0A    Mockito.doReturn(EVENT_ID).when(request).getParameter(%22event-id%22);%0A%0A    new BlobHandlerEventServlet().doGet(request, response);%0A %0A    Assert.assertFalse(stringWriter.toString().trim().isEmpty());%0A  %7D%0A%7D%0A

Add new test file