use of models.Car in project play-cookbook by spinscale.
the class CsvTest method checkThatLimitAndOffsetWorks.
@Test
public void checkThatLimitAndOffsetWorks() throws Exception {
new Car("VW", "Passat").save();
new Car("VW", "Golf").save();
new Car("VW", "Polo").save();
new Car("VW", "Phaeton").save();
new Car("VW", "Scirocco").save();
new Car("Loremo", "GT").save();
List<Car> cars = Car.find("byBrand", "VW").fetch();
assertEquals(5, cars.size());
assertValidCar(cars.get(0), "VW", "Passat");
assertValidCar(cars.get(1), "VW", "Golf");
assertValidCar(cars.get(2), "VW", "Polo");
assertValidCar(cars.get(3), "VW", "Phaeton");
assertValidCar(cars.get(4), "VW", "Scirocco");
cars = Car.find("byBrand", "VW").fetch(0, 1);
assertEquals(4, cars.size());
assertValidCar(cars.get(0), "VW", "Golf");
assertValidCar(cars.get(1), "VW", "Polo");
assertValidCar(cars.get(2), "VW", "Phaeton");
assertValidCar(cars.get(3), "VW", "Scirocco");
cars = Car.find("byBrand", "VW").fetch(3, 0);
assertEquals(3, cars.size());
assertValidCar(cars.get(0), "VW", "Passat");
assertValidCar(cars.get(1), "VW", "Golf");
assertValidCar(cars.get(2), "VW", "Polo");
cars = Car.find("byBrand", "VW").fetch(4, 2);
assertEquals(3, cars.size());
assertValidCar(cars.get(0), "VW", "Polo");
assertValidCar(cars.get(1), "VW", "Phaeton");
assertValidCar(cars.get(2), "VW", "Scirocco");
}
use of models.Car in project play-cookbook by spinscale.
the class CsvTest method deleteSimpleEntity.
@Test
public void deleteSimpleEntity() throws IOException {
c.delete();
Car c = new Car();
c.brand = "VW";
c.type = "Jetta";
c.save();
String data = FileUtils.readFileToString(new File("/tmp/Car.csv"));
String expected = "\"2\"\t\"VW\"\t\"Jetta\"\n";
assertEquals(expected, data);
}
use of models.Car in project play-cookbook by spinscale.
the class CsvTest method saveTwoEntities.
@Test
public void saveTwoEntities() throws Exception {
Car c = new Car();
c.brand = "VW";
c.type = "Jetta";
c.save();
String data = FileUtils.readFileToString(new File("/tmp/Car.csv"));
String expected = "\"1\"\t\"BMW\"\t\"320\"\n\"2\"\t\"VW\"\t\"Jetta\"\n";
assertEquals(expected, data);
}
use of models.Car in project play-cookbook by spinscale.
the class SolrSearchTest method ensureDeletionWorks.
@Test
public void ensureDeletionWorks() throws Exception {
List<Car> cars = Car.findAll();
for (Car car : cars) {
car.delete();
}
assertEquals(0, new Query("brand_s:*", Car.class).fetchIds().size());
}
use of models.Car in project play-cookbook by spinscale.
the class SolrSearchTest method testCarsWithDynamicSetup.
@Test
public void testCarsWithDynamicSetup() throws Exception {
Car c = Car.find("byBrand", "BMW").first();
assertNotNull(c);
SolrQuery query = new SolrQuery();
query.setQuery("brand_s:BMW");
QueryResponse rp = server.query(query);
SolrDocumentList results = rp.getResults();
assertEquals(1, results.size());
assertEquals("BMW", results.get(0).getFieldValue("brand_s"));
assertEquals(c.getClass().getName() + ":" + c.id.toString(), results.get(0).getFieldValue("id"));
}
Aggregations