Commit a2cd465f authored by Loris Croce's avatar Loris Croce
Browse files

patches.db test edit

parent 1f4ec9fb
Pipeline #37909 passed with stages
package fr.inrae.agriterix.simulator;
import org.apache.commons.lang3.RandomStringUtils;
import java.util.*;
public class GeoArea {
......
......@@ -204,15 +204,10 @@ public class Simulator {
ArrayBuilder arrayBuilder;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
CborEncoder cborEncoder = new CborEncoder(baos);
File file;
FileOutputStream fos;
OutputStream os;
file = new File("db", "data/out/" + timestamp + "/patches.cbor");
arrayBuilder = cborBuilder.addArray();
fos = new FileOutputStream(file);
os = Files.newOutputStream(Paths.get("data/out/" + timestamp + "/patches.cbor"));
for (Farmer farmer : this.getFarmers()) {
for (Patch patch : farmer.getFarm().getPatches()) {
......@@ -234,8 +229,8 @@ public class Simulator {
cborEncoder.encode(cborBuilder.build());
data = baos.toByteArray();
fos.write(data);
fos.close();
os.write(data);
os.close();
}
......
......@@ -189,16 +189,9 @@ public class SimulatorTest {
return flows;
}
//@Test
@Test
public void toDB() throws FileNotFoundException {
Simulator simulator = Simulator.loadSimulator(new FileInputStream(directory + "simulator.xml"));
int patchesNB = 0;
for (GeoArea geoArea : simulator.geoAreas()) {
for (Patch patch : geoArea.getPatches()) {
patchesNB++;
}
}
//System.out.println(patchesNB);
try {
simulator.patchesCBOR();
} catch (IOException e) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment