use of org.eclipse.jpt.jpa.core.context.JpaContextRoot in project jbosstools-hibernate by jbosstools.
the class HibernateJpaOrmModelTests method testNamigStrategyMapping.
@Test
public void testNamigStrategyMapping() {
ConsoleConfiguration cc = KnownConfigurations.getInstance().find(PROJECT_NAME);
assertNotNull("Console configuration not found for project " + PROJECT_NAME, cc);
cc.build();
assertNotNull("Console configuration build problem", cc.getConfiguration());
assertNotNull("Naming Strategy not found", cc.getConfiguration().getNamingStrategy());
assertEquals("ns.NamingStrategy", cc.getConfiguration().getNamingStrategy().getStrategyClassName());
try {
jpaProject = ((Reference) project.getAdapter(Reference.class)).getValue();
} catch (InterruptedException e) {
fail(e.getMessage());
}
assertNotNull(jpaProject);
JpaContextRoot rootContextNode = jpaProject.getContextRoot();
Persistence p = rootContextNode.getPersistenceXml().getRoot();
assertTrue(p.getPersistenceUnits().iterator().hasNext());
assertTrue(p.getPersistenceUnits().iterator().next() instanceof HibernatePersistenceUnit);
HibernatePersistenceUnit hpu = (HibernatePersistenceUnit) p.getPersistenceUnits().iterator().next();
List<MappingFileRef> mfrs = IterableTools.list(hpu.getMappingFileRefs());
assertTrue(mfrs.size() == 1);
assertTrue(mfrs.get(0).getMappingFile() instanceof GenericOrmXml);
GenericOrmXml orm = (GenericOrmXml) mfrs.get(0).getMappingFile();
checkManyToMany1NS(orm.getRoot().getPersistentType("entity.ManyToMany1"));
checkManyToMany2NS(orm.getRoot().getPersistentType("entity.ManyToMany2"));
cc.reset();
}
use of org.eclipse.jpt.jpa.core.context.JpaContextRoot in project jbosstools-hibernate by jbosstools.
the class HibernateJpaOrmModelTests method testDefaultMapping.
@Test
public void testDefaultMapping() {
assertNotNull(jpaProject);
JpaContextRoot rootContextNode = jpaProject.getContextRoot();
Persistence p = rootContextNode.getPersistenceXml().getRoot();
assertTrue(p.getPersistenceUnits().iterator().hasNext());
assertTrue(p.getPersistenceUnits().iterator().next() instanceof HibernatePersistenceUnit);
HibernatePersistenceUnit hpu = (HibernatePersistenceUnit) p.getPersistenceUnits().iterator().next();
List<MappingFileRef> mfrs = IterableTools.list(hpu.getMappingFileRefs());
assertTrue(mfrs.size() == 1);
assertTrue(mfrs.get(0).getMappingFile() instanceof GenericOrmXml);
GenericOrmXml orm = (GenericOrmXml) mfrs.get(0).getMappingFile();
List<OrmPersistentType> pTypes = IterableTools.list(orm.getRoot().getPersistentTypes());
assertTrue(pTypes.size() == 3);
checkManyToMany1(orm.getRoot().getPersistentType("entity.ManyToMany1"));
checkManyToMany2(orm.getRoot().getPersistentType("entity.ManyToMany2"));
}
use of org.eclipse.jpt.jpa.core.context.JpaContextRoot in project jbosstools-hibernate by jbosstools.
the class HibernateJpaModelTests method testNamigStrategyMapping.
@Test
public void testNamigStrategyMapping() {
ConsoleConfiguration cc = KnownConfigurations.getInstance().find(PROJECT_NAME);
assertNotNull("Console configuration not found for project " + PROJECT_NAME, cc);
cc.build();
assertNotNull("Console configuration build problem", cc.getConfiguration());
IConfiguration configuration = cc.getConfiguration();
assertNotNull("Naming Strategy not found", cc.getConfiguration().getNamingStrategy());
assertEquals("ns.NamingStrategy", cc.getConfiguration().getNamingStrategy().getStrategyClassName());
try {
jpaProject = ((Reference) project.getAdapter(Reference.class)).getValue();
} catch (InterruptedException e) {
fail(e.getMessage());
}
assertNotNull(jpaProject);
JpaContextRoot rootContextNode = jpaProject.getContextRoot();
Persistence p = rootContextNode.getPersistenceXml().getRoot();
assertTrue(p.getPersistenceUnits().iterator().hasNext());
assertTrue(p.getPersistenceUnits().iterator().next() instanceof HibernatePersistenceUnit);
HibernatePersistenceUnit hpu = (HibernatePersistenceUnit) p.getPersistenceUnits().iterator().next();
List<ClassRef> crs = IterableTools.list(hpu.getClassRefs());
assertTrue(crs.size() == 2);
if (crs.get(0).isFor("entity.ManyToMany1")) {
checkManyToManyNS1(crs.get(0));
checkManyToManyNS2(crs.get(1));
} else {
checkManyToManyNS1(crs.get(1));
checkManyToManyNS2(crs.get(0));
}
cc.reset();
}
use of org.eclipse.jpt.jpa.core.context.JpaContextRoot in project jbosstools-hibernate by jbosstools.
the class HibernateJpaModelTests method testDefaultMapping.
@Test
public void testDefaultMapping() {
assertNotNull(jpaProject);
JpaContextRoot rootContextNode = jpaProject.getContextRoot();
Persistence p = rootContextNode.getPersistenceXml().getRoot();
assertTrue(p.getPersistenceUnitsSize() > 0);
assertTrue(p.getPersistenceUnits().iterator().next() instanceof HibernatePersistenceUnit);
HibernatePersistenceUnit hpu = (HibernatePersistenceUnit) p.getPersistenceUnits().iterator().next();
List<ClassRef> crs = IterableTools.list(hpu.getClassRefs());
assertTrue(crs.size() == 2);
if (crs.get(0).isFor("entity.ManyToMany1")) {
checkManyToMany1(crs.get(0));
checkManyToMany2(crs.get(1));
} else {
checkManyToMany1(crs.get(1));
checkManyToMany2(crs.get(0));
}
}
Aggregations