Skip to content
Snippets Groups Projects
Commit a6121df1 authored by fedoreno's avatar fedoreno
Browse files

SSDM-3284: linearized tes-update code and java7'nd the test service

SVN: 35869
parent 5ab3fab6
No related branches found
No related tags found
No related merge requests found
...@@ -5,22 +5,29 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open ...@@ -5,22 +5,29 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open
var testUpdate = function(c, fCreate, fUpdate, fFind, fCheck, fCheckError) { var testUpdate = function(c, fCreate, fUpdate, fFind, fCheck, fCheckError) {
c.start(); c.start();
c.createFacadeAndLogin().then(function(facade) { var ctx = {
return fCreate(facade).then(function(permIds) { facade: null,
c.assertTrue(permIds != null && permIds.length == 1, "Entity was created"); permIds: null
return fFind(facade, permIds[0]).then(function(entity) { };
c.assertNotNull(entity, "Entity can be found"); c.createFacadeAndLogin()
return fUpdate(facade, permIds[0]).then(function() { .then(function(facade) {
c.ok("Entity was updated"); ctx.facade = facade;
return fFind(facade, permIds[0]).then(function(entity) { return fCreate(facade)
if (fCheck) { }).then(function(permIds) {
fCheck(entity); ctx.permIds = permIds;
} c.assertTrue(permIds != null && permIds.length == 1, "Entity was created");
c.finish(); return fFind(ctx.facade, permIds[0])
}); }).then(function(entity) {
}); c.assertNotNull(entity, "Entity can be found");
}); return fUpdate(ctx.facade, ctx.permIds[0])
}); }).then(function() {
c.ok("Entity was updated");
return fFind(ctx.facade, ctx.permIds[0])
}).then(function(entity) {
if (fCheck) {
fCheck(entity);
}
c.finish();
}).fail(function(error) { }).fail(function(error) {
if (fCheckError) { if (fCheckError) {
fCheckError(error.message); fCheckError(error.message);
......
...@@ -18,7 +18,6 @@ package ch.systemsx.cisd.openbis.jstest.service; ...@@ -18,7 +18,6 @@ package ch.systemsx.cisd.openbis.jstest.service;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
...@@ -54,13 +53,13 @@ public class V3ApiDtoTestService implements ICustomASServiceExecutor ...@@ -54,13 +53,13 @@ public class V3ApiDtoTestService implements ICustomASServiceExecutor
{ {
for (Method method : obj.getClass().getMethods()) for (Method method : obj.getClass().getMethods())
{ {
if (method.getParameterCount() == 1) { Class<?>[] parameterTypes = method.getParameterTypes();
Parameter parameter = method.getParameters()[0]; if (parameterTypes.length == 1) {
Class<?> type = parameter.getType(); Class<?> type = parameterTypes[0];
if (type.isPrimitive() || type.equals(String.class) || type.equals(Date.class)){ if (type.isPrimitive() || type.equals(String.class) || type.equals(Date.class)){
try try
{ {
setItUp(obj, method, parameter); setItUp(obj, method, type);
} catch (Exception e) } catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
...@@ -71,16 +70,15 @@ public class V3ApiDtoTestService implements ICustomASServiceExecutor ...@@ -71,16 +70,15 @@ public class V3ApiDtoTestService implements ICustomASServiceExecutor
return obj; return obj;
} }
private void setItUp(Object obj, Method method, Parameter parameter) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException private void setItUp(Object obj, Method method, Class<?> type) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
{ {
method.invoke(obj, getValue(parameter)); method.invoke(obj, getValue(type));
} }
private Object getValue(Parameter parameter) private Object getValue(Class<?> type)
{ {
double random = Math.random(); double random = Math.random();
long rnd = (long) (random*1000000); long rnd = (long) (random*1000000);
Class<?> type = parameter.getType();
if (type == String.class) { if (type == String.class) {
return String.valueOf(random); return String.valueOf(random);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment