@@ -46,6 +46,9 @@ public class LangevinResultsReadTest {
4646 private static File langevin_input_file ;
4747 private static File messaging_config_file ;
4848
49+ private static File euler_log_file ;
50+ private static File euler_ode_file ;
51+
4952 // results for first task in the batch, named to match single run file (ending in "_") ex: SimID_303404574_0_
5053 private static File ida_0_file ;
5154 // log produced by the solver for first task in the batch, named using the normal convention ex: SimID_303404574_0_0.log
@@ -56,6 +59,8 @@ public class LangevinResultsReadTest {
5659 // SimID_303404574_0_.ida
5760 private static File log_data_file ;
5861
62+ // resource location of files for various test cases
63+ private static String resourceBase = null ;
5964
6065 @ BeforeAll
6166 public static void setUp () throws IOException {
@@ -71,6 +76,7 @@ public static void setUp() throws IOException {
7176 throw new IOException ("Failed to create subdirectory: " + localSimDir .getAbsolutePath ());
7277 }
7378
79+ resourceBase = "cbit/vcell/simdata/langevin/batch/" ;
7480 functions_file = copyToPrimaryDir ("SimID_303404574_0_.functions" );
7581 ida_0_file = copyToPrimaryDir ("SimID_303404574_0_.ida" ); // results for batch run0 (or for single run)
7682 log_0_file = copyToPrimaryDir ("SimID_303404574_0_0.log" ); // langevin-made log for run 0
@@ -87,6 +93,11 @@ public static void setUp() throws IOException {
8793 ida_min_file = copyToPrimaryDir ("SimID_303404574_0__Min.ida" );
8894 ida_std_file = copyToPrimaryDir ("SimID_303404574_0__Std.ida" );
8995
96+ resourceBase = "cbit/vcell/simdata/langevin/euler/" ;
97+ euler_log_file = copyToPrimaryDir ("SimID_303690651_0_.log" );
98+ euler_ode_file = copyToPrimaryDir ("SimID_303690651_0_.ode" );
99+
100+
90101// ida_1_File = File.createTempFile("SimID_284673710_0_", ".ida");
91102// Resources.asByteSource(Resources.getResource("cbit/vcell/simdata/SimID_284673710_0_.ida"))
92103// .copyTo(com.google.common.io.Files.asByteSink(ida_1_File));
@@ -102,7 +113,7 @@ public static void tearDown() {
102113
103114
104115 @ Test
105- public void testReadData () throws IOException , DataAccessException , CacheException {
116+ public void testReadDataLangevinBatch () throws IOException , DataAccessException , CacheException {
106117
107118 String simID = "303404574" ;
108119 KeyValue key = new KeyValue (simID );
@@ -111,10 +122,13 @@ public void testReadData() throws IOException, DataAccessException, CacheExcepti
111122
112123 VCDataIdentifier vCDataIdentifier = new VCSimulationDataIdentifier (vcSimID , 0 );
113124 VCData vcData = new SimulationData (vCDataIdentifier , primaryDir , localSimDir , null );
125+ SimulationData simData = (SimulationData )vcData ;
126+ String identifier = simData .getDataIdentifierSafe ();
127+ assertTrue (identifier .equals (SimDataConstants .IDA_DATA_IDENTIFIER ), "Langevin simulation should be IDA data" );
128+ assertFalse (identifier .equals (SimDataConstants .ODE_DATA_IDENTIFIER ), "Langevin simulation should not be ODE data" );
114129
115130 Cachetable aCacheTable = new Cachetable (10 * Cachetable .minute , 100000 );
116131 aCacheTable .put (vCDataIdentifier , vcData );
117-
118132 DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl (aCacheTable , primaryDir , localSimDir );
119133
120134 LangevinBatchResultSet lbrs = dataSetControllerImpl .getLangevinBatchResultSet (vCDataIdentifier );
@@ -143,6 +157,31 @@ public void testReadData() throws IOException, DataAccessException, CacheExcepti
143157
144158 }
145159
160+ // we should not try to read euler results using LangevinBatchResultSet
161+ @ Test
162+ public void testReadDataEulerBatch () throws IOException , DataAccessException , CacheException {
163+
164+ String simID = "303690651" ;
165+ KeyValue key = new KeyValue (simID );
166+ User usr = new User ("temp" ,key );
167+ VCSimulationIdentifier vcSimID = new VCSimulationIdentifier (key , usr );
168+
169+ VCDataIdentifier vCDataIdentifier = new VCSimulationDataIdentifier (vcSimID , 0 );
170+ VCData vcData = new SimulationData (vCDataIdentifier , primaryDir , localSimDir , null );
171+ SimulationData simData = (SimulationData )vcData ;
172+ String identifier = simData .getDataIdentifierSafe ();
173+ assertFalse (identifier .equals (SimDataConstants .IDA_DATA_IDENTIFIER ), "Langevin simulation should not be IDA data" );
174+ assertTrue (identifier .equals (SimDataConstants .ODE_DATA_IDENTIFIER ), "Langevin simulation should be ODE data" );
175+
176+ Cachetable aCacheTable = new Cachetable (10 * Cachetable .minute , 100000 );
177+ aCacheTable .put (vCDataIdentifier , vcData );
178+ DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl (aCacheTable , primaryDir , localSimDir );
179+
180+ LangevinBatchResultSet lbrs = dataSetControllerImpl .getLangevinBatchResultSet (vCDataIdentifier );
181+ assertNull (lbrs , "Result set should be null for Euler data when read as LangevinBatchResultSet" );
182+
183+ }
184+
146185// @Test
147186// public void testRead() throws IOException {
148187//
@@ -167,7 +206,7 @@ private static void deleteRecursively(File file) {
167206
168207 private static File copyToPrimaryDir (String resourceName ) throws IOException {
169208 File out = new File (primaryDir , resourceName );
170- Resources .asByteSource (Resources .getResource ("cbit/vcell/simdata/langevin/batch/" + resourceName ))
209+ Resources .asByteSource (Resources .getResource (resourceBase + resourceName ))
171210 .copyTo (com .google .common .io .Files .asByteSink (out ));
172211 return out ;
173212 }
0 commit comments