commented junit test
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-analysis/dataminer-invocation-model@176037 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
086f63d5be
commit
fd305a59f2
|
@ -18,8 +18,6 @@ import org.gcube.data.analysis.dminvocation.model.DataMinerInvocation;
|
||||||
import org.gcube.data.analysis.dminvocation.model.DataMinerParam;
|
import org.gcube.data.analysis.dminvocation.model.DataMinerParam;
|
||||||
import org.gcube.data.analysis.dminvocation.model.DataMinerParamList;
|
import org.gcube.data.analysis.dminvocation.model.DataMinerParamList;
|
||||||
import org.gcube.data.analysis.dminvocation.model.DataMinerParameters;
|
import org.gcube.data.analysis.dminvocation.model.DataMinerParameters;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,7 +35,7 @@ public class DataMinerInvocationTest {
|
||||||
static DataMinerInvocationManager dmMng;
|
static DataMinerInvocationManager dmMng;
|
||||||
|
|
||||||
|
|
||||||
@Before
|
//@Before
|
||||||
public void init() throws JAXBException, IOException, SAXException{
|
public void init() throws JAXBException, IOException, SAXException{
|
||||||
parameters.put("fileId", "http://publicLinkToFile");
|
parameters.put("fileId", "http://publicLinkToFile");
|
||||||
parameters.put("[key2]", "[value2]");
|
parameters.put("[key2]", "[value2]");
|
||||||
|
@ -59,7 +57,7 @@ public class DataMinerInvocationTest {
|
||||||
// Map<String, String> inputList = new HashMap<String, String>();
|
// Map<String, String> inputList = new HashMap<String, String>();
|
||||||
// inputList.putAll(parameters);
|
// inputList.putAll(parameters);
|
||||||
//new DataMinerParamList(parameters)
|
//new DataMinerParamList(parameters)
|
||||||
DataMinerParameters parameters = new DataMinerParameters(new DataMinerParamList(inParams), null);
|
DataMinerParameters parameters = new DataMinerParameters(new DataMinerParamList(inParams), new DataMinerParamList(inParams));
|
||||||
|
|
||||||
DataMinerInvocation dmInvocation = new DataMinerInvocation();
|
DataMinerInvocation dmInvocation = new DataMinerInvocation();
|
||||||
dmInvocation.setOperatorId(operatorID);
|
dmInvocation.setOperatorId(operatorID);
|
||||||
|
@ -126,7 +124,7 @@ public class DataMinerInvocationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
//@Test
|
||||||
public void unmarshallingJSONTest() throws JAXBException, IOException, SAXException{
|
public void unmarshallingJSONTest() throws JAXBException, IOException, SAXException{
|
||||||
System.out.println("unmarshallingJSONTest called");
|
System.out.println("unmarshallingJSONTest called");
|
||||||
FileInputStream dmInvocationJSONFile = new FileInputStream(new File("./src/test/resources/DataMinerInvocation.json"));
|
FileInputStream dmInvocationJSONFile = new FileInputStream(new File("./src/test/resources/DataMinerInvocation.json"));
|
||||||
|
@ -142,66 +140,4 @@ public class DataMinerInvocationTest {
|
||||||
System.out.println("TO JSON: \n"+marshJSON);
|
System.out.println("TO JSON: \n"+marshJSON);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
try{
|
|
||||||
|
|
||||||
System.out.println("marshallingTest called");
|
|
||||||
//LOADING PARAMETERS
|
|
||||||
List<DataMinerParam> inParams = new ArrayList<DataMinerParam>();
|
|
||||||
for (String pm : parameters.keySet()) {
|
|
||||||
inParams.add(new DataMinerParam(pm, parameters.get(pm)));
|
|
||||||
}
|
|
||||||
|
|
||||||
DataMinerInvocation dm = new DataMinerInvocation();
|
|
||||||
dm.setOperatorId("the operator");
|
|
||||||
DataMinerParameters parameters = new DataMinerParameters(null, null);
|
|
||||||
dm.setParameters(parameters);
|
|
||||||
|
|
||||||
List<String> errors = new ArrayList<String>();
|
|
||||||
checkRequiredFiels(dm, errors);
|
|
||||||
System.out.println(errors);
|
|
||||||
|
|
||||||
}catch(Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void checkRequiredFiels(Object theInstance, List<String> errors) throws IllegalArgumentException, IllegalAccessException{
|
|
||||||
|
|
||||||
System.out.println("Checking instance: "+theInstance);
|
|
||||||
|
|
||||||
for(Field field : theInstance.getClass().getDeclaredFields()){
|
|
||||||
Class<?> type = field.getType();
|
|
||||||
String name = field.getName();
|
|
||||||
Annotation[] annotations = field.getDeclaredAnnotations();
|
|
||||||
System.out.println("Field: "+name);
|
|
||||||
for (Annotation annotation : annotations) {
|
|
||||||
if(annotation instanceof XmlElement){
|
|
||||||
field.setAccessible(true);
|
|
||||||
XmlElement xmlEl = (XmlElement) annotation;
|
|
||||||
Object value = field.get(theInstance);
|
|
||||||
if(value==null){
|
|
||||||
String error = "Required field '"+xmlEl.name() + "' of "+type+" is null";
|
|
||||||
System.err.println("Required field '"+xmlEl.name() + "' is null");
|
|
||||||
errors.add(error);
|
|
||||||
}else if (String.class.equals(type) && ((String) value).isEmpty()){
|
|
||||||
String error = "Required field '"+xmlEl.name() + "' of "+type+" is empty";
|
|
||||||
System.err.println("Required field '"+xmlEl.name() + "' is null");
|
|
||||||
errors.add(error);
|
|
||||||
}else if(!type.isPrimitive() && type != String.class){
|
|
||||||
System.out.println("The field "+xmlEl.name()+ " is not a primitive or a String\n\n");
|
|
||||||
checkRequiredFiels(value, errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
//System.out.println("XmlElement "+annotation.annotationType()+" is required: "+xmlEl.required());
|
|
||||||
}else
|
|
||||||
System.out.println("Another annotation: "+annotation);
|
|
||||||
//if (annotation.annotationType() instanceof XmlElement.c)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue