Revision 553a4aea
Added by Andreas Müller almost 5 years ago
cdmlib-commons/src/test/java/eu/etaxonomy/cdm/common/CdmUtilsTest.java | ||
---|---|---|
18 | 18 |
import org.apache.log4j.Level; |
19 | 19 |
import org.apache.log4j.Logger; |
20 | 20 |
import org.junit.After; |
21 |
import org.junit.AfterClass; |
|
22 | 21 |
import org.junit.Assert; |
23 | 22 |
import org.junit.Before; |
24 |
import org.junit.BeforeClass; |
|
25 | 23 |
import org.junit.Test; |
26 | 24 |
|
27 | 25 |
/** |
... | ... | |
32 | 30 |
public class CdmUtilsTest { |
33 | 31 |
private static final Logger logger = Logger.getLogger(CdmUtilsTest.class); |
34 | 32 |
|
35 |
@BeforeClass |
|
36 |
public static void setUpBeforeClass() throws Exception { |
|
37 |
} |
|
38 |
|
|
39 |
@AfterClass |
|
40 |
public static void tearDownAfterClass() throws Exception { |
|
41 |
} |
|
42 | 33 |
|
43 | 34 |
@Before |
44 | 35 |
public void setUp() throws Exception { |
... | ... | |
116 | 107 |
|
117 | 108 |
} |
118 | 109 |
|
110 |
/** |
|
111 |
* This test can be used for functional testing of any task but should |
|
112 |
* never be committed when failing. |
|
113 |
*/ |
|
114 |
@Test |
|
115 |
public void testSomething(){ |
|
116 |
String MCL = "MCL[0-9]{1,3}(\\-[0-9]{1,4}(\\-[0-9]{1,4}(\\-[0-9]{1,3}(\\-[0-9]{1,3})?)?)?)?"; |
|
117 |
// String MCL = "a{1,3}"; |
|
118 |
String filter = "Acc "+MCL; |
|
119 |
|
|
120 |
String notes = "Acc: 0x is Hieracium djimilense subsp. neotericum Zahn MCL293-3140-00-630"; |
|
121 |
String result; |
|
122 |
if (notes.matches("Acc:.*")){ |
|
123 |
if (notes.matches("Acc: .*\\$$") || (notes.matches("Acc: .*"+MCL))){ |
|
124 |
result = null; |
|
125 |
}else if (notes.matches("Acc: .*(\\$|"+MCL+")\\s*\\{.*\\}")){ |
|
126 |
notes = notes.substring(notes.indexOf("{")+1, notes.length()-1); |
|
127 |
result = notes; |
|
128 |
}else if (notes.matches("Acc: .*(\\$|"+MCL+")\\s*\\[.*\\]")){ |
|
129 |
notes = notes.substring(notes.indexOf("[")+1, notes.length()-1); |
|
130 |
result = notes; |
|
131 |
}else{ |
|
132 |
logger.warn("Namenote: " + notes); |
|
133 |
result = notes; |
|
134 |
} |
|
135 |
}else if (notes.matches("Syn:.*")){ |
|
136 |
if (notes.matches("Syn: .*\\$$") || (notes.matches("Syn: .*"+MCL))){ |
|
137 |
result = null; |
|
138 |
}else if (notes.matches("Syn: .*(\\$|"+MCL+")\\s*\\{.*\\}")){ |
|
139 |
notes = notes.substring(notes.indexOf("{")+1, notes.length()-1); |
|
140 |
result = notes; |
|
141 |
}else if (notes.matches("Syn: .*(\\$|"+MCL+")\\s*\\[.*\\]")){ |
|
142 |
notes = notes.substring(notes.indexOf("[")+1, notes.length()-1); |
|
143 |
result = notes; |
|
144 |
}else{ |
|
145 |
logger.warn("Namenote: " + notes); |
|
146 |
result = notes; |
|
147 |
} |
|
148 |
}else{ |
|
149 |
result = notes; |
|
150 |
} |
|
151 |
System.out.println(result); |
|
152 |
} |
|
153 |
|
|
119 | 154 |
} |
Also available in: Unified diff
cleanup and add test for any functional testing