NIHVIVO-1564 Separate properties and methods in object dump. Reorganize unit tests to share more code.
This commit is contained in:
parent
0eb6f25e89
commit
6ebb72a09d
2 changed files with 187 additions and 198 deletions
|
@ -48,7 +48,9 @@ public abstract class BaseDumpDirective implements TemplateDirectiveModel {
|
||||||
private static final Log log = LogFactory.getLog(BaseDumpDirective.class);
|
private static final Log log = LogFactory.getLog(BaseDumpDirective.class);
|
||||||
|
|
||||||
enum Key {
|
enum Key {
|
||||||
|
METHODS("methods"),
|
||||||
NAME("name"),
|
NAME("name"),
|
||||||
|
PROPERTIES(Key.METHODS.toString()),
|
||||||
TYPE("type"),
|
TYPE("type"),
|
||||||
VALUE("value"),
|
VALUE("value"),
|
||||||
DATE_TYPE("dateType");
|
DATE_TYPE("dateType");
|
||||||
|
@ -285,8 +287,9 @@ public abstract class BaseDumpDirective implements TemplateDirectiveModel {
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
map.put(Key.TYPE.toString(), object.getClass().getName());
|
map.put(Key.TYPE.toString(), object.getClass().getName());
|
||||||
|
|
||||||
// Compile the set of properties and methods available to model
|
// Compile the sets of properties and methods available to template
|
||||||
SortedMap<String, Object> availableMethods = new TreeMap<String, Object>();
|
SortedMap<String, Object> properties = new TreeMap<String, Object>();
|
||||||
|
SortedMap<String, Object> methods = new TreeMap<String, Object>();
|
||||||
|
|
||||||
// keys() gets only values visible to template based on the BeansWrapper used.
|
// keys() gets only values visible to template based on the BeansWrapper used.
|
||||||
// Note: if the BeansWrapper exposure level > BeansWrapper.EXPOSE_PROPERTIES_ONLY,
|
// Note: if the BeansWrapper exposure level > BeansWrapper.EXPOSE_PROPERTIES_ONLY,
|
||||||
|
@ -305,12 +308,12 @@ public abstract class BaseDumpDirective implements TemplateDirectiveModel {
|
||||||
if (keySet.size() > 0) {
|
if (keySet.size() > 0) {
|
||||||
|
|
||||||
Class<?> cls = object.getClass();
|
Class<?> cls = object.getClass();
|
||||||
Method[] methods = cls.getMethods();
|
Method[] classMethods = cls.getMethods();
|
||||||
|
|
||||||
// Iterate through the methods rather than the keys, so that we can remove
|
// Iterate through the methods rather than the keys, so that we can remove
|
||||||
// some keys based on reflection on the methods. We also want to remove duplicates
|
// some keys based on reflection on the methods. We also want to remove duplicates
|
||||||
// like name/getName - we'll keep only the first form.
|
// like name/getName - we'll keep only the first form.
|
||||||
for ( Method method : methods ) {
|
for ( Method method : classMethods ) {
|
||||||
|
|
||||||
// Eliminate methods declared on Object
|
// Eliminate methods declared on Object
|
||||||
Class<?> c = method.getDeclaringClass();
|
Class<?> c = method.getDeclaringClass();
|
||||||
|
@ -331,16 +334,19 @@ public abstract class BaseDumpDirective implements TemplateDirectiveModel {
|
||||||
// If the method is available as a property, use that
|
// If the method is available as a property, use that
|
||||||
if (keySet.contains(propertyName)) {
|
if (keySet.contains(propertyName)) {
|
||||||
TemplateModel value = model.get(propertyName);
|
TemplateModel value = model.get(propertyName);
|
||||||
availableMethods.put(propertyName, getData(value));
|
properties.put(propertyName, getData(value));
|
||||||
// Else look for the entire methodName in the key set
|
// Else look for the entire methodName in the key set
|
||||||
} else if (keySet.contains(methodName)) {
|
} else if (keySet.contains(methodName)) {
|
||||||
String methodDisplayName = getMethodDisplayName(method);
|
String methodDisplayName = getMethodDisplayName(method);
|
||||||
availableMethods.put(methodDisplayName, "");
|
methods.put(methodDisplayName, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
map.put(Key.VALUE.toString(), availableMethods);
|
Map<String, Object> objectValue = new HashMap<String, Object>(2);
|
||||||
|
objectValue.put(Key.PROPERTIES.toString(), properties);
|
||||||
|
objectValue.put(Key.METHODS.toString(), methods);
|
||||||
|
map.put(Key.VALUE.toString(), objectValue);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -635,118 +635,22 @@ public class DumpDirectiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void dumpObjectWithExposeNothingWrapper() {
|
public void dumpObjectWithExposeNothingWrapper() {
|
||||||
|
dumpObject(BeansWrapper.EXPOSE_NOTHING);
|
||||||
String varName = "employee";
|
|
||||||
Map<String, Object> dataModel = new HashMap<String, Object>();
|
|
||||||
BeansWrapper wrapper = new BeansWrapper();
|
|
||||||
wrapper.setExposureLevel(BeansWrapper.EXPOSE_NOTHING);
|
|
||||||
try {
|
|
||||||
dataModel.put("employee", wrapper.wrap(getEmployee()));
|
|
||||||
} catch (TemplateModelException e) {
|
|
||||||
// logging is suppressed, so what do we do here?
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Object> expectedDump = new HashMap<String, Object>();
|
|
||||||
expectedDump.put(Key.NAME.toString(), varName);
|
|
||||||
expectedDump.put(Key.TYPE.toString(), "freemarker.ext.dump.DumpDirectiveTest$Employee");
|
|
||||||
expectedDump.put(Key.VALUE.toString(), new TreeMap<String, Object>());
|
|
||||||
test(varName, dataModel, expectedDump);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void dumpObjectWithExposePropertiesOnlyWrapper() {
|
public void dumpObjectWithExposePropertiesOnlyWrapper() {
|
||||||
|
dumpObject(BeansWrapper.EXPOSE_PROPERTIES_ONLY);
|
||||||
String varName = "employee";
|
|
||||||
Map<String, Object> dataModel = new HashMap<String, Object>();
|
|
||||||
BeansWrapper wrapper = new BeansWrapper();
|
|
||||||
wrapper.setExposureLevel(BeansWrapper.EXPOSE_PROPERTIES_ONLY);
|
|
||||||
try {
|
|
||||||
dataModel.put("employee", wrapper.wrap(getEmployee()));
|
|
||||||
} catch (TemplateModelException e) {
|
|
||||||
// logging is suppressed, so what do we do here?
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Object> expectedDump = new HashMap<String, Object>();
|
|
||||||
expectedDump.put(Key.NAME.toString(), varName);
|
|
||||||
expectedDump.put(Key.TYPE.toString(), "freemarker.ext.dump.DumpDirectiveTest$Employee");
|
|
||||||
|
|
||||||
SortedMap<String, Object> propertiesExpectedDump = getJohnDoePropertiesExpectedDump();
|
|
||||||
|
|
||||||
expectedDump.put(Key.VALUE.toString(), propertiesExpectedDump);
|
|
||||||
|
|
||||||
Map<String, Object> dump = getDump(varName, dataModel);
|
|
||||||
assertEquals(expectedDump, dump);
|
|
||||||
|
|
||||||
// Test the sorting of the methods
|
|
||||||
List<String> expectedKeys = new ArrayList<String>(propertiesExpectedDump.keySet());
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Map<String, Object> methodsActualDump = (Map<String, Object>) dump.get(Key.VALUE.toString());
|
|
||||||
List<String> actualKeys = new ArrayList<String>(methodsActualDump.keySet());
|
|
||||||
assertEquals(expectedKeys, actualKeys);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void dumpObjectWithExposeSafeWrapper() {
|
public void dumpObjectWithExposeSafeWrapper() {
|
||||||
|
//dumpObject(BeansWrapper.EXPOSE_SAFE);
|
||||||
String varName = "employee";
|
|
||||||
Map<String, Object> dataModel = new HashMap<String, Object>();
|
|
||||||
BeansWrapper wrapper = new BeansWrapper();
|
|
||||||
wrapper.setExposureLevel(BeansWrapper.EXPOSE_SAFE);
|
|
||||||
try {
|
|
||||||
dataModel.put("employee", wrapper.wrap(getEmployee()));
|
|
||||||
} catch (TemplateModelException e) {
|
|
||||||
// logging is suppressed, so what do we do here?
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Object> expectedDump = new HashMap<String, Object>();
|
|
||||||
expectedDump.put(Key.NAME.toString(), varName);
|
|
||||||
expectedDump.put(Key.TYPE.toString(), "freemarker.ext.dump.DumpDirectiveTest$Employee");
|
|
||||||
|
|
||||||
SortedMap<String, Object> methodsExpectedDump = getJohnDoePropertiesExpectedDump();
|
|
||||||
// methodsExpectedDump.putAll(...);
|
|
||||||
expectedDump.put(Key.VALUE.toString(), methodsExpectedDump);
|
|
||||||
|
|
||||||
//Map<String, Object> dump = getDump(varName, dataModel);
|
|
||||||
//assertEquals(expectedDump, dump);
|
|
||||||
|
|
||||||
// Test the sorting of the methods
|
|
||||||
// List<String> expectedKeys = new ArrayList<String>(properties.keySet());
|
|
||||||
// @SuppressWarnings("unchecked")
|
|
||||||
// Map<String, Object> methodsActualDump = (Map<String, Object>) dump.get(Key.VALUE.toString());
|
|
||||||
// List<String> actualKeys = new ArrayList<String>(methodsActualDump.keySet());
|
|
||||||
//assertEquals(expectedKeys, actualKeys);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void dumpObjectWithExposeAllWrapper() {
|
public void dumpObjectWithExposeAllWrapper() {
|
||||||
|
//dumpObject(BeansWrapper.EXPOSE_ALL);
|
||||||
String varName = "employee";
|
|
||||||
Map<String, Object> dataModel = new HashMap<String, Object>();
|
|
||||||
BeansWrapper wrapper = new BeansWrapper();
|
|
||||||
wrapper.setExposureLevel(BeansWrapper.EXPOSE_ALL);
|
|
||||||
try {
|
|
||||||
dataModel.put("employee", wrapper.wrap(getEmployee()));
|
|
||||||
} catch (TemplateModelException e) {
|
|
||||||
// logging is suppressed, so what do we do here?
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Object> expectedDump = new HashMap<String, Object>();
|
|
||||||
expectedDump.put(Key.NAME.toString(), varName);
|
|
||||||
expectedDump.put(Key.TYPE.toString(), "freemarker.ext.dump.DumpDirectiveTest$Employee");
|
|
||||||
|
|
||||||
SortedMap<String, Object> methodsExpectedDump = getJohnDoePropertiesExpectedDump();
|
|
||||||
// methodsExpectedDump.putAll(...);
|
|
||||||
expectedDump.put(Key.VALUE.toString(), methodsExpectedDump);
|
|
||||||
|
|
||||||
//Map<String, Object> dump = getDump(varName, dataModel);
|
|
||||||
//assertEquals(expectedDump, dump);
|
|
||||||
|
|
||||||
// Test the sorting of the methods
|
|
||||||
// List<String> expectedKeys = new ArrayList<String>(properties.keySet());
|
|
||||||
// @SuppressWarnings("unchecked")
|
|
||||||
// Map<String, Object> methodsActualDump = (Map<String, Object>) dump.get(Key.VALUE.toString());
|
|
||||||
// List<String> actualKeys = new ArrayList<String>(methodsActualDump.keySet());
|
|
||||||
//assertEquals(expectedKeys, actualKeys);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -757,6 +661,56 @@ public class DumpDirectiveTest {
|
||||||
assertEquals(expectedDump, dump);
|
assertEquals(expectedDump, dump);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void dumpObject(int exposureLevel) {
|
||||||
|
|
||||||
|
String varName = "employee";
|
||||||
|
Map<String, Object> dataModel = new HashMap<String, Object>();
|
||||||
|
BeansWrapper wrapper = new BeansWrapper();
|
||||||
|
wrapper.setExposureLevel(exposureLevel);
|
||||||
|
try {
|
||||||
|
dataModel.put("employee", wrapper.wrap(getEmployee()));
|
||||||
|
} catch (TemplateModelException e) {
|
||||||
|
// logging is suppressed, so what do we do here?
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> expectedDump = new HashMap<String, Object>();
|
||||||
|
expectedDump.put(Key.NAME.toString(), varName);
|
||||||
|
expectedDump.put(Key.TYPE.toString(), "freemarker.ext.dump.DumpDirectiveTest$Employee");
|
||||||
|
expectedDump.put(Key.VALUE.toString(), getJohnDoeExpectedDump(exposureLevel));
|
||||||
|
|
||||||
|
testObjectDump(varName, dataModel, expectedDump);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testObjectDump(String varName, Map<String, Object> dataModel, Map<String, Object> expectedDump) {
|
||||||
|
|
||||||
|
Map<String, Object> dump = getDump(varName, dataModel);
|
||||||
|
assertEquals(expectedDump, dump);
|
||||||
|
|
||||||
|
// Test the sorting of the properties and methods
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String, Object> valueExpectedDump = (Map<String, Object>) expectedDump.get(Key.VALUE.toString());
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String, Object> valueActualDump = (Map<String, Object>) dump.get(Key.VALUE.toString());
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String, Object> propertiesExpectedDump = (Map<String, Object>) valueExpectedDump.get(Key.PROPERTIES.toString());
|
||||||
|
List<String> propertyKeysExpected = new ArrayList<String>(propertiesExpectedDump.keySet());
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String, Object> propertiesActualDump = (Map<String, Object>) valueActualDump.get(Key.PROPERTIES.toString());
|
||||||
|
List<String> propertyKeysActual = new ArrayList<String>(propertiesActualDump.keySet());
|
||||||
|
assertEquals(propertyKeysExpected, propertyKeysActual);
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String, Object> methodsExpectedDump = (Map<String, Object>) valueExpectedDump.get(Key.METHODS.toString());
|
||||||
|
List<String> methodKeysExpected = new ArrayList<String>(methodsExpectedDump.keySet());
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String, Object> methodsActualDump = (Map<String, Object>) valueActualDump.get(Key.METHODS.toString());
|
||||||
|
List<String> methodKeysActual = new ArrayList<String>(methodsActualDump.keySet());
|
||||||
|
assertEquals(methodKeysExpected, methodKeysActual);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private Map<String, Object> getDump(String varName, Map<String, Object> dataModel) {
|
private Map<String, Object> getDump(String varName, Map<String, Object> dataModel) {
|
||||||
try {
|
try {
|
||||||
Environment env = template.createProcessingEnvironment(dataModel, new StringWriter());
|
Environment env = template.createProcessingEnvironment(dataModel, new StringWriter());
|
||||||
|
@ -767,6 +721,8 @@ public class DumpDirectiveTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private class HelplessMethod implements TemplateMethodModel {
|
private class HelplessMethod implements TemplateMethodModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -982,117 +938,144 @@ public class DumpDirectiveTest {
|
||||||
return jdoe;
|
return jdoe;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SortedMap<String, Object> getJohnDoePropertiesExpectedDump() {
|
private Map<String, Object> getJohnDoeExpectedDump(int exposureLevel) {
|
||||||
|
|
||||||
|
Map<String, Object> expectedDump = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
// Properties
|
||||||
SortedMap<String, Object> propertiesExpectedDump = new TreeMap<String, Object>();
|
SortedMap<String, Object> propertiesExpectedDump = new TreeMap<String, Object>();
|
||||||
|
|
||||||
// Map<String, Object> birthdateExpectedDump = new HashMap<String, Object>();
|
if (exposureLevel != BeansWrapper.EXPOSE_NOTHING) {
|
||||||
// birthdateExpectedDump.put(Key.TYPE.toString(), Type.DATE);
|
|
||||||
// birthdateExpectedDump.put(Key.DATE_TYPE.toString(), DateType.UNKNOWN);
|
|
||||||
// Calendar c = Calendar.getInstance();
|
|
||||||
// c.set(75, Calendar.MAY, 5);
|
|
||||||
// birthdateExpectedDump.put(Key.VALUE.toString(), c.getTime());
|
|
||||||
// propertiesExpectedDump.put("birthdate", birthdateExpectedDump);
|
|
||||||
|
|
||||||
Map<String, Object> fullNameExpectedDump = new HashMap<String, Object>();
|
// Map<String, Object> birthdateExpectedDump = new HashMap<String, Object>();
|
||||||
fullNameExpectedDump.put(Key.TYPE.toString(), Type.STRING);
|
// birthdateExpectedDump.put(Key.TYPE.toString(), Type.DATE);
|
||||||
fullNameExpectedDump.put(Key.VALUE.toString(), "John Doe");
|
// birthdateExpectedDump.put(Key.DATE_TYPE.toString(), DateType.UNKNOWN);
|
||||||
propertiesExpectedDump.put("fullName", fullNameExpectedDump);
|
// Calendar c = Calendar.getInstance();
|
||||||
|
// c.set(75, Calendar.MAY, 5);
|
||||||
|
// birthdateExpectedDump.put(Key.VALUE.toString(), c.getTime());
|
||||||
|
// propertiesExpectedDump.put("birthdate", birthdateExpectedDump);
|
||||||
|
|
||||||
Map<String, Object> idExpectedDump = new HashMap<String, Object>();
|
Map<String, Object> fullNameExpectedDump = new HashMap<String, Object>();
|
||||||
idExpectedDump.put(Key.TYPE.toString(), Type.NUMBER);
|
fullNameExpectedDump.put(Key.TYPE.toString(), Type.STRING);
|
||||||
idExpectedDump.put(Key.VALUE.toString(), 34523);
|
fullNameExpectedDump.put(Key.VALUE.toString(), "John Doe");
|
||||||
propertiesExpectedDump.put("id", idExpectedDump);
|
propertiesExpectedDump.put("fullName", fullNameExpectedDump);
|
||||||
|
|
||||||
Map<String, Object> nicknameExpectedDump = new HashMap<String, Object>();
|
Map<String, Object> idExpectedDump = new HashMap<String, Object>();
|
||||||
nicknameExpectedDump.put(Key.TYPE.toString(), Type.STRING);
|
idExpectedDump.put(Key.TYPE.toString(), Type.NUMBER);
|
||||||
nicknameExpectedDump.put(Key.VALUE.toString(), "");
|
idExpectedDump.put(Key.VALUE.toString(), 34523);
|
||||||
propertiesExpectedDump.put("nickname", nicknameExpectedDump);
|
propertiesExpectedDump.put("id", idExpectedDump);
|
||||||
|
|
||||||
Map<String, Object> middleNameExpectedDump = new HashMap<String, Object>();
|
Map<String, Object> nicknameExpectedDump = new HashMap<String, Object>();
|
||||||
middleNameExpectedDump.put(Key.VALUE.toString(), "null");
|
nicknameExpectedDump.put(Key.TYPE.toString(), Type.STRING);
|
||||||
propertiesExpectedDump.put("middleName", middleNameExpectedDump);
|
nicknameExpectedDump.put(Key.VALUE.toString(), "");
|
||||||
|
propertiesExpectedDump.put("nickname", nicknameExpectedDump);
|
||||||
|
|
||||||
Map<String, Object> marriedExpectedDump = new HashMap<String, Object>();
|
Map<String, Object> middleNameExpectedDump = new HashMap<String, Object>();
|
||||||
marriedExpectedDump.put(Key.TYPE.toString(), Type.BOOLEAN);
|
middleNameExpectedDump.put(Key.VALUE.toString(), "null");
|
||||||
marriedExpectedDump.put(Key.VALUE.toString(), true);
|
propertiesExpectedDump.put("middleName", middleNameExpectedDump);
|
||||||
propertiesExpectedDump.put("married", marriedExpectedDump);
|
|
||||||
|
|
||||||
Map<String, Object> supervisorExpectedDump = new HashMap<String, Object>();
|
Map<String, Object> marriedExpectedDump = new HashMap<String, Object>();
|
||||||
supervisorExpectedDump.put(Key.TYPE.toString(), "freemarker.ext.dump.DumpDirectiveTest$Employee");
|
marriedExpectedDump.put(Key.TYPE.toString(), Type.BOOLEAN);
|
||||||
supervisorExpectedDump.put(Key.VALUE.toString(), getJaneSmithPropertiesExpectedDump());
|
marriedExpectedDump.put(Key.VALUE.toString(), true);
|
||||||
propertiesExpectedDump.put("supervisor", supervisorExpectedDump);
|
propertiesExpectedDump.put("married", marriedExpectedDump);
|
||||||
|
|
||||||
Map<String, Object> favoriteColorsExpectedDump = new HashMap<String, Object>();
|
Map<String, Object> supervisorExpectedDump = new HashMap<String, Object>();
|
||||||
favoriteColorsExpectedDump.put(Key.TYPE.toString(), Type.SEQUENCE);
|
supervisorExpectedDump.put(Key.TYPE.toString(), "freemarker.ext.dump.DumpDirectiveTest$Employee");
|
||||||
List<Map<String, Object>> favoriteColorListExpectedDump = new ArrayList<Map<String, Object>>();
|
|
||||||
Map<String, Object> color1ExpectedDump = new HashMap<String, Object>();
|
|
||||||
color1ExpectedDump.put(Key.TYPE.toString(), Type.STRING);
|
|
||||||
color1ExpectedDump.put(Key.VALUE.toString(), "blue");
|
|
||||||
favoriteColorListExpectedDump.add(color1ExpectedDump);
|
|
||||||
Map<String, Object> color2ExpectedDump = new HashMap<String, Object>();
|
|
||||||
color2ExpectedDump.put(Key.TYPE.toString(), Type.STRING);
|
|
||||||
color2ExpectedDump.put(Key.VALUE.toString(), "green");
|
|
||||||
favoriteColorListExpectedDump.add(color2ExpectedDump);
|
|
||||||
favoriteColorsExpectedDump.put(Key.VALUE.toString(), favoriteColorListExpectedDump);
|
|
||||||
propertiesExpectedDump.put("favoriteColors", favoriteColorsExpectedDump);
|
|
||||||
|
|
||||||
return propertiesExpectedDump;
|
supervisorExpectedDump.put(Key.VALUE.toString(), getJaneSmithExpectedDump(exposureLevel));
|
||||||
|
propertiesExpectedDump.put("supervisor", supervisorExpectedDump);
|
||||||
|
|
||||||
|
Map<String, Object> favoriteColorsExpectedDump = new HashMap<String, Object>();
|
||||||
|
favoriteColorsExpectedDump.put(Key.TYPE.toString(), Type.SEQUENCE);
|
||||||
|
List<Map<String, Object>> favoriteColorListExpectedDump = new ArrayList<Map<String, Object>>();
|
||||||
|
Map<String, Object> color1ExpectedDump = new HashMap<String, Object>();
|
||||||
|
color1ExpectedDump.put(Key.TYPE.toString(), Type.STRING);
|
||||||
|
color1ExpectedDump.put(Key.VALUE.toString(), "blue");
|
||||||
|
favoriteColorListExpectedDump.add(color1ExpectedDump);
|
||||||
|
Map<String, Object> color2ExpectedDump = new HashMap<String, Object>();
|
||||||
|
color2ExpectedDump.put(Key.TYPE.toString(), Type.STRING);
|
||||||
|
color2ExpectedDump.put(Key.VALUE.toString(), "green");
|
||||||
|
favoriteColorListExpectedDump.add(color2ExpectedDump);
|
||||||
|
favoriteColorsExpectedDump.put(Key.VALUE.toString(), favoriteColorListExpectedDump);
|
||||||
|
propertiesExpectedDump.put("favoriteColors", favoriteColorsExpectedDump);
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedDump.put(Key.PROPERTIES.toString(), propertiesExpectedDump);
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
|
||||||
|
SortedMap<String, Object> methodsExpectedDump = new TreeMap<String, Object>();
|
||||||
|
expectedDump.put(Key.METHODS.toString(), methodsExpectedDump);
|
||||||
|
|
||||||
|
return expectedDump;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SortedMap<String, Object> getJaneSmithPropertiesExpectedDump() {
|
private Map<String, Object> getJaneSmithExpectedDump(int exposureLevel) {
|
||||||
|
|
||||||
|
Map<String, Object> expectedDump = new HashMap<String, Object>();
|
||||||
|
|
||||||
SortedMap<String, Object> propertiesExpectedDump = new TreeMap<String, Object>();
|
SortedMap<String, Object> propertiesExpectedDump = new TreeMap<String, Object>();
|
||||||
|
|
||||||
// Map<String, Object> birthdateExpectedDump = new HashMap<String, Object>();
|
// Properties
|
||||||
// birthdateExpectedDump.put(Key.TYPE.toString(), Type.DATE);
|
if (exposureLevel != BeansWrapper.EXPOSE_NOTHING) {
|
||||||
// birthdateExpectedDump.put(Key.DATE_TYPE.toString(), DateType.UNKNOWN);
|
|
||||||
// Calendar c = Calendar.getInstance();
|
|
||||||
// c.set(75, Calendar.MAY, 5);
|
|
||||||
// birthdateExpectedDump.put(Key.VALUE.toString(), c.getTime());
|
|
||||||
// propertiesExpectedDump.put("birthdate", birthdateExpectedDump);
|
|
||||||
|
|
||||||
Map<String, Object> fullNameExpectedDump = new HashMap<String, Object>();
|
// Map<String, Object> birthdateExpectedDump = new HashMap<String, Object>();
|
||||||
fullNameExpectedDump.put(Key.TYPE.toString(), Type.STRING);
|
// birthdateExpectedDump.put(Key.TYPE.toString(), Type.DATE);
|
||||||
fullNameExpectedDump.put(Key.VALUE.toString(), "Jane Smith");
|
// birthdateExpectedDump.put(Key.DATE_TYPE.toString(), DateType.UNKNOWN);
|
||||||
propertiesExpectedDump.put("fullName", fullNameExpectedDump);
|
// Calendar c = Calendar.getInstance();
|
||||||
|
// c.set(75, Calendar.MAY, 5);
|
||||||
|
// birthdateExpectedDump.put(Key.VALUE.toString(), c.getTime());
|
||||||
|
// propertiesExpectedDump.put("birthdate", birthdateExpectedDump);
|
||||||
|
|
||||||
Map<String, Object> idExpectedDump = new HashMap<String, Object>();
|
Map<String, Object> fullNameExpectedDump = new HashMap<String, Object>();
|
||||||
idExpectedDump.put(Key.TYPE.toString(), Type.NUMBER);
|
fullNameExpectedDump.put(Key.TYPE.toString(), Type.STRING);
|
||||||
idExpectedDump.put(Key.VALUE.toString(), 78234);
|
fullNameExpectedDump.put(Key.VALUE.toString(), "Jane Smith");
|
||||||
propertiesExpectedDump.put("id", idExpectedDump);
|
propertiesExpectedDump.put("fullName", fullNameExpectedDump);
|
||||||
|
|
||||||
Map<String, Object> nicknameExpectedDump = new HashMap<String, Object>();
|
Map<String, Object> idExpectedDump = new HashMap<String, Object>();
|
||||||
nicknameExpectedDump.put(Key.TYPE.toString(), Type.STRING);
|
idExpectedDump.put(Key.TYPE.toString(), Type.NUMBER);
|
||||||
nicknameExpectedDump.put(Key.VALUE.toString(), "");
|
idExpectedDump.put(Key.VALUE.toString(), 78234);
|
||||||
propertiesExpectedDump.put("nickname", nicknameExpectedDump);
|
propertiesExpectedDump.put("id", idExpectedDump);
|
||||||
|
|
||||||
Map<String, Object> middleNameExpectedDump = new HashMap<String, Object>();
|
Map<String, Object> nicknameExpectedDump = new HashMap<String, Object>();
|
||||||
middleNameExpectedDump.put(Key.VALUE.toString(), "null");
|
nicknameExpectedDump.put(Key.TYPE.toString(), Type.STRING);
|
||||||
propertiesExpectedDump.put("middleName", middleNameExpectedDump);
|
nicknameExpectedDump.put(Key.VALUE.toString(), "");
|
||||||
|
propertiesExpectedDump.put("nickname", nicknameExpectedDump);
|
||||||
|
|
||||||
Map<String, Object> marriedExpectedDump = new HashMap<String, Object>();
|
Map<String, Object> middleNameExpectedDump = new HashMap<String, Object>();
|
||||||
marriedExpectedDump.put(Key.TYPE.toString(), Type.BOOLEAN);
|
middleNameExpectedDump.put(Key.VALUE.toString(), "null");
|
||||||
marriedExpectedDump.put(Key.VALUE.toString(), true);
|
propertiesExpectedDump.put("middleName", middleNameExpectedDump);
|
||||||
propertiesExpectedDump.put("married", marriedExpectedDump);
|
|
||||||
|
|
||||||
Map<String, Object> supervisorExpectedDump = new HashMap<String, Object>();
|
Map<String, Object> marriedExpectedDump = new HashMap<String, Object>();
|
||||||
supervisorExpectedDump.put(Key.VALUE.toString(), "null");
|
marriedExpectedDump.put(Key.TYPE.toString(), Type.BOOLEAN);
|
||||||
propertiesExpectedDump.put("supervisor", supervisorExpectedDump);
|
marriedExpectedDump.put(Key.VALUE.toString(), true);
|
||||||
|
propertiesExpectedDump.put("married", marriedExpectedDump);
|
||||||
|
|
||||||
Map<String, Object> favoriteColorsExpectedDump = new HashMap<String, Object>();
|
Map<String, Object> supervisorExpectedDump = new HashMap<String, Object>();
|
||||||
favoriteColorsExpectedDump.put(Key.TYPE.toString(), Type.SEQUENCE);
|
supervisorExpectedDump.put(Key.VALUE.toString(), "null");
|
||||||
List<Map<String, Object>> favoriteColorListExpectedDump = new ArrayList<Map<String, Object>>();
|
propertiesExpectedDump.put("supervisor", supervisorExpectedDump);
|
||||||
Map<String, Object> color1ExpectedDump = new HashMap<String, Object>();
|
|
||||||
color1ExpectedDump.put(Key.TYPE.toString(), Type.STRING);
|
|
||||||
color1ExpectedDump.put(Key.VALUE.toString(), "red");
|
|
||||||
favoriteColorListExpectedDump.add(color1ExpectedDump);
|
|
||||||
Map<String, Object> color2ExpectedDump = new HashMap<String, Object>();
|
|
||||||
color2ExpectedDump.put(Key.TYPE.toString(), Type.STRING);
|
|
||||||
color2ExpectedDump.put(Key.VALUE.toString(), "orange");
|
|
||||||
favoriteColorListExpectedDump.add(color2ExpectedDump);
|
|
||||||
favoriteColorsExpectedDump.put(Key.VALUE.toString(), favoriteColorListExpectedDump);
|
|
||||||
propertiesExpectedDump.put("favoriteColors", favoriteColorsExpectedDump);
|
|
||||||
|
|
||||||
return propertiesExpectedDump;
|
Map<String, Object> favoriteColorsExpectedDump = new HashMap<String, Object>();
|
||||||
|
favoriteColorsExpectedDump.put(Key.TYPE.toString(), Type.SEQUENCE);
|
||||||
|
List<Map<String, Object>> favoriteColorListExpectedDump = new ArrayList<Map<String, Object>>();
|
||||||
|
Map<String, Object> color1ExpectedDump = new HashMap<String, Object>();
|
||||||
|
color1ExpectedDump.put(Key.TYPE.toString(), Type.STRING);
|
||||||
|
color1ExpectedDump.put(Key.VALUE.toString(), "red");
|
||||||
|
favoriteColorListExpectedDump.add(color1ExpectedDump);
|
||||||
|
Map<String, Object> color2ExpectedDump = new HashMap<String, Object>();
|
||||||
|
color2ExpectedDump.put(Key.TYPE.toString(), Type.STRING);
|
||||||
|
color2ExpectedDump.put(Key.VALUE.toString(), "orange");
|
||||||
|
favoriteColorListExpectedDump.add(color2ExpectedDump);
|
||||||
|
favoriteColorsExpectedDump.put(Key.VALUE.toString(), favoriteColorListExpectedDump);
|
||||||
|
propertiesExpectedDump.put("favoriteColors", favoriteColorsExpectedDump);
|
||||||
|
}
|
||||||
|
expectedDump.put(Key.PROPERTIES.toString(), propertiesExpectedDump);
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
SortedMap<String, Object> methodsExpectedDump = new TreeMap<String, Object>();
|
||||||
|
expectedDump.put(Key.METHODS.toString(), methodsExpectedDump);
|
||||||
|
|
||||||
|
return expectedDump;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue