Re-enabled additional tests
This commit is contained in:
parent
6f32391ed7
commit
ccb590caf4
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
//$Id: Group.java 5686 2005-02-12 07:27:32Z steveebersole $
|
||||
package org.hibernate.test.mapelemformula;
|
||||
package org.hibernate.orm.test.mapelemformula;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.orm.test.mapelemformula;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Gavin King
|
||||
*/
|
||||
@DomainModel(
|
||||
xmlMappings = "org/hibernate/orm/test/mapelemformula/UserGroup.hbm.xml"
|
||||
)
|
||||
@SessionFactory
|
||||
public class MapElementFormulaTest {
|
||||
|
||||
@BeforeEach
|
||||
public void setUp(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
User gavin = new User( "gavin", "secret" );
|
||||
User turin = new User( "turin", "tiger" );
|
||||
Group g = new Group( "users" );
|
||||
g.getUsers().put( "Gavin", gavin );
|
||||
g.getUsers().put( "Turin", turin );
|
||||
session.persist( g );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
Group g = session.get( Group.class, "users" );
|
||||
assertEquals( 1, g.getUsers().size() );
|
||||
session.delete( g );
|
||||
session.delete( g.getUsers().get( "Gavin" ) );
|
||||
session.delete( session.get( User.class, "turin" ) );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public void testManyToManyFormula(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
Group g = session.get( Group.class, "users" );
|
||||
assertEquals( 2, g.getUsers().size() );
|
||||
g.getUsers().remove( "Turin" );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
//$Id: User.java 5686 2005-02-12 07:27:32Z steveebersole $
|
||||
package org.hibernate.test.mapelemformula;
|
||||
package org.hibernate.orm.test.mapelemformula;
|
||||
|
||||
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
-->
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.mapelemformula">
|
||||
<hibernate-mapping package="org.hibernate.orm.test.mapelemformula">
|
||||
|
||||
<class name="Group" table="groups_">
|
||||
<id name="name"/>
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.mapelemformula;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Gavin King
|
||||
*/
|
||||
public class MapElementFormulaTest extends BaseCoreFunctionalTestCase {
|
||||
public String[] getMappings() {
|
||||
return new String[] { "mapelemformula/UserGroup.hbm.xml" };
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings( {"unchecked"})
|
||||
public void testManyToManyFormula() {
|
||||
Session s = openSession();
|
||||
Transaction t = s.beginTransaction();
|
||||
User gavin = new User("gavin", "secret");
|
||||
User turin = new User("turin", "tiger");
|
||||
Group g = new Group("users");
|
||||
g.getUsers().put("Gavin", gavin);
|
||||
g.getUsers().put("Turin", turin);
|
||||
s.persist(g);
|
||||
t.commit();
|
||||
s.close();
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
g = (Group) s.get(Group.class, "users");
|
||||
assertEquals( g.getUsers().size(), 2 );
|
||||
g.getUsers().remove("Turin");
|
||||
t.commit();
|
||||
s.close();
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
g = (Group) s.get(Group.class, "users");
|
||||
assertEquals( g.getUsers().size(), 1 );
|
||||
s.delete(g);
|
||||
s.delete( g.getUsers().get("Gavin") );
|
||||
s.delete( s.get(User.class, "turin") );
|
||||
t.commit();
|
||||
s.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue