Search in sources :

Example 6 with JDOMetaDataManager

use of org.datanucleus.api.jdo.metadata.JDOMetaDataManager in project tests by datanucleus.

the class BasicTest method testFieldForeignKeyMetadata.

/**
 * Tests the foreign key declared in many forms
 */
public void testFieldForeignKeyMetadata() {
    MetaDataManager mgr = new JDOMetaDataManager(new PersistenceNucleusContextImpl("JDO", null));
    mgr.setValidate(false);
    AbstractClassMetaData cmdD0 = mgr.getMetaDataForClass(D0.class, new ClassLoaderResolverImpl());
    AbstractClassMetaData cmdD1 = mgr.getMetaDataForClass(D1.class, new ClassLoaderResolverImpl());
    AbstractClassMetaData cmdD2 = mgr.getMetaDataForClass(D2.class, new ClassLoaderResolverImpl());
    AbstractClassMetaData cmdD3 = mgr.getMetaDataForClass(D3.class, new ClassLoaderResolverImpl());
    AbstractClassMetaData cmdD4 = mgr.getMetaDataForClass(D4.class, new ClassLoaderResolverImpl());
    AbstractClassMetaData cmdD5 = mgr.getMetaDataForClass(D5.class, new ClassLoaderResolverImpl());
    // Foreign Key name
    assertEquals("FK1", cmdD0.getMetaDataForManagedMemberAtAbsolutePosition(cmdD0.getAbsolutePositionOfMember("name")).getForeignKeyMetaData().getName());
    assertEquals(cmdD0.getMetaDataForManagedMemberAtAbsolutePosition(cmdD0.getAbsolutePositionOfMember("name")).getForeignKeyMetaData().getName(), cmdD1.getMetaDataForManagedMemberAtAbsolutePosition(cmdD1.getAbsolutePositionOfMember("name")).getForeignKeyMetaData().getName());
    assertEquals(cmdD0.getMetaDataForManagedMemberAtAbsolutePosition(cmdD0.getAbsolutePositionOfMember("name")).getForeignKeyMetaData().getName(), cmdD2.getMetaDataForManagedMemberAtAbsolutePosition(cmdD2.getAbsolutePositionOfMember("name")).getForeignKeyMetaData().getName());
    assertEquals(cmdD0.getMetaDataForManagedMemberAtAbsolutePosition(cmdD0.getAbsolutePositionOfMember("name")).getForeignKeyMetaData().getName(), cmdD3.getMetaDataForManagedMemberAtAbsolutePosition(cmdD3.getAbsolutePositionOfMember("name")).getForeignKeyMetaData().getName());
    assertEquals(cmdD0.getMetaDataForManagedMemberAtAbsolutePosition(cmdD0.getAbsolutePositionOfMember("name")).getForeignKeyMetaData().getName(), cmdD4.getMetaDataForManagedMemberAtAbsolutePosition(cmdD4.getAbsolutePositionOfMember("name")).getForeignKeyMetaData().getName());
    assertEquals(cmdD0.getMetaDataForManagedMemberAtAbsolutePosition(cmdD0.getAbsolutePositionOfMember("name")).getForeignKeyMetaData().getName(), cmdD5.getMetaDataForManagedMemberAtAbsolutePosition(cmdD5.getAbsolutePositionOfMember("name")).getForeignKeyMetaData().getName());
    // Foreign Key delete action
    assertEquals(ForeignKeyAction.CASCADE.toString(), cmdD4.getMetaDataForManagedMemberAtAbsolutePosition(cmdD4.getAbsolutePositionOfMember("name")).getForeignKeyMetaData().getDeleteAction().toString());
    // D5 should be "restrict" since the DTD imposes a default of "restrict" when specifying the <foreign-key/> element so the
    // "delete-action" attribute is ignored.
    assertEquals(ForeignKeyAction.RESTRICT.toString(), cmdD5.getMetaDataForManagedMemberAtAbsolutePosition(cmdD5.getAbsolutePositionOfMember("name")).getForeignKeyMetaData().getDeleteAction().toString());
}
Also used : JDOMetaDataManager(org.datanucleus.api.jdo.metadata.JDOMetaDataManager) MetaDataManager(org.datanucleus.metadata.MetaDataManager) PersistenceNucleusContextImpl(org.datanucleus.PersistenceNucleusContextImpl) JDOMetaDataManager(org.datanucleus.api.jdo.metadata.JDOMetaDataManager) AbstractClassMetaData(org.datanucleus.metadata.AbstractClassMetaData) ClassLoaderResolverImpl(org.datanucleus.ClassLoaderResolverImpl)

Example 7 with JDOMetaDataManager

use of org.datanucleus.api.jdo.metadata.JDOMetaDataManager in project tests by datanucleus.

the class BasicTest method testPrimaryKeyMetadata.

/**
 * Tests the primary key
 */
public void testPrimaryKeyMetadata() {
    MetaDataManager mgr = new JDOMetaDataManager(new PersistenceNucleusContextImpl("JDO", null));
    mgr.setValidate(false);
    AbstractClassMetaData cmdD0 = mgr.getMetaDataForClass(D0.class, new ClassLoaderResolverImpl());
    // Primary Key name
    assertEquals("THED0_PK", cmdD0.getPrimaryKeyMetaData().getName());
}
Also used : JDOMetaDataManager(org.datanucleus.api.jdo.metadata.JDOMetaDataManager) MetaDataManager(org.datanucleus.metadata.MetaDataManager) PersistenceNucleusContextImpl(org.datanucleus.PersistenceNucleusContextImpl) JDOMetaDataManager(org.datanucleus.api.jdo.metadata.JDOMetaDataManager) AbstractClassMetaData(org.datanucleus.metadata.AbstractClassMetaData) ClassLoaderResolverImpl(org.datanucleus.ClassLoaderResolverImpl)

Example 8 with JDOMetaDataManager

use of org.datanucleus.api.jdo.metadata.JDOMetaDataManager in project tests by datanucleus.

the class FetchPlanTest method testNestedFetchGroupsAgain.

/**
 * Test nested fetch groups.
 * TODO Merge this with the test above
 */
public void testNestedFetchGroupsAgain() {
    FetchPlan fp = getFetchPlan();
    PersistenceNucleusContextImpl nucleusCtx = new PersistenceNucleusContextImpl("JDO", null);
    MetaDataManager metaMgr = new JDOMetaDataManager(nucleusCtx);
    // test parent with fetch-group = group1
    AbstractClassMetaData cmd = metaMgr.getMetaDataForClass(FP1Sub.class, new ClassLoaderResolverImpl());
    fp.addGroup("1");
    fp.removeGroup(FetchPlan.DEFAULT);
    FetchPlanForClass fpc = fp.getFetchPlanForClass(cmd);
    int[] fieldsInFP = fpc.getMemberNumbers();
    assertEquals("should have 2 fields in fetchplan", 2, fieldsInFP.length);
    // check if fields are in the FP
    BitSet fieldsInFPBitSet = fpc.getMemberNumbersByBitSet();
    assertTrue("name should be in the fetchplan", fieldsInFPBitSet.get(cmd.getAbsolutePositionOfMember("name")));
    assertTrue("room should be in the fetchplan", fieldsInFPBitSet.get(cmd.getAbsolutePositionOfMember("room")));
}
Also used : FetchPlanForClass(org.datanucleus.FetchPlanForClass) BitSet(java.util.BitSet) JDOMetaDataManager(org.datanucleus.api.jdo.metadata.JDOMetaDataManager) MetaDataManager(org.datanucleus.metadata.MetaDataManager) PersistenceNucleusContextImpl(org.datanucleus.PersistenceNucleusContextImpl) FetchPlan(org.datanucleus.FetchPlan) JDOFetchPlan(org.datanucleus.api.jdo.JDOFetchPlan) JDOMetaDataManager(org.datanucleus.api.jdo.metadata.JDOMetaDataManager) AbstractClassMetaData(org.datanucleus.metadata.AbstractClassMetaData) ClassLoaderResolverImpl(org.datanucleus.ClassLoaderResolverImpl)

Example 9 with JDOMetaDataManager

use of org.datanucleus.api.jdo.metadata.JDOMetaDataManager in project tests by datanucleus.

the class FetchPlanTest method testPostLoad.

/**
 * Test the use of "postload"
 */
public void testPostLoad() throws Exception {
    FetchPlan fp = getFetchPlan();
    PersistenceNucleusContextImpl nucleusCtx = new PersistenceNucleusContextImpl("JDO", null);
    MetaDataManager metaMgr = new JDOMetaDataManager(nucleusCtx);
    AbstractClassMetaData cmd = metaMgr.getMetaDataForClass(FP2Base.class, new ClassLoaderResolverImpl());
    // --------------------------------------
    // all fields in DFG
    // --------------------------------------
    FetchPlanForClass fpc = fp.getFetchPlanForClass(cmd);
    boolean[] loadedFields = new boolean[14];
    loadedFields[cmd.getAbsolutePositionOfMember("piece1")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece2")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece3")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece4")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece5")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece6")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece7")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece8")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece9")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece10")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece11")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece12")] = true;
    assertFalse("Should not call postLoad callback", fpc.isToCallPostLoadFetchPlan(loadedFields));
    loadedFields[cmd.getAbsolutePositionOfMember("piece1")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece2")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece3")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece4")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece5")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece6")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece7")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece8")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece9")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece10")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece11")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece12")] = false;
    assertFalse("Should not call postLoad callback", fpc.isToCallPostLoadFetchPlan(loadedFields));
    loadedFields[cmd.getAbsolutePositionOfMember("piece1")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece2")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece3")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece4")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece5")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece6")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece7")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece8")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece9")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece10")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece11")] = false;
    loadedFields[cmd.getAbsolutePositionOfMember("piece12")] = false;
    assertTrue("Should call postLoad callback", fpc.isToCallPostLoadFetchPlan(loadedFields));
    // --------------------------------------
    // fetch group width postLoad + DFG
    // --------------------------------------
    fp.addGroup("groupD");
    fpc = fp.getFetchPlanForClass(cmd);
    loadedFields[cmd.getAbsolutePositionOfMember("piece1")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece2")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece3")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece4")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece5")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece6")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece7")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece8")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece9")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece10")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece11")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece12")] = true;
    assertFalse("Should not call postLoad callback", fpc.isToCallPostLoadFetchPlan(loadedFields));
    loadedFields[cmd.getAbsolutePositionOfMember("piece1")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece2")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece3")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece4")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece5")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece6")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece7")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece8")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece9")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece10")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece11")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece12")] = false;
    assertTrue("Should call postLoad callback", fpc.isToCallPostLoadFetchPlan(loadedFields));
    loadedFields[cmd.getAbsolutePositionOfMember("piece1")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece2")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece3")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece4")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece5")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece6")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece7")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece8")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece9")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece10")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece11")] = false;
    loadedFields[cmd.getAbsolutePositionOfMember("piece12")] = false;
    assertTrue("Should call postLoad callback", fpc.isToCallPostLoadFetchPlan(loadedFields));
    // --------------------------------------
    // fetch group width postLoad
    // --------------------------------------
    fp.addGroup("groupD");
    fp.removeGroup(FetchPlan.DEFAULT);
    fpc = fp.getFetchPlanForClass(cmd);
    loadedFields[cmd.getAbsolutePositionOfMember("piece1")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece2")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece3")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece4")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece5")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece6")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece7")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece8")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece9")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece10")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece11")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece12")] = true;
    assertFalse("Should not call postLoad callback", fpc.isToCallPostLoadFetchPlan(loadedFields));
    loadedFields[cmd.getAbsolutePositionOfMember("piece1")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece2")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece3")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece4")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece5")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece6")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece7")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece8")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece9")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece10")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece11")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece12")] = false;
    assertTrue("Should call postLoad callback", fpc.isToCallPostLoadFetchPlan(loadedFields));
    loadedFields[cmd.getAbsolutePositionOfMember("piece1")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece2")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece3")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece4")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece5")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece6")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece7")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece8")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece9")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece10")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece11")] = false;
    loadedFields[cmd.getAbsolutePositionOfMember("piece12")] = false;
    assertTrue("Should call postLoad callback", fpc.isToCallPostLoadFetchPlan(loadedFields));
    loadedFields[cmd.getAbsolutePositionOfMember("piece1")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece2")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece3")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece4")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece5")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece6")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece7")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece8")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece9")] = false;
    loadedFields[cmd.getAbsolutePositionOfMember("piece10")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece11")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece12")] = true;
    assertFalse("Should not call postLoad callback", fpc.isToCallPostLoadFetchPlan(loadedFields));
    // --------------------------------------
    // fetch group without postLoad
    // --------------------------------------
    fp.addGroup("groupC");
    fp.removeGroup("groupD");
    fp.removeGroup(FetchPlan.DEFAULT);
    fpc = fp.getFetchPlanForClass(cmd);
    loadedFields[cmd.getAbsolutePositionOfMember("piece1")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece2")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece3")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece4")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece5")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece6")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece7")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece8")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece9")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece10")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece11")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece12")] = true;
    assertFalse("Should not call postLoad callback", fpc.isToCallPostLoadFetchPlan(loadedFields));
    loadedFields[cmd.getAbsolutePositionOfMember("piece1")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece2")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece3")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece4")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece5")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece6")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece7")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece8")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece9")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece10")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece11")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece12")] = false;
    assertFalse("Should call postLoad callback", fpc.isToCallPostLoadFetchPlan(loadedFields));
    loadedFields[cmd.getAbsolutePositionOfMember("piece1")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece2")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece3")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece4")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece5")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece6")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece7")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece8")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece9")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece10")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece11")] = false;
    loadedFields[cmd.getAbsolutePositionOfMember("piece12")] = false;
    assertFalse("Should not call postLoad callback", fpc.isToCallPostLoadFetchPlan(loadedFields));
    loadedFields[cmd.getAbsolutePositionOfMember("piece1")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece2")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece3")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece4")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece5")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece6")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece7")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece8")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece9")] = false;
    loadedFields[cmd.getAbsolutePositionOfMember("piece10")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece11")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece12")] = true;
    assertFalse("Should not call postLoad callback", fpc.isToCallPostLoadFetchPlan(loadedFields));
    // --------------------------------------
    // fetch group width postLoad
    // --------------------------------------
    fp.addGroup("groupAll");
    fp.removeGroup("groupC");
    fp.removeGroup(FetchPlan.DEFAULT);
    fpc = fp.getFetchPlanForClass(cmd);
    loadedFields[cmd.getAbsolutePositionOfMember("piece1")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece2")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece3")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece4")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece5")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece6")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece7")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece8")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece9")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece10")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece11")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece12")] = true;
    assertFalse("Should not call postLoad callback", fpc.isToCallPostLoadFetchPlan(loadedFields));
    loadedFields[cmd.getAbsolutePositionOfMember("piece1")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece2")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece3")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece4")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece5")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece6")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece7")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece8")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece9")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece10")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece11")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece12")] = false;
    assertTrue("Should call postLoad callback", fpc.isToCallPostLoadFetchPlan(loadedFields));
    loadedFields[cmd.getAbsolutePositionOfMember("piece1")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece2")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece3")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece4")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece5")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece6")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece7")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece8")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece9")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece10")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece11")] = false;
    loadedFields[cmd.getAbsolutePositionOfMember("piece12")] = false;
    assertTrue("Should call postLoad callback", fpc.isToCallPostLoadFetchPlan(loadedFields));
    loadedFields[cmd.getAbsolutePositionOfMember("piece1")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece2")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece3")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece4")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece5")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece6")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece7")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece8")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece9")] = false;
    loadedFields[cmd.getAbsolutePositionOfMember("piece10")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece11")] = true;
    loadedFields[cmd.getAbsolutePositionOfMember("piece12")] = true;
    assertFalse("Should not call postLoad callback", fpc.isToCallPostLoadFetchPlan(loadedFields));
}
Also used : FetchPlanForClass(org.datanucleus.FetchPlanForClass) JDOMetaDataManager(org.datanucleus.api.jdo.metadata.JDOMetaDataManager) MetaDataManager(org.datanucleus.metadata.MetaDataManager) PersistenceNucleusContextImpl(org.datanucleus.PersistenceNucleusContextImpl) FetchPlan(org.datanucleus.FetchPlan) JDOFetchPlan(org.datanucleus.api.jdo.JDOFetchPlan) JDOMetaDataManager(org.datanucleus.api.jdo.metadata.JDOMetaDataManager) AbstractClassMetaData(org.datanucleus.metadata.AbstractClassMetaData) ClassLoaderResolverImpl(org.datanucleus.ClassLoaderResolverImpl)

Example 10 with JDOMetaDataManager

use of org.datanucleus.api.jdo.metadata.JDOMetaDataManager in project tests by datanucleus.

the class AnnotationTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    nucleusCtx = new PersistenceNucleusContextImpl("JDO", null);
    metaDataMgr = new JDOMetaDataManager(nucleusCtx);
    clr = new ClassLoaderResolverImpl();
}
Also used : PersistenceNucleusContextImpl(org.datanucleus.PersistenceNucleusContextImpl) JDOMetaDataManager(org.datanucleus.api.jdo.metadata.JDOMetaDataManager) ClassLoaderResolverImpl(org.datanucleus.ClassLoaderResolverImpl)

Aggregations

JDOMetaDataManager (org.datanucleus.api.jdo.metadata.JDOMetaDataManager)28 PersistenceNucleusContextImpl (org.datanucleus.PersistenceNucleusContextImpl)27 ClassLoaderResolverImpl (org.datanucleus.ClassLoaderResolverImpl)20 MetaDataManager (org.datanucleus.metadata.MetaDataManager)17 AbstractClassMetaData (org.datanucleus.metadata.AbstractClassMetaData)16 MetaDataParser (org.datanucleus.metadata.xml.MetaDataParser)8 NucleusContext (org.datanucleus.NucleusContext)7 FetchPlan (org.datanucleus.FetchPlan)5 FetchPlanForClass (org.datanucleus.FetchPlanForClass)5 JDOFetchPlan (org.datanucleus.api.jdo.JDOFetchPlan)5 ArrayList (java.util.ArrayList)4 BitSet (java.util.BitSet)4 MetaData (org.datanucleus.metadata.MetaData)4 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 NucleusException (org.datanucleus.exceptions.NucleusException)2 FileMetaData (org.datanucleus.metadata.FileMetaData)2 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1