This commit is contained in:
Francesco Mangiacrapa 2022-05-20 15:43:35 +02:00
parent 5e876f32df
commit f812ac31d6
1 changed files with 42 additions and 16 deletions

View File

@ -23,11 +23,11 @@ public class UCD_Tests {
// private static String TOKEN = ""; //preVRE
private static String CONTEXT = "/gcube/devsec/devVRE";
private static String TOKEN = "3aa85bbf-d5f3-4df4-ad03-4f8f788eba3d-98187548"; // devVRE
private static String TOKEN = ""; // devVRE
private static String PROFILE_ID = "profiledConcessioni";
@Before
//@Before
public void getClient() {
// assumeTrue(GCubeTest.isTestInfrastructureEnabled());
ScopeProvider.instance.set(CONTEXT);
@ -35,7 +35,7 @@ public class UCD_Tests {
client = GeoportalClientCaller.useCaseDescriptors();
}
// @Test
//@Test
public void getList() throws Exception {
ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN);
@ -69,22 +69,12 @@ public class UCD_Tests {
}
}
@Test
public void getUCDForHandlerIds() throws Exception {
//@Test
public void getUCDForDataEntryHandlerIds() throws Exception {
ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN);
// List<String> handlersIds = Arrays.asList(GEOPORTAL_DATA_HANDLER.geoportal_data_entry.getId());
// List<UseCaseDescriptor> listOfUCD = client
// .getListForHandlerIds(handlersIds);
// int i = 0;
// for (UseCaseDescriptor useCaseDescriptor : listOfUCD) {
// System.out.println(++i + ") " + useCaseDescriptor);
// UseCaseDescriptorDV ucdDV = ConvertToDataValueObjectModel.toUseCaseDescriptorDV(useCaseDescriptor, null);
// System.out.println("returned " + ucdDV);
// }
List<String> handlersIds = Arrays.asList(GEOPORTAL_DATA_HANDLER.geoportal_data_entry.getId());
List<String> handlersIds = null;
List<UseCaseDescriptor> listUseCaseDescriptor;
try {
UseCaseDescriptorCaller client = GeoportalClientCaller.useCaseDescriptors();
@ -113,5 +103,41 @@ public class UCD_Tests {
System.out.println(listUCDDV);
}
//@Test
public void getUCDForDatalistHandlerIds() throws Exception {
ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN);
List<String> handlersIds = null;
List<UseCaseDescriptor> listUseCaseDescriptor;
try {
UseCaseDescriptorCaller client = GeoportalClientCaller.useCaseDescriptors();
if (handlersIds == null) {
handlersIds = Arrays.asList(GEOPORTAL_DATA_HANDLER.geoportal_data_list.getId());
System.out.println("handlersIds is null, so using default: " + handlersIds);
}
listUseCaseDescriptor = client.getListForHandlerIds(handlersIds);
} catch (Exception e) {
String error = "Error on contacting the Geoportal service";
System.out.println(error + " for handlers: " + handlersIds);
throw new Exception(
"Error when contacting the Geoportal service. Refresh and try again or contact the support", e);
}
if (listUseCaseDescriptor == null) {
listUseCaseDescriptor = new ArrayList<UseCaseDescriptor>();
}
List<UseCaseDescriptorDV> listUCDDV = new ArrayList<UseCaseDescriptorDV>(listUseCaseDescriptor.size());
for (UseCaseDescriptor ucd : listUseCaseDescriptor) {
listUCDDV.add(ConvertToDataValueObjectModel.toUseCaseDescriptorDV(ucd, null));
}
System.out.println(listUCDDV);
}
}