package it.twiskex.test;
import java.util.Date;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
import com.googlecode.objectify.Query;
import it.twiskex.dal.DALService;
import it.twiskex.dal.entities.SearchNTT;
public class OrderbyTest {
private final LocalServiceTestHelper helper = new LocalServiceTestHelper(
new LocalDatastoreServiceTestConfig());
@Before
public void setUp() {
helper.setUp();
}
@After
public void tearDown() {
helper.tearDown();
}
@Test
public void testInsert1() {
doTest();
}
private void doTest() {
try {
helper.setUp();
SearchNTT s1 = new SearchNTT("1");
s1.setLastUpdate(new Date());
Thread.sleep(2000);
SearchNTT s2 = new SearchNTT("2");
s2.setLastUpdate(new Date());
Thread.sleep(2500);
SearchNTT s3 = new SearchNTT("3");
s3.setLastUpdate(new Date());
DALService.ofy().put(s1);
DALService.ofy().put(s2);
DALService.ofy().put(s3);
Query<SearchNTT> s = DALService.ofy().query(SearchNTT.class)
.order("-lastUpdate");
for (SearchNTT searchNTT : s) {
System.out.println(searchNTT.getHashtag());
DALService.ofy().delete(searchNTT);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}