Updated Test classes
This commit is contained in:
parent
aa9c837912
commit
66aac2dacb
|
@ -12,6 +12,7 @@ import test.TestContextConfig;
|
|||
|
||||
public class CataloguePurgeDatasets {
|
||||
|
||||
private static final int SLEEPING_TIME = 7000;
|
||||
private static boolean useGeoportalServiceAccount = true;
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -30,7 +31,7 @@ public class CataloguePurgeDatasets {
|
|||
|
||||
|
||||
while (resultExists) {
|
||||
System.out.println("offest: " + offset + ", limit: " + limit);
|
||||
System.out.println("offset: " + offset + ", limit: " + limit);
|
||||
ScopeProvider.instance.set(TestContextConfig.CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TestContextConfig.TOKEN);
|
||||
String items = new CatalogueCaller().list(limit, offset, useGeoportalServiceAccount);
|
||||
|
@ -63,7 +64,6 @@ public class CataloguePurgeDatasets {
|
|||
try {
|
||||
|
||||
int index = 0;
|
||||
int sleepingTime = 4000;
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
index++;
|
||||
String datasetName = array.getString(i);
|
||||
|
@ -71,8 +71,8 @@ public class CataloguePurgeDatasets {
|
|||
ScopeProvider.instance.set(TestContextConfig.CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TestContextConfig.TOKEN);
|
||||
new CatalogueCaller().deleteDatasetOnCatalogue(datasetName, useGeoportalServiceAccount);
|
||||
System.out.println("sleeping..." + sleepingTime);
|
||||
Thread.sleep(sleepingTime);
|
||||
System.out.println("sleeping..." + SLEEPING_TIME);
|
||||
Thread.sleep(SLEEPING_TIME);
|
||||
}
|
||||
|
||||
System.out.println("done!");
|
||||
|
@ -100,7 +100,7 @@ public class CataloguePurgeDatasets {
|
|||
SecurityTokenProvider.instance.set(TestContextConfig.TOKEN);
|
||||
new CatalogueCaller().deleteDatasetOnCatalogue(datasetName, useGeoportalServiceAccount);
|
||||
|
||||
Thread.sleep(5000);
|
||||
Thread.sleep(SLEEPING_TIME);
|
||||
}
|
||||
|
||||
System.out.println("done!");
|
||||
|
|
|
@ -68,16 +68,23 @@ import test.TestContextConfig;
|
|||
public class GeoportalToCatalogueBatchPublisher {
|
||||
|
||||
public final static String profileID = "profiledConcessioni";
|
||||
public final static Integer MAX_ITEMS = 1;
|
||||
|
||||
public final static Integer MAX_ITEMS = 100;
|
||||
public static int limit = 10;
|
||||
public static int offset = 100;
|
||||
|
||||
static PrintWriter reportPrintWriter;
|
||||
static PrintWriter errorPrintWriter;
|
||||
private static long startTime;
|
||||
|
||||
private static final String CSV_DELIMITER = ";";
|
||||
|
||||
|
||||
private static boolean useGeoportalServiceAccount = true;
|
||||
|
||||
// if true append the data published or error in the report files.
|
||||
// Otherwise create new files.
|
||||
private static boolean appendErrors = true;
|
||||
|
||||
/**
|
||||
* The main method.
|
||||
*
|
||||
|
@ -123,23 +130,25 @@ public class GeoportalToCatalogueBatchPublisher {
|
|||
TestContextConfig.readContextSettings();
|
||||
String sourceScope = TestContextConfig.CONTEXT;
|
||||
String sourceToken = TestContextConfig.TOKEN;
|
||||
|
||||
//Setting empty SecretManager for test case
|
||||
//SecretManagerProvider.instance.set(new SecretManager());
|
||||
|
||||
// Setting empty SecretManager for test case
|
||||
// SecretManagerProvider.instance.set(new SecretManager());
|
||||
|
||||
String reportFile = TestContextConfig.CONTEXT.replaceAll("/", "_") + "_report_.csv";
|
||||
String errorFile = TestContextConfig.CONTEXT.replaceAll("/", "_") + "_error_.csv";
|
||||
try {
|
||||
Files.deleteIfExists(Paths.get(reportFile));
|
||||
Files.deleteIfExists(Paths.get(errorFile));
|
||||
if (!appendErrors) {
|
||||
Files.deleteIfExists(Paths.get(reportFile));
|
||||
Files.deleteIfExists(Paths.get(errorFile));
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
try {
|
||||
|
||||
FileWriter reportWriter = new FileWriter(reportFile, true);
|
||||
FileWriter errorWriter = new FileWriter(errorFile, true);
|
||||
FileWriter reportWriter = new FileWriter(reportFile, appendErrors);
|
||||
FileWriter errorWriter = new FileWriter(errorFile, appendErrors);
|
||||
BufferedWriter reportBW = new BufferedWriter(reportWriter);
|
||||
BufferedWriter errorBW = new BufferedWriter(errorWriter);
|
||||
reportPrintWriter = new PrintWriter(reportBW);
|
||||
|
@ -172,8 +181,6 @@ public class GeoportalToCatalogueBatchPublisher {
|
|||
log.info("Total projects are: " + totalProjects);
|
||||
boolean documentFound = true;
|
||||
boolean maxItemsReached = false;
|
||||
int limit = 10;
|
||||
int offset = 0;
|
||||
|
||||
int counter = 0;
|
||||
try {
|
||||
|
@ -221,14 +228,12 @@ public class GeoportalToCatalogueBatchPublisher {
|
|||
|
||||
ScopeProvider.instance.set(targetScope);
|
||||
SecurityTokenProvider.instance.set(targetToken);
|
||||
|
||||
|
||||
|
||||
|
||||
SecretManager secretManager = new SecretManager();
|
||||
Secret secret = new GCubeSecret(targetToken);
|
||||
secretManager.addSecret(secret);
|
||||
SecretManagerProvider.instance.set(secretManager);
|
||||
|
||||
|
||||
log.info("\n publishOnCatalogue the PROJECT N. " + counter + " with id: "
|
||||
+ theProject.getId());
|
||||
|
||||
|
@ -290,7 +295,8 @@ public class GeoportalToCatalogueBatchPublisher {
|
|||
*/
|
||||
public static void publishOnCatalogue(Project theProject, String toCatalogueJSON) throws Exception {
|
||||
|
||||
new CatalogueCaller().createOrUpdateTheDatasetOnCatalogue(theProject.getId(), toCatalogueJSON, useGeoportalServiceAccount);
|
||||
new CatalogueCaller().createOrUpdateTheDatasetOnCatalogue(theProject.getId(), toCatalogueJSON,
|
||||
useGeoportalServiceAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue