Fixed test

This commit is contained in:
Luca Frosini 2024-03-24 18:28:12 +01:00
parent 69e07054ac
commit e0a0983373
1 changed files with 21 additions and 28 deletions

View File

@ -176,45 +176,40 @@ public class RecordTest extends ContextTest {
return record;
}
// @Ignore
@Test
@Ignore
// @Test
public void testFisheryRecords() throws Exception {
ContextTest.setContextByName("/pred4s/preprod/GRSF_Pre");
List<String> types = new ArrayList<>();
types.add(FISHERY);
boolean restart = true;
// String restartFromSource = "firms";
boolean restart = false;
String restartFromSource = "firms";
// String restartFromSource = "fishsource";
String restartFromSource = "grsf";
String restartFromFile = "c10cc833-ef4d-44d1-adef-3ea12283e6ad";
// String restartFromSource = "grsf";
String restartFromFile = null;
testRecords(types, restart, restartFromSource, restartFromFile);
}
// @Ignore
@Test
@Ignore
// @Test
public void testStockRecords() throws Exception {
ContextTest.setContextByName("/pred4s/preprod/GRSF_Pre");
List<String> types = new ArrayList<>();
types.add(STOCK);
boolean restart = true;
boolean restart = false;
String restartFromSource = "firms";
// String restartFromSource = "fishsource";
// String restartFromSource = "grsf";
// String restartFromSource = "ram";
// String restartFromSource = "sdg_14_4_1";
String restartFromFile = null; // 38 di 911
String restartFromFile = null;
testRecords(types, restart, restartFromSource, restartFromFile);
}
// @Ignore
@Test
@Ignore
// @Test
public void testTraceabilityUnitRecords() throws Exception {
ContextTest.setContextByName("/pred4s/preprod/GRSF_Pre");
List<String> types = new ArrayList<>();
types.add(TRACEABILITY_UNIT);
boolean restart = true;
boolean restart = false;
String restartFromSource = "grsf";
String restartFromFile = null;
testRecords(types, restart, restartFromSource, restartFromFile);
@ -222,12 +217,11 @@ public class RecordTest extends ContextTest {
private void testRecords(List<String> types, boolean restart, String restartFromSource, String restartFromFile) throws Exception {
int maxTestRecords = Integer.MAX_VALUE;
maxTestRecords = 1;
// maxTestRecords = 1;
int maxTestRecordsPerSource = Integer.MAX_VALUE;
maxTestRecordsPerSource = 1;
// maxTestRecordsPerSource = 1;
/*
* Tell if we want test the whole creation process;
@ -254,8 +248,7 @@ public class RecordTest extends ContextTest {
if(restart && restartFromFile!=null) {
restartedFromFile = false;
}
Calendar start = Calendar.getInstance();
int countRecord = 0;
@ -291,8 +284,7 @@ public class RecordTest extends ContextTest {
File[] sourceDirectory = typeDir.listFiles(dirnameFilter);
Arrays.sort(sourceDirectory);
// List<File> sourceDirectory = new ArrayList<>();
// sourceDirectory.add(new File(typeDir, "firms"));
@ -337,13 +329,15 @@ public class RecordTest extends ContextTest {
int numberOfRecordsPerSource = jsonFiles.length;
for (File jsonFile : jsonFiles) {
String expectedGRSFUUID = jsonFile.getName().replace(".json", "");
if(restart && restartedFromFile==false) {
if(restartFromFile!=null) {
if(jsonFile.getName().startsWith(restartFromFile)) {
logger.info("Found the record to restart i.e. {} {} {}", sourceString, type, jsonFile.getName());
restartedFromFile = true;
}else {
logger.info("The record {} {} {} has been already elaborated. Skipping...", sourceString, type, jsonFile.getName());
logger.info("[{} of {}] {} {} with GRSF UUID {} has been already elaborated", countRecordPerSource + 1, numberOfRecordsPerSource, sourceString, type, expectedGRSFUUID);
++countRecord;
++countRecordPerSource;
continue;
@ -361,7 +355,6 @@ public class RecordTest extends ContextTest {
break;
}
String expectedGRSFUUID = jsonFile.getName().replace(".json", "");
logger.trace("[{} of {}] Going to elaborate {} {} with GRSF UUID {} from file {}", countRecordPerSource + 1, numberOfRecordsPerSource, sourceString, type, expectedGRSFUUID, jsonFile.getAbsolutePath());
logger.info("[{} of {}] Going to elaborate {} {} with GRSF UUID {}", countRecordPerSource + 1, numberOfRecordsPerSource, sourceString, type, expectedGRSFUUID);
@ -419,7 +412,7 @@ public class RecordTest extends ContextTest {
countRecord, diff, TimeUnit.MILLISECONDS.toSeconds(diff));
}
// @Ignore
@Ignore
@Test
public void testList() {
MultivaluedMap<String, String> mvm = new MultivaluedHashMap<String,String>();