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