List of usage examples for org.apache.commons.lang StringUtils center
public static String center(String str, int size, String padStr)
Centers a String in a larger String of size size
.
From source file:org.isatools.isatab.export.isatab.pipeline.IsaTabTableBuilderTest.java
@Test public void testSeparatedSampleFile() { out.println("\n\n" + StringUtils.center(" Testing ISATAB exporter, IsaTabTableBuilder, sample file export ", 120, "-") + "\n"); SeparatedFilesModel pip = new SeparatedFilesModel(); BIIObjectStore store = new BIIObjectStore(); IsaTabTableBuilder tbld = new IsaTabTableBuilder(store, pip.study); out.println(tbld.report());/* ww w .j ava2 s .c o m*/ // TODO: assertions! out.println("\n" + StringUtils.center( " /end: Testing ISATAB exporter, IsaTabTableBuilder, sample file export ", 120, "-") + "\n"); }
From source file:org.isatools.isatab.export.isatab.pipeline.IsaTabTableBuilderTest.java
@Test public void testComments() { out.println("\n\n" + StringUtils.center(" Testing ISATAB exporter, IsaTabTableBuilder, Comments ", 120, "-") + "\n"); FullStudyPipelineModel pip = new FullStudyPipelineModel(); pip.src1.addAnnotation(new Annotation(SMP_ANN_TYPE, "sample.txt")); pip.src2.addAnnotation(new Annotation(SMP_ANN_TYPE, "sample.txt")); pip.as1.addAnnotation(new Annotation(SMP_ANN_TYPE, "sample.txt")); pip.src1.addAnnotation(new Annotation(new AnnotationType("comment:Foo Comment"), "Foo Comment 1.1")); pip.src2.addAnnotation(new Annotation(new AnnotationType("comment:Foo Comment"), "Foo Comment 2.1")); pip.src2.addAnnotation(new Annotation(new AnnotationType("comment:Foo Comment"), "Foo Comment 2.2")); pip.src2.addAnnotation(new Annotation(new AnnotationType("comment:Foo Comment 1"), "Foo Comment 2.3")); BIIObjectStore store = new BIIObjectStore(); IsaTabTableBuilder tbld = new IsaTabTableBuilder(store, pip.study); out.println(tbld.report());// w w w.j ava 2 s .c o m // TODO: assertions! out.println( "\n" + StringUtils.center(" /end: Testing ISATAB exporter, IsaTabTableBuilder, Comments ", 120, "-") + "\n"); }
From source file:org.isatools.isatab.export.isatab.pipeline.LayersBuilderTest.java
@Test public void testComputeLayers() throws Exception { out.println("\n\n" + StringUtils.center(" Testing LayerBuilders.computeAllLayers() ", 120, "-") + "\n"); FullStudyPipelineModel pip = new FullStudyPipelineModel(); pip.as1.addAnnotation(new Annotation( new AnnotationType(ProcessingEntityTabMapper.ASSAY_FILE_ANNOTATION_TAG), FOO_ASSAY_FILE_NAME)); Method testedMethod = LayersBuilder.class.getDeclaredMethod("computeAllLayers"); testedMethod.setAccessible(true);/* www .j a v a 2 s . com*/ LayersBuilder lb = new LayersBuilder(new BIIObjectStore(), pip.study, false, FOO_ASSAY_FILE_NAME); testedMethod.invoke(lb); GraphLayers gls = lb.getGraphLayers(); out.print(gls.report()); assertEquals("Wrong layer for src1", 0, gls.getLayer(pip.nsrc1)); assertEquals("Wrong layer for src2", 0, gls.getLayer(pip.nsrc2)); assertEquals("Wrong layer for p1", 1, gls.getLayer(pip.p1)); assertEquals("Wrong layer for nas1", 2, gls.getLayer(pip.nas1)); assertEquals("Wrong layer for p2", 3, gls.getLayer(pip.p2)); assertEquals("Wrong layer for nar1", 4, gls.getLayer(pip.nar1)); assertEquals("Wrong layer for nar2", 4, gls.getLayer(pip.nar2)); out.println("\n" + StringUtils.center(" /end: Testing LayerBuilders.computeAllLayers() ", 120, "-") + "\n"); }
From source file:org.isatools.isatab.export.isatab.pipeline.LayersBuilderTest.java
@Test public void testComputeTypedLayers() throws Exception { out.println("\n\n" + StringUtils.center(" Testing LayerBuilders.computeTypedLayers() ", 120, "-") + "\n"); FullStudyPipelineModel pip = new FullStudyPipelineModel(); pip.as1.addAnnotation(new Annotation( new AnnotationType(ProcessingEntityTabMapper.ASSAY_FILE_ANNOTATION_TAG), FOO_ASSAY_FILE_NAME)); MaterialRole sampleRole = new MaterialRole("bii:tests:material:sample", "Sample", new ReferenceSource("bii:tests:ontos:foo", "Foo Ontology")); pip.src2.setType(sampleRole);//from w ww . j av a2 s . c o m LayersBuilder lb = new LayersBuilder(new BIIObjectStore(), pip.study, false, FOO_ASSAY_FILE_NAME); boolean isFailed = false; try { GraphLayers gls = lb.getGraphLayers(); } catch (TabUnsupportedException e) { isFailed = true; } assertTrue("typed layers are not supported yet and this test should generate an exception!", isFailed); // TODO: restore when the behavior will be supported // assertEquals ( "Wrong layer for src2", 0, gls.getLayer ( pip.nsrc2 ) ); // assertEquals ( "Wrong layer for src1", 1, gls.getLayer ( pip.nsrc1 ) ); // assertEquals ( "Wrong layer for p1", 2, gls.getLayer ( pip.p1 ) ); // assertEquals ( "Wrong layer for nas1", 3, gls.getLayer ( pip.nas1 ) ); // assertEquals ( "Wrong layer for p2", 4, gls.getLayer ( pip.p2 ) ); // assertEquals ( "Wrong layer for nar1", 5, gls.getLayer ( pip.nar1 ) ); // assertEquals ( "Wrong layer for nar2", 5, gls.getLayer ( pip.nar2 ) ); out.println( "\n" + StringUtils.center(" /end: Testing LayerBuilders.computeTypedLayers() ", 120, "-") + "\n"); }
From source file:org.isatools.isatab.export.isatab.pipeline.LayersBuilderTest.java
@Test public void testSeparatedAssayFile() { out.println("\n\n" + StringUtils.center(" Testing layering of assay file only ", 120, "-") + "\n"); SeparatedFilesModel pip = new SeparatedFilesModel(); pip.as1.addAnnotation(new Annotation( new AnnotationType(ProcessingEntityTabMapper.ASSAY_FILE_ANNOTATION_TAG), FOO_ASSAY_FILE_NAME)); LayersBuilder lb = new LayersBuilder(new BIIObjectStore(), pip.study, false, FOO_ASSAY_FILE_NAME); GraphLayers gls = lb.getGraphLayers(); out.print(gls.report());// ww w. j a va2s . c o m assertEquals("Wrong layer for nsample1", 0, gls.getLayer(pip.nsample1)); assertEquals("Wrong layer for p11", 1, gls.getLayer(pip.p11)); assertEquals("Wrong layer for nas1", 2, gls.getLayer(pip.nas1)); assertEquals("Wrong layer for p2", 3, gls.getLayer(pip.p2)); assertEquals("Wrong layer for nar1", 4, gls.getLayer(pip.nar1)); assertEquals("Wrong layer for nar2", 4, gls.getLayer(pip.nar2)); out.println("\n" + StringUtils.center(" /end: Testing layering of assay file only ", 120, "-") + "\n"); }
From source file:org.isatools.isatab.export.isatab.pipeline.LayersBuilderTest.java
@Test public void testSeparatedSampleFile() { out.println("\n\n" + StringUtils.center(" Testing layering of sample file only ", 120, "-") + "\n"); SeparatedFilesModel pip = new SeparatedFilesModel(); pip.as1.addAnnotation(new Annotation( new AnnotationType(ProcessingEntityTabMapper.ASSAY_FILE_ANNOTATION_TAG), FOO_ASSAY_FILE_NAME)); LayersBuilder lb = new LayersBuilder(new BIIObjectStore(), pip.study); GraphLayers gls = lb.getGraphLayers(); out.print(gls.report());//from w ww . j a v a2 s . c o m assertEquals("Wrong layer for src1", 0, gls.getLayer(pip.nsrc1)); assertEquals("Wrong layer for src2", 0, gls.getLayer(pip.nsrc2)); assertEquals("Wrong layer for p1", 1, gls.getLayer(pip.p1)); assertEquals("Wrong layer for sample1", 2, gls.getLayer(pip.nsample1)); out.println("\n" + StringUtils.center(" /end: Testing layering of sample file only ", 120, "-") + "\n"); }
From source file:org.isatools.isatab.export.sra.SraExportTest.java
@Test public void testBasicExport() throws XmlException { Map<String, String> testData = getTestData(); for (String directory : testData.keySet()) { out.println("\n\n" + StringUtils.center("Testing the SRA exporter with " + directory, 120, "-") + "\n"); System.setProperty("bioinvindex.converters.sra.backlink", "(This study is linked to the BII project, see http://www.ebi.ac.uk/bioinvindex/study.seam?studyId=${study-acc})"); String baseDir = System.getProperty("basedir"); System.out.println("basedir = " + baseDir); String filesPath = baseDir + "/target/test-classes/test-data/isatab/isatab_bii/" + directory; System.out.println("filesPath = " + filesPath); ISATABLoader loader = new ISATABLoader(filesPath); FormatSetInstance isatabInstance = null; try {/*from w ww .j a va2s .c o m*/ isatabInstance = loader.load(); } catch (IOException e) { e.printStackTrace(); } BIIObjectStore store = new BIIObjectStore(); ISATABMapper mapper = new ISATABMapper(store, isatabInstance); mapper.map(); String studyExportPath = baseDir + "/target/export/"; SraExporter sraExporter = new SraExporter(store, filesPath, studyExportPath); sraExporter.export(); System.out.println("exportPath = " + studyExportPath); assertTrue("Ouch! No SRA export directory created for " + directory + ": " + studyExportPath, new File(studyExportPath).exists()); assertTrue("Ouch! No SRA study.xml created", new File(studyExportPath + "/sra/" + testData.get(directory) + "/study.xml").exists()); // Validate the generated XML files try { XmlOptions xopts = new XmlOptions(); xopts.setValidateOnSet(); SubmissionType xsub = SubmissionType.Factory.parse( new File(studyExportPath + "/sra/" + testData.get(directory) + "/submission.xml"), xopts); StudyType xstudy = StudyType.Factory .parse(new File(studyExportPath + "/sra/" + testData.get(directory) + "/study.xml"), xopts); SAMPLESETDocument xsamples = SAMPLESETDocument.Factory.parse( new File(studyExportPath + "/sra/" + testData.get(directory) + "/sample_set.xml"), xopts); EXPERIMENTSETDocument xexps = EXPERIMENTSETDocument.Factory.parse( new File(studyExportPath + "/sra/" + testData.get(directory) + "/experiment_set.xml"), xopts); RUNSETDocument xruns = RUNSETDocument.Factory.parse( new File(studyExportPath + "/sra/" + testData.get(directory) + "/run_set.xml"), xopts); } catch (XmlException ex) { throw new XmlException("Argh! Validation of resulting SRA/XML failed!: " + ex.getMessage(), ex); } catch (IOException e) { e.printStackTrace(); } } // TODO: search (XPath) some items that must be there }
From source file:org.isatools.isatab_v1.converter.ConverterTest.java
@Test public void testConverterWithCastrillo() throws Exception { out.println("\n\n" + StringUtils.center("Testing the converter with Castrillo submissin", 120, "-") + "\n"); String baseDir = System.getProperty("basedir"); String subDir = baseDir + "/target/test-classes/test-data/isatab/isatab_bii/JCastrillo-BII-I-1"; GUIISATABValidator validator = new GUIISATABValidator(); assertFalse("Validator returns ERRROR!", GUIInvokerResult.ERROR == validator.validate(subDir)); BIIObjectStore store = validator.getStore(); assertNotNull("No store created by the validator!", store); GUIISATABConverter converter = new GUIISATABConverter(); GUIInvokerResult result = converter.convert(store, subDir, baseDir + "/target/export"); out.println("Results:"); out.println(validator.report());// w w w. j a v a 2s . c om // TODO: some assertions assertFalse("Converter failed!", GUIInvokerResult.ERROR == result); out.println("\n" + StringUtils.center("/end:Testing the converter with Castrillo submissin", 120, "-") + "\n\n"); }
From source file:org.isatools.isatab_v1.RealCasesTest.java
private void runSingleTest(String isatabPath) throws Exception { String label = "'" + isatabPath + "'"; if (Persister.isLightPersistence()) { label += " (Light Mode)"; }/*from w ww .ja v a2 s .c o m*/ out.println("\n\n" + StringUtils.center(" Real Case Test on " + label, 180, "=-") + "\n"); // initEntityManager ( true ); GUIISATABValidator validator = new GUIISATABValidator(); GUIInvokerResult result = validator.validate(isatabPath); BIIObjectStore store = validator.getStore(); assertFalse("Validation returns an error!", GUIInvokerResult.ERROR.equals(result)); assertTrue("No study loaded, Store is empty!", store.valuesOfType(Study.class).size() > 0); out.println("Loading of " + store.size() + " objects. Result is " + result + ". Now persisting."); GUIISATABLoader loader = new GUIISATABLoader(); result = loader.persist(store, isatabPath); out.println("\n_____ Persistence done. Result is " + result + ". Now unloading."); assertFalse("Peristence returns an error!", GUIInvokerResult.ERROR.equals(result)); String repoPath = baseDir + "/target/bii_test_repo/meta_data"; Study study = store.valueOfType(Study.class); String studyFileName = "study_" + DataLocationManager.getObfuscatedStudyFileName(study); String submissionRepoPath = repoPath + "/" + studyFileName; assertTrue("Oh no! Submission directory not created in the submission repo: " + submissionRepoPath + "!", new File(submissionRepoPath).exists()); session.flush(); GUIISATABUnloader unloader = new GUIISATABUnloader(); result = unloader.unload(store.valuesOfType(Study.class)); out.println("\n_____ Unloading done. Result is " + result + "."); assertFalse("Unloading returns an error!", GUIInvokerResult.ERROR.equals(result)); session.flush(); Query q = entityManager .createQuery("SELECT e FROM " + Identifiable.class.getName() + " e WHERE e.submissionTs = :ts"); q.setParameter("ts", study.getSubmissionTs()); boolean isAllUnloaded = true; for (Object o : q.getResultList()) { out.println("**** Oh No! I have found an entity that should be unloaded! " + o); isAllUnloaded = false; } assertTrue("Sigh! I still have some objects that were not unloaded", isAllUnloaded); assertFalse("Oh no! Submission directory not deleted from the submission repo: " + submissionRepoPath + "!", new File(submissionRepoPath).exists()); out.println("\n" + StringUtils.center(" /end: Real Case Test on " + label, 180, "=-") + "\n"); }
From source file:org.isatools.isatab_v1.validator.ValidatorTest.java
@Test public void testValidatorWithCastrillo() throws Exception { out.println(//from www.j a v a 2 s . c o m "\n\n" + StringUtils.center("Testing the validator with Castrillo submission", 120, "-") + "\n"); String baseDir = System.getProperty("basedir"); String subDir = baseDir + "/target/test-classes/test-data/isatab/isatab_bii/JCastrillo-BII-I-1"; GUIISATABValidator validator = new GUIISATABValidator(); GUIInvokerResult result = validator.validate(subDir); out.println("Results:"); out.println(result == GUIInvokerResult.ERROR ? "Validation failed!" : validator.report()); out.println("Some Log Results:"); List<TabLoggingEventWrapper> log = validator.getLog(); boolean unusedSourceMsgFound = false, unusedFactorMsgFound = false, unusedProtoParamFound = false; int ih = log.size(), il = ih - 10; for (int i = ih - 1; i >= 0; i--) { TabLoggingEventWrapper event = log.get(i); String msg = StringUtils.trimToEmpty(event.getFormattedMessage()); if (i > il) { out.println("LOG EVENT:" + msg); } if (msg.contains( "WARNING: the ontology source '_FOO1_' is declared in the investigation file but never used")) { unusedSourceMsgFound = true; } else if (msg .contains("the factor type '_foo unused factor_' is declared in the investigation file")) { unusedFactorMsgFound = true; } else if (msg.contains( "the parameter 'sample volume' for the protocol 'metabolite extraction' is declared in the investigation file")) { unusedProtoParamFound = true; } } assertEquals("Validation failed!", GUIInvokerResult.SUCCESS, result); assertTrue("Unused ontology source not found by the validator! :-(", unusedSourceMsgFound); assertTrue("Unused factor not found by the validator! :-(", unusedFactorMsgFound); assertTrue("Unused protocol parameter not found by the validator! :-(", unusedProtoParamFound); out.println("\n" + StringUtils.center("/end:Testing the validator with Castrillo submission", 120, "-") + "\n\n"); }