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; package fr.inrae.agriterix.simulator;
import org.apache.commons.lang3.RandomStringUtils;
import java.util.*; import java.util.*;
public class GeoArea { public class GeoArea {
......
...@@ -204,15 +204,10 @@ public class Simulator { ...@@ -204,15 +204,10 @@ public class Simulator {
ArrayBuilder arrayBuilder; ArrayBuilder arrayBuilder;
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
CborEncoder cborEncoder = new CborEncoder(baos); CborEncoder cborEncoder = new CborEncoder(baos);
File file; OutputStream os;
FileOutputStream fos;
file = new File("db", "data/out/" + timestamp + "/patches.cbor");
arrayBuilder = cborBuilder.addArray(); arrayBuilder = cborBuilder.addArray();
os = Files.newOutputStream(Paths.get("data/out/" + timestamp + "/patches.cbor"));
fos = new FileOutputStream(file);
for (Farmer farmer : this.getFarmers()) { for (Farmer farmer : this.getFarmers()) {
for (Patch patch : farmer.getFarm().getPatches()) { for (Patch patch : farmer.getFarm().getPatches()) {
...@@ -234,8 +229,8 @@ public class Simulator { ...@@ -234,8 +229,8 @@ public class Simulator {
cborEncoder.encode(cborBuilder.build()); cborEncoder.encode(cborBuilder.build());
data = baos.toByteArray(); data = baos.toByteArray();
fos.write(data); os.write(data);
fos.close(); os.close();
} }
......
...@@ -189,16 +189,9 @@ public class SimulatorTest { ...@@ -189,16 +189,9 @@ public class SimulatorTest {
return flows; return flows;
} }
//@Test @Test
public void toDB() throws FileNotFoundException { public void toDB() throws FileNotFoundException {
Simulator simulator = Simulator.loadSimulator(new FileInputStream(directory + "simulator.xml")); 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 { try {
simulator.patchesCBOR(); simulator.patchesCBOR();
} catch (IOException e) { } catch (IOException e) {
......
Supports Markdown
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