use of org.apache.openejb.test.entity.cmr.manytomany.PlatformLocal in project tomee by apache.
the class ManyToManyTests method testBSetADropExisting.
public void testBSetADropExisting() throws Exception {
resetDB();
beginTransaction();
try {
GameLocal game = findGame(new Integer(11));
game.setPlatforms(new HashSet<PlatformLocal>());
game = findGame(new Integer(22));
game.setPlatforms(new HashSet<PlatformLocal>());
} finally {
completeTransaction();
}
assertAllUnlinked();
}
use of org.apache.openejb.test.entity.cmr.manytomany.PlatformLocal in project tomee by apache.
the class ManyToManyTests method testAGetBExistingAB.
public void testAGetBExistingAB() throws Exception {
resetDB();
beginTransaction();
try {
final PlatformLocal platform = findPlatform(new Integer(1));
final Set<GameLocal> gameSets = platform.getGames();
assertEquals(2, gameSets.size());
for (final Iterator iter = gameSets.iterator(); iter.hasNext(); ) {
final GameLocal game = (GameLocal) iter.next();
if (game.getId().equals(new Integer(11))) {
assertEquals("value11", game.getName());
} else if (game.getId().equals(new Integer(22))) {
assertEquals("value22", game.getName());
} else {
fail();
}
}
} finally {
completeTransaction();
}
}
use of org.apache.openejb.test.entity.cmr.manytomany.PlatformLocal in project tomee by apache.
the class ManyToManyTests method testSetCmrNull.
public void testSetCmrNull() throws Exception {
resetDB();
beginTransaction();
try {
final PlatformLocal platform = findPlatform(new Integer(1));
try {
platform.setGames(null);
fail("expected platform.setGames(null) to throw an IllegalArgumentException");
} catch (final TransactionRolledbackLocalException e) {
final Throwable cause = e.getCause();
assertNotNull("cause is null", cause);
assertTrue("cause is not a instance of IllegalArgumentException", cause instanceof IllegalArgumentException);
}
} finally {
completeTransaction();
}
}
use of org.apache.openejb.test.entity.cmr.manytomany.PlatformLocal in project tomee by apache.
the class ManyToManyComplexPkTests method testASetBNewAB.
public void testASetBNewAB() throws Exception {
resetDB();
beginTransaction();
try {
final PlatformLocal platform = createPlatform(new Integer(4));
final GameLocal game = createGame(new Integer(33));
final Set<GameLocal> gameSets = platform.getGames();
gameSets.add(game);
} finally {
completeTransaction();
}
assertLinked(4, 33);
}
use of org.apache.openejb.test.entity.cmr.manytomany.PlatformLocal in project tomee by apache.
the class ManyToManyComplexPkTests method testSetCmrNull.
public void testSetCmrNull() throws Exception {
resetDB();
beginTransaction();
try {
final PlatformLocal platform = findPlatform(new Integer(1));
try {
platform.setGames(null);
fail("expected platform.setGames(null) to throw an IllegalArgumentException");
} catch (final TransactionRolledbackLocalException e) {
final Throwable cause = e.getCause();
assertNotNull("cause is null", cause);
assertTrue("cause is not a instance of IllegalArgumentException", cause instanceof IllegalArgumentException);
}
} finally {
completeTransaction();
}
}
Aggregations