Hibernate one to many Tutorial (#1050)
* First Commit * Second Commit for Guide to JGit * Hibernate many to one example * added test units to hibernate one to many tutorial
This commit is contained in:
+43
@@ -0,0 +1,43 @@
|
||||
|
||||
package com.baeldung.hibernate.oneToMany.config;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
public class HibernateAnnotationUtilTest {
|
||||
|
||||
public HibernateAnnotationUtilTest() {
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSessionFactory() {
|
||||
System.out.println("getSessionFactory");
|
||||
SessionFactory expResult = null;
|
||||
SessionFactory result = HibernateAnnotationUtil.getSessionFactory();
|
||||
assertEquals(expResult, result);
|
||||
fail("The test failed.");
|
||||
}
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
|
||||
package com.baeldung.hibernate.oneToMany.main;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
public class HibernateOneToManyAnnotationMainTest {
|
||||
|
||||
public HibernateOneToManyAnnotationMainTest() {
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
}
|
||||
@Test
|
||||
public void testMain() {
|
||||
System.out.println("main");
|
||||
String[] args = null;
|
||||
HibernateOneToManyAnnotationMain.main(args);
|
||||
fail("The test failed.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
|
||||
package com.baeldung.hibernate.oneToMany.model;
|
||||
|
||||
import java.util.Set;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
public class CartTest {
|
||||
|
||||
public CartTest() {
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetId() {
|
||||
System.out.println("getId");
|
||||
Cart instance = new Cart();
|
||||
long expResult = 0L;
|
||||
long result = instance.getId();
|
||||
assertEquals(expResult, result);
|
||||
fail("The test failed.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetId() {
|
||||
System.out.println("setId");
|
||||
long id = 0L;
|
||||
Cart instance = new Cart();
|
||||
instance.setId(id);
|
||||
fail("The test failed.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTotal() {
|
||||
System.out.println("getTotal");
|
||||
Cart instance = new Cart();
|
||||
double expResult = 0.0;
|
||||
double result = instance.getTotal();
|
||||
assertEquals(expResult, result, 0.0);
|
||||
fail("The test failed.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetTotal() {
|
||||
System.out.println("setTotal");
|
||||
double total = 0.0;
|
||||
Cart instance = new Cart();
|
||||
instance.setTotal(total);
|
||||
fail("The test failed.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetName() {
|
||||
System.out.println("getName");
|
||||
Cart instance = new Cart();
|
||||
String expResult = "";
|
||||
String result = instance.getName();
|
||||
assertEquals(expResult, result);
|
||||
fail("The test failed");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetName() {
|
||||
System.out.println("setName");
|
||||
String name = "";
|
||||
Cart instance = new Cart();
|
||||
instance.setName(name);
|
||||
fail("The test failed.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetItems() {
|
||||
System.out.println("getItems");
|
||||
Cart instance = new Cart();
|
||||
Set<Items> expResult = null;
|
||||
Set<Items> result = instance.getItems();
|
||||
assertEquals(expResult, result);
|
||||
fail("The test failed.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetItems() {
|
||||
System.out.println("setItems");
|
||||
Set<Items> items = null;
|
||||
Cart instance = new Cart();
|
||||
instance.setItems(items);
|
||||
fail("The test case failed");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
|
||||
package com.baeldung.hibernate.oneToMany.model;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
public class ItemsTest {
|
||||
|
||||
public ItemsTest() {
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetItemId() {
|
||||
System.out.println("getItemId");
|
||||
Items instance = new Items();
|
||||
String expResult = "";
|
||||
String result = instance.getItemId();
|
||||
assertEquals(expResult, result);
|
||||
fail("The test failed.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetItemId() {
|
||||
System.out.println("setItemId");
|
||||
String itemId = "";
|
||||
Items instance = new Items();
|
||||
instance.setItemId(itemId);
|
||||
fail("The test failed.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetItemTotal() {
|
||||
System.out.println("getItemTotal");
|
||||
Items instance = new Items();
|
||||
double expResult = 0.0;
|
||||
double result = instance.getItemTotal();
|
||||
assertEquals(expResult, result, 0.0);
|
||||
fail("The test failed.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetItemTotal() {
|
||||
System.out.println("setItemTotal");
|
||||
double itemTotal = 0.0;
|
||||
Items instance = new Items();
|
||||
instance.setItemTotal(itemTotal);
|
||||
fail("The test failed.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetQuantity() {
|
||||
System.out.println("getQuantity");
|
||||
Items instance = new Items();
|
||||
int expResult = 0;
|
||||
int result = instance.getQuantity();
|
||||
assertEquals(expResult, result);
|
||||
fail("The test failed.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetQuantity() {
|
||||
System.out.println("setQuantity");
|
||||
int quantity = 0;
|
||||
Items instance = new Items();
|
||||
instance.setQuantity(quantity);
|
||||
fail("The test failed.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCart() {
|
||||
System.out.println("getCart");
|
||||
Items instance = new Items();
|
||||
Cart expResult = null;
|
||||
Cart result = instance.getCart();
|
||||
assertEquals(expResult, result);
|
||||
fail("The test failed.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetCart() {
|
||||
System.out.println("setCart");
|
||||
Cart cart = null;
|
||||
Items instance = new Items();
|
||||
instance.setCart1(cart);
|
||||
fail("The test failed.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetId() {
|
||||
System.out.println("getId");
|
||||
Items instance = new Items();
|
||||
long expResult = 0L;
|
||||
long result = instance.getId();
|
||||
assertEquals(expResult, result);
|
||||
fail("The test failed.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetId() {
|
||||
System.out.println("setId");
|
||||
long id = 0L;
|
||||
Items instance = new Items();
|
||||
instance.setId(id);
|
||||
fail("The test failed.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user