Example usage for org.apache.commons.lang StringUtils center

List of usage examples for org.apache.commons.lang StringUtils center

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils center.

Prototype

public static String center(String str, int size, String padStr) 

Source Link

Document

Centers a String in a larger String of size size.

Usage

From source file:org.isatools.isatab_v1.validator.ValidatorTest.java

@Test
public void testValidatorDupeFiles() throws Exception {
    out.println("\n\n" + StringUtils.center("Testing validator for the dupe files case", 120, "-") + "\n");

    String baseDir = System.getProperty("basedir");
    String subDir = baseDir + "/target/test-classes/test-data/isatab/isatab_bii/JCastrillo-BII-I-1_duped_files";

    GUIISATABValidator validator = new GUIISATABValidator();
    GUIInvokerResult result = validator.validate(subDir);

    assertEquals("Validation should have failed!", GUIInvokerResult.ERROR, result);

    out.println("\n" + StringUtils.center("/end:Testing validator for the dupe files case", 120, "-") + "\n\n");
}

From source file:org.isatools.isatab_v1.validator.ValidatorTest.java

@Test
public void testValidatorFieldOrder() throws Exception {
    out.println(// www  .j  a  va2 s  .  com
            "\n\n" + StringUtils.center("Testing validator for the wrong field order case", 120, "-") + "\n");

    String baseDir = System.getProperty("basedir");
    String subDir = baseDir
            + "/target/test-classes/test-data/isatab/isatab_bii/JCastrillo-BII-I-1_wrong_field_order";

    GUIISATABValidator validator = new GUIISATABValidator();

    GUIInvokerResult result = validator.validate(subDir);
    assertEquals("Validation should have failed!", GUIInvokerResult.ERROR, result);

    out.println("\n" + StringUtils.center("/end:Testing validator for the wrong field order case", 120, "-")
            + "\n\n");
}

From source file:org.isatools.tablib.utils.logging.TabAppenderTest.java

@Test
@SuppressWarnings("static-access")
public void testTabAppender() {
    out.println("\n" + StringUtils.center(" Testing TabAppender ", 120, "-"));

    Logger log = Logger.getLogger(TabAppenderTest.class);
    // This is necessary in order to override external config.
    log.setLevel(Level.ALL);// w w w.j av  a2s .  c  o m

    ListTabAppender app = new ListTabAppender();
    final String APP_NAME = "testTabAppender";
    app.setName(APP_NAME);
    app.setLayout(new PatternLayout("%d {%x} [%-5p] (%C{1},%L): %m%n"));
    app.setThreshold(Level.ALL);

    Logger rootLog = log.getRootLogger();
    rootLog.setLevel(Level.ALL);
    rootLog.addAppender(app);

    TabNDC ndc = TabNDC.getInstance();
    int ct = 0;
    ndc.pushFormat("fooFormat", "A Foo Test Format", "some/path");
    log.debug("A debug message");
    ct++;
    log.info("An info message");
    ct++;
    Study study = new Study("Test Study");
    study.setAcc("TEST:S:01");
    ndc.pushObject(study);
    log.warn("A warn message ");
    ct++;
    log.warn("Another warn message");
    ct++;
    ndc.popObject();
    log.trace("Debug message, one step back in the NDC");
    ct++;
    ndc.popTabDescriptor();

    ListTabAppender app1 = (ListTabAppender) log.getRootLogger().getAppender(APP_NAME);
    assertTrue("log4j is not returing the correct appender!", app1 == app);

    List<TabLoggingEventWrapper> tlog = app1.getOutput();
    for (TabLoggingEventWrapper tevent : tlog) {
        out.println("TAB CONTEXT: " + tevent.getTabDescriptors());
        out.println("OBJECTS: " + TabNDC.getObjectDescriptions(tevent.getObjects()));
        out.println(tevent.getFormattedMessage());
        out.println(StringUtils.repeat("-", 120) + "\n");
    }

    assertEquals("Wrong no of recorded messages!", ct, tlog.size());

    out.println(StringUtils.center(" /end:Testing TabAppender ", 120, "-") + "\n\n");
}

From source file:uk.ac.ebi.bioinvindex.unloading.PipelineUnloadingTest.java

@Test
public void testBasics() {
    out.println("\n\n" + StringUtils.center(" Testing ISATAB unloader, basiscs ", 120, "-") + "\n");

    SimplePipelineModel pip = new SimplePipelineModel();

    Timestamp ts = new Timestamp(System.currentTimeMillis());
    StudyPersister studyPersister = new StudyPersister(daoFactory, ts);
    AssayMaterialPersister assayMaterialPersister = new AssayMaterialPersister(daoFactory, ts);
    studyPersister.persist(pip.study);//  w  w w .j a v a  2  s .c o m
    assayMaterialPersister.persist(pip.assayMaterial1);
    commitTansaction();
    session.flush();

    AccessibleDAO<Accessible> adao = daoFactory.getAccessibleDAO(Accessible.class);
    OntologyEntryDAO<OntologyEntry> oedao = daoFactory.getOntologyEntryDAO();

    assertNotNull("Ops! nsrc1 not saved!", adao.getByAcc(pip.nsrc1.getAcc()));
    assertNotNull("Ops! nsrc2 not saved!", adao.getByAcc(pip.nsrc2.getAcc()));
    assertNotNull("Ops! p1 not saved!", adao.getByAcc(pip.p1.getAcc()));
    assertNotNull("Ops! nas1 not saved!", adao.getByAcc(pip.nas1.getAcc()));
    assertNotNull("Ops! p2 not saved!", adao.getByAcc(pip.p2.getAcc()));
    assertNotNull("Ops! nar1 not saved!", adao.getByAcc(pip.nar1.getAcc()));
    assertNotNull("Ops! src1 not saved!", adao.getByAcc(pip.src1.getAcc()));
    assertNotNull("Ops! src2 not saved!", adao.getByAcc(pip.src2.getAcc()));
    assertNotNull("Ops! assay1 not saved!", adao.getByAcc(pip.assayMaterial1.getAcc()));
    assertNotNull("Ops! dt1 not saved!", adao.getByAcc(pip.dt1.getAcc()));
    assertNotNull("Ops! dt2 not saved!", adao.getByAcc(pip.dt2.getAcc()));
    assertNotNull("Ops! cv1 not saved!", pip.cv1.getId());
    assertNotNull("Ops! cv1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.cv1.getClass()).getById(pip.cv1.getId()));
    assertNotNull("Ops! cv2 not saved!", pip.cv2.getId());
    assertNotNull("Ops! cv2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.cv2.getClass()).getById(pip.cv2.getId()));
    assertNotNull("Ops! fv1 not saved!", pip.fv1.getId());
    assertNotNull("Ops! fv1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.fv1.getClass()).getById(pip.fv1.getId()));
    assertNotNull("Ops! fv2 not saved!", pip.fv2.getId());
    assertNotNull("Ops! fv2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.fv2.getClass()).getById(pip.fv2.getId()));
    assertNotNull("Ops! c1 not saved!", pip.c1.getId());
    assertNotNull("Ops! c1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.c1.getClass()).getById(pip.c1.getId()));
    assertNotNull("Ops! c2 not saved!", pip.c2.getId());
    assertNotNull("Ops! c2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.c2.getClass()).getById(pip.c2.getId()));
    assertNotNull("Ops! fact1 not saved!", pip.fact1.getId());
    assertNotNull("Ops! fact1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.fact1.getClass()).getById(pip.fact1.getId()));
    assertNotNull("Ops! fact2 not saved!", pip.fact2.getId());
    assertNotNull("Ops! fact2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.fact2.getClass()).getById(pip.fact2.getId()));
    assertNotNull("Ops! cv2UnitVal not saved!", pip.cv2UnitVal.getId());
    assertNotNull("Ops! cv2UnitVal not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.cv2UnitVal.getClass()).getById(pip.cv2UnitVal.getId()));
    assertNotNull("Ops! cv2Unit not saved!", pip.cv2Unit.getId());
    assertNotNull("Ops! cv2Unit not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.cv2Unit.getClass()).getById(pip.cv2Unit.getId()));
    ReferenceSource fooOntoDB = (ReferenceSource) adao.getByAcc(pip.fooOnto.getAcc());
    assertNotNull("Ops! fooOnto not saved!", fooOntoDB);
    assertEquals("Ops! fooOnto #ID is wrong!", -1L, fooOntoDB.getId().longValue());
    assertNotNull("Ops! srcRole not saved!", oedao.getByAcc(pip.srcRole.getAcc()));
    assertNotNull("Ops! assayRole not saved!", oedao.getByAcc(pip.assayRole.getAcc()));
    assertNotNull("Ops! dataType not saved!", oedao.getByAcc(pip.dataType.getAcc()));
    OntologyEntry c1OtDB = oedao.getByAcc(pip.c1Ot.getAcc());
    assertNotNull("Ops! fooOnto not saved!", c1OtDB);
    assertEquals("Ops! fooOnto #ID is wrong!", -1L, c1OtDB.getId().longValue());

    transaction.begin();
    UnloadManager unloaderMgr = new UnloadManager(DaoFactory.getInstance(entityManager), ts);
    StudyUnloader unloader = (StudyUnloader) unloaderMgr.getUnloader(Study.class);
    unloader.queueByAcc(pip.study.getAcc());
    unloaderMgr.delete();
    transaction.commit();
    session.flush();
    out.println("\n ====> Unloading done,  Warnings/Errors: " + unloaderMgr.getMessages());

    checkAllUnloaded(ts);

    out.println("\n" + StringUtils.center(" /end: Testing ISATAB unloader, basiscs ", 120, "-") + "\n");

}

From source file:uk.ac.ebi.bioinvindex.unloading.PipelineUnloadingTest.java

@Test
public void testWithProtocols() {
    out.println("\n\n" + StringUtils.center(" Testing ISATAB unloader, study+protocols ", 120, "-") + "\n");

    ProtocolEquippedModel pip = new ProtocolEquippedModel();

    Timestamp ts = new Timestamp(System.currentTimeMillis());
    StudyPersister studyPersister = new StudyPersister(daoFactory, ts);
    AssayMaterialPersister assayMaterialPersister = new AssayMaterialPersister(daoFactory, ts);
    studyPersister.persist(pip.study);/*from   www  .j av a2s .  c o  m*/
    assayMaterialPersister.persist(pip.assayMaterial1);
    commitTansaction();
    session.flush();

    AccessibleDAO<Accessible> adao = daoFactory.getAccessibleDAO(Accessible.class);
    OntologyEntryDAO<OntologyEntry> oedao = daoFactory.getOntologyEntryDAO();

    assertNotNull("Ops! nsrc1 not saved!", adao.getByAcc(pip.nsrc1.getAcc()));
    assertNotNull("Ops! nsrc2 not saved!", adao.getByAcc(pip.nsrc2.getAcc()));
    assertNotNull("Ops! p1 not saved!", adao.getByAcc(pip.p1.getAcc()));
    assertNotNull("Ops! nas1 not saved!", adao.getByAcc(pip.nas1.getAcc()));
    assertNotNull("Ops! p2 not saved!", adao.getByAcc(pip.p2.getAcc()));
    assertNotNull("Ops! nar1 not saved!", adao.getByAcc(pip.nar1.getAcc()));
    assertNotNull("Ops! src1 not saved!", adao.getByAcc(pip.src1.getAcc()));
    assertNotNull("Ops! src2 not saved!", adao.getByAcc(pip.src2.getAcc()));
    assertNotNull("Ops! assay1 not saved!", adao.getByAcc(pip.assayMaterial1.getAcc()));
    assertNotNull("Ops! dt1 not saved!", adao.getByAcc(pip.dt1.getAcc()));
    assertNotNull("Ops! dt2 not saved!", adao.getByAcc(pip.dt2.getAcc()));
    assertNotNull("Ops! cv1 not saved!", pip.cv1.getId());
    assertNotNull("Ops! cv1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.cv1.getClass()).getById(pip.cv1.getId()));
    assertNotNull("Ops! cv2 not saved!", pip.cv2.getId());
    assertNotNull("Ops! cv2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.cv2.getClass()).getById(pip.cv2.getId()));
    assertNotNull("Ops! fv1 not saved!", pip.fv1.getId());
    assertNotNull("Ops! fv1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.fv1.getClass()).getById(pip.fv1.getId()));
    assertNotNull("Ops! fv2 not saved!", pip.fv2.getId());
    assertNotNull("Ops! fv2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.fv2.getClass()).getById(pip.fv2.getId()));
    assertNotNull("Ops! c1 not saved!", pip.c1.getId());
    assertNotNull("Ops! c1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.c1.getClass()).getById(pip.c1.getId()));
    assertNotNull("Ops! c2 not saved!", pip.c2.getId());
    assertNotNull("Ops! c2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.c2.getClass()).getById(pip.c2.getId()));
    assertNotNull("Ops! fact1 not saved!", pip.fact1.getId());
    assertNotNull("Ops! fact1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.fact1.getClass()).getById(pip.fact1.getId()));
    assertNotNull("Ops! fact2 not saved!", pip.fact2.getId());
    assertNotNull("Ops! fact2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.fact2.getClass()).getById(pip.fact2.getId()));

    assertNotNull("Ops! cv2UnitVal not saved!", pip.cv2UnitVal.getId());
    assertNotNull("Ops! cv1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.cv2UnitVal.getClass()).getById(pip.cv2UnitVal.getId()));
    assertNotNull("Ops! cv2Unit not saved!", pip.cv2Unit.getId());
    assertNotNull("Ops! cv1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.cv2Unit.getClass()).getById(pip.cv2Unit.getId()));
    assertNotNull("Ops! paramv1 not saved!", pip.paramv1.getId());
    assertNotNull("Ops! paramv1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.paramv1.getClass()).getById(pip.paramv1.getId()));
    assertNotNull("Ops! paramv2 not saved!", pip.paramv2.getId());
    assertNotNull("Ops! paramv2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.paramv2.getClass()).getById(pip.paramv2.getId()));
    assertNotNull("Ops! param1 not saved!", pip.param1.getId());
    assertNotNull("Ops! param1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.param1.getClass()).getById(pip.param1.getId()));
    assertNotNull("Ops! param2 not saved!", pip.param2.getId());
    assertNotNull("Ops! param2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.param2.getClass()).getById(pip.param2.getId()));
    assertNotNull("Ops! paramv2UnitVal not saved!", pip.paramv2UnitVal.getId());
    assertNotNull("Ops! paramv2UnitVal not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.paramv2UnitVal.getClass()).getById(pip.paramv2UnitVal.getId()));
    assertNotNull("Ops! paramv2Unit not saved!", pip.paramv2Unit.getId());
    assertNotNull("Ops! paramv2Unit not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.paramv2Unit.getClass()).getById(pip.paramv2Unit.getId()));

    assertNotNull("Ops! proto1 not saved!", adao.getByAcc(pip.proto1.getAcc()));
    assertNotNull("Ops! proto2 not saved!", adao.getByAcc(pip.proto2.getAcc()));

    ReferenceSource fooOntoDB = (ReferenceSource) adao.getByAcc(pip.fooOnto.getAcc());
    assertNotNull("Ops! fooOnto not saved!", fooOntoDB);
    assertEquals("Ops! fooOnto #ID is wrong!", -1L, fooOntoDB.getId().longValue());
    assertNotNull("Ops! srcRole not saved!", oedao.getByAcc(pip.srcRole.getAcc()));
    assertNotNull("Ops! assayRole not saved!", oedao.getByAcc(pip.assayRole.getAcc()));
    assertNotNull("Ops! dataType not saved!", oedao.getByAcc(pip.dataType.getAcc()));
    OntologyEntry c1OtDB = oedao.getByAcc(pip.c1Ot.getAcc());
    assertNotNull("Ops! fooOnto not saved!", c1OtDB);
    assertEquals("Ops! fooOnto #ID is wrong!", -1L, c1OtDB.getId().longValue());

    transaction.begin();
    UnloadManager unloaderMgr = new UnloadManager(DaoFactory.getInstance(entityManager), ts);
    StudyUnloader unloader = (StudyUnloader) unloaderMgr.getUnloader(Study.class);
    unloader.queueByAcc(pip.study.getAcc());
    unloaderMgr.delete();
    transaction.commit();
    session.flush();
    out.println("\n ====> Unloading done,  Warnings/Errors: " + unloaderMgr.getMessages());

    checkAllUnloaded(ts);

    out.println("\n" + StringUtils.center(" /end: Testing ISATAB unloader, study+protocols ", 120, "-") + "\n");
}

From source file:uk.ac.ebi.bioinvindex.unloading.PipelineUnloadingTest.java

@Test
public void testFullStudy() {
    out.println("\n\n" + StringUtils.center(" Testing ISATAB unloader, study+protocols+assays+ARs ", 120, "-")
            + "\n");

    FullStudyPipelineModel pip = new FullStudyPipelineModel();

    Timestamp ts = new Timestamp(System.currentTimeMillis());
    StudyPersister studyPersister = new StudyPersister(daoFactory, ts);
    studyPersister.persist(pip.study);/*from   w ww  . j a  v a2s  .c  o  m*/
    commitTansaction();
    session.flush();

    AccessibleDAO<Accessible> adao = daoFactory.getAccessibleDAO(Accessible.class);
    OntologyEntryDAO<OntologyEntry> oedao = daoFactory.getOntologyEntryDAO();

    assertNotNull("Ops! nsrc1 not saved!", adao.getByAcc(pip.nsrc1.getAcc()));
    assertNotNull("Ops! nsrc2 not saved!", adao.getByAcc(pip.nsrc2.getAcc()));
    assertNotNull("Ops! p1 not saved!", adao.getByAcc(pip.p1.getAcc()));
    assertNotNull("Ops! nas1 not saved!", adao.getByAcc(pip.nas1.getAcc()));
    assertNotNull("Ops! p2 not saved!", adao.getByAcc(pip.p2.getAcc()));
    assertNotNull("Ops! nar1 not saved!", adao.getByAcc(pip.nar1.getAcc()));
    assertNotNull("Ops! src1 not saved!", adao.getByAcc(pip.src1.getAcc()));
    assertNotNull("Ops! src2 not saved!", adao.getByAcc(pip.src2.getAcc()));
    assertNotNull("Ops! assay1 not saved!", adao.getByAcc(pip.assayMaterial1.getAcc()));
    assertNotNull("Ops! dt1 not saved!", adao.getByAcc(pip.dt1.getAcc()));
    assertNotNull("Ops! dt2 not saved!", adao.getByAcc(pip.dt2.getAcc()));
    assertNotNull("Ops! cv1 not saved!", pip.cv1.getId());
    assertNotNull("Ops! cv1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.cv1.getClass()).getById(pip.cv1.getId()));
    assertNotNull("Ops! cv2 not saved!", pip.cv2.getId());
    assertNotNull("Ops! cv2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.cv2.getClass()).getById(pip.cv2.getId()));
    assertNotNull("Ops! fv1 not saved!", pip.fv1.getId());
    assertNotNull("Ops! fv1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.fv1.getClass()).getById(pip.fv1.getId()));
    assertNotNull("Ops! fv2 not saved!", pip.fv2.getId());
    assertNotNull("Ops! fv2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.fv2.getClass()).getById(pip.fv2.getId()));

    assertNotNull("Ops! c1 not saved!", pip.c1.getId());
    assertNotNull("Ops! c1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.c1.getClass()).getById(pip.c1.getId()));
    assertNotNull("Ops! c2 not saved!", pip.c2.getId());
    assertNotNull("Ops! c2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.c2.getClass()).getById(pip.c2.getId()));
    assertNotNull("Ops! fact1 not saved!", pip.fact1.getId());
    assertNotNull("Ops! fact1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.fact1.getClass()).getById(pip.fact1.getId()));
    assertNotNull("Ops! fact2 not saved!", pip.fact2.getId());
    assertNotNull("Ops! fact2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.fact2.getClass()).getById(pip.fact2.getId()));

    assertNotNull("Ops! cv2UnitVal not saved!", pip.cv2UnitVal.getId());
    assertNotNull("Ops! cv1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.cv2UnitVal.getClass()).getById(pip.cv2UnitVal.getId()));
    assertNotNull("Ops! cv2Unit not saved!", pip.cv2Unit.getId());
    assertNotNull("Ops! cv1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.cv2Unit.getClass()).getById(pip.cv2Unit.getId()));

    assertNotNull("Ops! paramv1 not saved!", pip.paramv1.getId());
    assertNotNull("Ops! paramv1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.paramv1.getClass()).getById(pip.paramv1.getId()));
    assertNotNull("Ops! paramv2 not saved!", pip.paramv2.getId());
    assertNotNull("Ops! paramv2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.paramv2.getClass()).getById(pip.paramv2.getId()));
    assertNotNull("Ops! param1 not saved!", pip.param1.getId());
    assertNotNull("Ops! param1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.param1.getClass()).getById(pip.param1.getId()));
    assertNotNull("Ops! param2 not saved!", pip.param2.getId());
    assertNotNull("Ops! param2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.param2.getClass()).getById(pip.param2.getId()));
    assertNotNull("Ops! paramv2UnitVal not saved!", pip.paramv2UnitVal.getId());
    assertNotNull("Ops! paramv2UnitVal not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.paramv2UnitVal.getClass()).getById(pip.paramv2UnitVal.getId()));
    assertNotNull("Ops! paramv2Unit not saved!", pip.paramv2Unit.getId());
    assertNotNull("Ops! paramv2Unit not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.paramv2Unit.getClass()).getById(pip.paramv2Unit.getId()));

    assertNotNull("Ops! proto1 not saved!", adao.getByAcc(pip.proto1.getAcc()));
    assertNotNull("Ops! proto2 not saved!", adao.getByAcc(pip.proto2.getAcc()));

    ReferenceSource fooOntoDB = (ReferenceSource) adao.getByAcc(pip.fooOnto.getAcc());
    assertNotNull("Ops! fooOnto not saved!", fooOntoDB);
    assertEquals("Ops! fooOnto #ID is wrong!", -1L, fooOntoDB.getId().longValue());
    assertNotNull("Ops! srcRole not saved!", oedao.getByAcc(pip.srcRole.getAcc()));
    assertNotNull("Ops! assayRole not saved!", oedao.getByAcc(pip.assayRole.getAcc()));
    assertNotNull("Ops! dataType not saved!", oedao.getByAcc(pip.dataType.getAcc()));
    OntologyEntry c1OtDB = (OntologyEntry) oedao.getByAcc(pip.c1Ot.getAcc());
    assertNotNull("Ops! fooOnto not saved!", c1OtDB);
    assertEquals("Ops! fooOnto #ID is wrong!", -1L, c1OtDB.getId().longValue());

    assertNotNull("Ops! as1 not saved!", adao.getByAcc(pip.as1.getAcc()));
    assertNotNull("Ops! ar1 not saved!", pip.ar1.getId());
    assertNotNull("Ops! ar1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.ar1.getClass()).getById(pip.ar1.getId()));
    assertNotNull("Ops! ar2 not saved!", pip.ar2.getId());
    assertNotNull("Ops! ar2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.ar2.getClass()).getById(pip.ar2.getId()));

    for (PropertyValue<?> pv : pip.ar1.getCascadedPropertyValues()) {
        assertNotNull("Ops! pv not saved!", pv.getId());
        assertNotNull("Ops! pv not saved (retrieval test)!",
                daoFactory.getIdentifiableDAO(pv.getClass()).getById(pv.getId()));
    }

    for (PropertyValue<?> pv : pip.ar2.getCascadedPropertyValues()) {
        assertNotNull("Ops! pv not saved!", pv.getId());
        assertNotNull("Ops! pv not saved (retrieval test)!",
                daoFactory.getIdentifiableDAO(pv.getClass()).getById(pv.getId()));
    }

    assertTrue("Ops! ar1 does not contain fv1", pip.ar1.getCascadedPropertyValues().contains(pip.fv1));
    assertTrue("Ops! ar1 does not contain fv2", pip.ar1.getCascadedPropertyValues().contains(pip.fv2));

    transaction.begin();
    UnloadManager unloaderMgr = new UnloadManager(DaoFactory.getInstance(entityManager), ts);
    StudyUnloader unloader = (StudyUnloader) unloaderMgr.getUnloader(Study.class);
    unloader.queueByAcc(pip.study.getAcc());
    unloaderMgr.delete();
    transaction.commit();
    session.flush();
    out.println("\n ====> Unloading done,  Warnings/Errors: " + unloaderMgr.getMessages());

    checkAllUnloaded(ts);

    out.println(
            "\n" + StringUtils.center(" /end: Testing ISATAB unloader, study+protocols+assays+ARs ", 120, "-")
                    + "\n");
}

From source file:uk.ac.ebi.bioinvindex.unloading.PipelineUnloadingTest.java

@Test
public void testLightPersistence() {
    out.println("\n\n" + StringUtils.center(" Testing ISATAB unloader, Light Persistence ", 120, "-") + "\n");

    System.setProperty(Persister.LIGHT_PERSISTENCE_PROPERTY, "true");

    FullStudyPipelineModel pip = new FullStudyPipelineModel();

    Timestamp ts = new Timestamp(System.currentTimeMillis());
    StudyPersister studyPersister = new StudyPersister(daoFactory, ts);
    studyPersister.persist(pip.study);/*  w w w.j  av  a 2 s. c  o m*/
    commitTansaction();
    session.flush();

    AccessibleDAO<Accessible> adao = daoFactory.getAccessibleDAO(Accessible.class);
    OntologyEntryDAO<OntologyEntry> oedao = daoFactory.getOntologyEntryDAO();

    assertNotNull("Ops! cv1 not saved!", pip.cv1.getId());
    assertNotNull("Ops! cv1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.cv1.getClass()).getById(pip.cv1.getId()));
    assertNotNull("Ops! cv2 not saved!", pip.cv2.getId());
    assertNotNull("Ops! cv2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.cv2.getClass()).getById(pip.cv2.getId()));
    assertNotNull("Ops! fv1 not saved!", pip.fv1.getId());
    assertNotNull("Ops! fv1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.fv1.getClass()).getById(pip.fv1.getId()));
    assertNotNull("Ops! fv2 not saved!", pip.fv2.getId());
    assertNotNull("Ops! fv2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.fv2.getClass()).getById(pip.fv2.getId()));

    assertNotNull("Ops! c1 not saved!", pip.c1.getId());
    assertNotNull("Ops! c1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.c1.getClass()).getById(pip.c1.getId()));
    assertNotNull("Ops! c2 not saved!", pip.c2.getId());
    assertNotNull("Ops! c2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.c2.getClass()).getById(pip.c2.getId()));
    assertNotNull("Ops! fact1 not saved!", pip.fact1.getId());
    assertNotNull("Ops! fact1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.fact1.getClass()).getById(pip.fact1.getId()));
    assertNotNull("Ops! fact2 not saved!", pip.fact2.getId());
    assertNotNull("Ops! fact2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.fact2.getClass()).getById(pip.fact2.getId()));

    assertNotNull("Ops! cv2UnitVal not saved!", pip.cv2UnitVal.getId());
    assertNotNull("Ops! cv1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.cv2UnitVal.getClass()).getById(pip.cv2UnitVal.getId()));
    assertNotNull("Ops! cv2Unit not saved!", pip.cv2Unit.getId());
    assertNotNull("Ops! cv1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.cv2Unit.getClass()).getById(pip.cv2Unit.getId()));

    assertNotNull("Ops! proto1 not saved!", adao.getByAcc(pip.proto1.getAcc()));
    assertNotNull("Ops! proto2 not saved!", adao.getByAcc(pip.proto2.getAcc()));

    ReferenceSource fooOntoDB = (ReferenceSource) adao.getByAcc(pip.fooOnto.getAcc());
    assertNotNull("Ops! fooOnto not saved!", fooOntoDB);
    assertEquals("Ops! fooOnto #ID is wrong!", -1L, fooOntoDB.getId().longValue());
    OntologyEntry c1OtDB = (OntologyEntry) oedao.getByAcc(pip.c1Ot.getAcc());
    assertNotNull("Ops! fooOnto not saved!", c1OtDB);
    assertEquals("Ops! fooOnto #ID is wrong!", -1L, c1OtDB.getId().longValue());

    assertNotNull("Ops! as1 not saved!", adao.getByAcc(pip.as1.getAcc()));
    assertNotNull("Ops! ar1 not saved!", pip.ar1.getId());
    assertNotNull("Ops! ar1 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.ar1.getClass()).getById(pip.ar1.getId()));
    assertNotNull("Ops! ar2 not saved!", pip.ar2.getId());
    assertNotNull("Ops! ar2 not saved (retrieval test)!",
            daoFactory.getIdentifiableDAO(pip.ar2.getClass()).getById(pip.ar2.getId()));

    for (PropertyValue<?> pv : pip.ar1.getCascadedPropertyValues()) {
        assertNotNull("Ops! pv not saved!", pv.getId());
        assertNotNull("Ops! pv not saved (retrieval test)!",
                daoFactory.getIdentifiableDAO(pv.getClass()).getById(pv.getId()));
    }

    for (PropertyValue<?> pv : pip.ar2.getCascadedPropertyValues()) {
        assertNotNull("Ops! pv not saved!", pv.getId());
        assertNotNull("Ops! pv not saved (retrieval test)!",
                daoFactory.getIdentifiableDAO(pv.getClass()).getById(pv.getId()));
    }

    assertTrue("Ops! ar1 does not contain fv1", pip.ar1.getCascadedPropertyValues().contains(pip.fv1));
    assertTrue("Ops! ar1 does not contain fv2", pip.ar1.getCascadedPropertyValues().contains(pip.fv2));

    transaction.begin();
    UnloadManager unloaderMgr = new UnloadManager(DaoFactory.getInstance(entityManager), ts);
    StudyUnloader unloader = (StudyUnloader) unloaderMgr.getUnloader(Study.class);
    unloader.queueByAcc(pip.study.getAcc());
    unloaderMgr.delete();
    transaction.commit();
    session.flush();
    out.println("\n ====> Unloading done,  Warnings/Errors: " + unloaderMgr.getMessages());

    checkAllUnloaded(ts);

    out.println(
            "\n" + StringUtils.center(" /end: Testing ISATAB unloader, study+protocols+assays+ARs ", 120, "-")
                    + "\n");
}