package com.jmethods.test;

import static org.junit.Assert.assertEquals;

import java.io.IOException;

import org.junit.BeforeClass;
import org.junit.Test;

import com.google.cloud.datastore.Datastore;
import com.google.cloud.datastore.Entity;
import com.google.cloud.datastore.FullEntity;
import com.google.cloud.datastore.IncompleteKey;
import com.google.cloud.datastore.KeyFactory;
import com.google.cloud.datastore.testing.LocalDatastoreHelper;

/**
 * Unit test for simple App.
 */
public class AppTest {

	private static LocalDatastoreHelper helper;
	private static Datastore datastore;

	@BeforeClass
	public static void beforeClass() throws IOException, InterruptedException {
		helper = LocalDatastoreHelper.create(1.0);
		helper.start();
		datastore = helper.getOptions().getService();
	}

	@Test
	public void testApp() {
		KeyFactory kf = datastore.newKeyFactory();
		IncompleteKey incompleteKey = kf.setKind("MyEntity").newKey();
		FullEntity<IncompleteKey> fullEntity = FullEntity.newBuilder().setKey(incompleteKey).set("name", "John Doe")
				.build();
		Entity entity = datastore.add(fullEntity);
		Entity entity2 = datastore.get(entity.getKey());
		assertEquals(entity, entity2);
	}
}

@@ -65,16 +65,64 @@
 tEquals;
+%0Aimport static org.junit.Assert.assertNotEquals;
 %0A%0Aimport
@@ -1240,10 +1240,559 @@
 y2);%0A%09%7D%0A
+%0A%09@Test%0A%09public void testApp2() %7B%0A%09%09KeyFactory kf = datastore.newKeyFactory();%0A%09%09IncompleteKey incompleteKey = kf.setKind(%22MyEntity%22).newKey();%0A%09%09FullEntity%3CIncompleteKey%3E fullEntity = FullEntity.newBuilder().setKey(incompleteKey).set(%22name%22, %22John Doe%22)%0A%09%09%09%09.build();%0A%09%09Entity entity = datastore.add(fullEntity);%0A%09%09Entity entity2 = Entity.newBuilder(entity).set(%22name%22, %22John Smith%22).build();%0A%09%09datastore.update(entity2);%0A%09%09Entity entity3 = datastore.get(entity2.getKey());%0A%09%09assertEquals(entity2, entity3);%0A%09%09assertNotEquals(entity, entity3);%0A%09%7D%0A%0A
 %7D%0A

Test pull request build in Travis