BAEL-1277: RESTFul CRUD application with JavaLite (#3359)

* BAEL-1277: RESTFul CRUD application with JavaLite.

* BAEL-1277: RESTFul CRUD application with JavaLite. Adding exception handling.
This commit is contained in:
Magdalena Krause
2018-01-05 16:51:47 -03:00
committed by maibin
parent 749533e14d
commit 1273bb4aee
15 changed files with 315 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
package app.models;
import org.javalite.activejdbc.Base;
import org.junit.Assert;
import org.junit.Test;
public class ProductTest {
//@Test
public void givenSavedProduct_WhenFindFirst_ThenSavedProductIsReturned() {
//Open DB connection
Base.open("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/dbname", "user", "password");
//Create a product and save it
Product toSaveProduct = new Product();
toSaveProduct.set("name", "Bread");
toSaveProduct.saveIt();
//Find product
Product savedProduct = Product.findFirst("name = ?", "Bread");
Assert.assertEquals(toSaveProduct.get("name"), savedProduct.get("name"));
}
}