com.googlecode.objectify.test.BulkGetTests Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of objectify Show documentation
Show all versions of objectify Show documentation
*** THIS VERSION UPLOADED FOR USE WITH CEDAR-COMMON, TO AVOID DEPENDENCIES ON GOOGLE CODE-BASED MAVEN REPOSITORIES. *** The simplest convenient interface to the Google App Engine datastore
The newest version!
package com.googlecode.objectify.test;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.testng.annotations.Test;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.test.entity.Trivial;
/**
* Tests that bulk gets return results having the same order as the argument
*/
public class BulkGetTests extends TestBase
{
/** */
@Test
@SuppressWarnings("unchecked")
public void testOrderOfBulkGet()
{
Objectify ofy = this.fact.begin();
Trivial t1 = new Trivial("foo", 5);
Trivial t2 = new Trivial("bar", 6);
Key k1 = ofy.put(t1);
Key k2 = ofy.put(t2);
// get k1, then k2
Map,Trivial> map = ofy.get(Arrays.asList(k1, k2));
assert sameList(Arrays.asList(k1, k2), map.keySet());
// get k2, then k1
map = ofy.get(Arrays.asList(k2, k1));
assert sameList(Arrays.asList(k2, k1), map.keySet());
}
private boolean sameList(List> l1, Collection> l2) {
return Arrays.equals(l1.toArray(), l2.toArray());
}
}