Skip to content

Some Trivial Tests #189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 26, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Check style isn't my friend today.
Several changes due to weird imports in IntelliJ.
  • Loading branch information
Les Vogel committed Apr 25, 2016
commit 158181fc0ef9dfc1d80a974b94c6a9e89fa7fb77
2 changes: 1 addition & 1 deletion appengine/guestbook-objectify/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
*/
package com.example.guestbook;

import static com.example.guestbook.GuestbookTestUtilities.cleanDatastore;
import static org.junit.Assert.assertEquals;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
Expand All @@ -24,15 +27,12 @@

import com.googlecode.objectify.ObjectifyService;
import com.googlecode.objectify.util.Closeable;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import static com.example.guestbook.GuestbookTestUtilities.cleanDatastore;
import static org.junit.Assert.assertEquals;

@RunWith(JUnit4.class)
public class GreetingTest {
Expand Down Expand Up @@ -79,7 +79,6 @@ public void createSaveObject() throws Exception {
.setAncestor(new KeyFactory.Builder("Guestbook", "default").getKey());
PreparedQuery pq = ds.prepare(query);
Entity greeting = pq.asSingleEntity(); // Should only be one at this point.
System.out.println("e: "+greeting.toString());
assertEquals(greeting.getProperty("content"), TEST_CONTENT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void cleanDatastore(DatastoreService ds, String book) {
List<Entity> entities = pq.asList(FetchOptions.Builder.withDefaults());
ArrayList<Key> keys = new ArrayList<>(entities.size());

for(Entity e : entities) {
for (Entity e : entities) {
keys.add(e.getKey());
}
ds.delete(keys);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

package com.example.guestbook;

import static com.example.guestbook.GuestbookTestUtilities.cleanDatastore;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
Expand All @@ -27,7 +31,6 @@

import com.googlecode.objectify.ObjectifyService;
import com.googlecode.objectify.util.Closeable;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -42,9 +45,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import static com.example.guestbook.GuestbookTestUtilities.cleanDatastore;
import static junit.framework.Assert.assertEquals;
import static org.mockito.Mockito.when;
/**
* Unit tests for {@link com.example.guestbook.SignGuestbookServlet}.
*/
Expand All @@ -64,7 +64,8 @@ public class SignGuestbookServletTest {

@Mock private HttpServletRequest mockRequest;

@Mock private HttpServletResponse mockResponse;
@Mock
private HttpServletResponse mockResponse;

private StringWriter stringWriter;
private SignGuestbookServlet servletUnderTest;
Expand Down