TestResult testResult, TreeSRelated treeSRelated) {\r
for (String key : contextAware.getExpectedValues().keySet()) {\r
\r
- // Register in structure\r
- if (treeSRelated != null) {\r
- if (treeSRelated.getBasePath() != null) {\r
- TreeSPath path = treeSRelated.getBasePath()\r
- .createChild(key);\r
- StructureRegistry<TreeSPath> registry = treeSRelated\r
- .getRegistry();\r
- final StructureElement element = treeSRelated\r
- .getStructureElement(key);\r
- registry.register(path, element);\r
- if (testResult instanceof StructureAware)\r
- ((StructureAware<TreeSPath>) testResult)\r
- .notifyCurrentPath(registry, path);\r
-\r
- if (log.isDebugEnabled())\r
- log.debug("Checking key " + key + " for path " + path);\r
- }\r
- }\r
-\r
// Compare expected values with reached ones\r
Object expectedValue = contextAware.getExpectedValues().get(key);\r
\r
+ if (expectedValue.toString().equals(\r
+ contextAware.getContextSkipFlag())) {\r
+ if (log.isDebugEnabled())\r
+ log.debug("Skipped check for key '" + key + "'");\r
+ continue;\r
+ }\r
+\r
+ // Register in structure\r
+ registerInStructure(testResult, treeSRelated, key);\r
+\r
if (contextAware.getValues().containsKey(key)) {\r
Object reachedValue = contextAware.getValues().get(key);\r
\r
- if (expectedValue.equals(reachedValue)) {\r
+ if (expectedValue.equals(contextAware.getContextAnyFlag())) {\r
+ testResult.addResultPart(new SimpleResultPart(\r
+ TestStatus.PASSED, "Expected any value for key '"\r
+ + key + "'"));\r
+ } else if (expectedValue.equals(reachedValue)) {\r
testResult.addResultPart(new SimpleResultPart(\r
TestStatus.PASSED, "Values matched for key '" + key\r
+ "'"));\r
TestStatus.FAILED, "No value reached for key '" + key\r
+ "'"));\r
}\r
+ resetStructure(testResult, treeSRelated);\r
+ }\r
+ }\r
+\r
+ private static void registerInStructure(TestResult testResult,\r
+ TreeSRelated treeSRelated, String key) {\r
+ if (treeSRelated != null) {\r
+ if (treeSRelated.getBasePath() != null) {\r
+ TreeSPath path = treeSRelated.getBasePath().createChild(key);\r
+ StructureRegistry<TreeSPath> registry = treeSRelated\r
+ .getRegistry();\r
+ final StructureElement element = treeSRelated\r
+ .getStructureElement(key);\r
+ registry.register(path, element);\r
+ if (testResult instanceof StructureAware)\r
+ ((StructureAware<TreeSPath>) testResult).notifyCurrentPath(\r
+ registry, path);\r
+\r
+ if (log.isDebugEnabled())\r
+ log.debug("Checking key " + key + " for path " + path);\r
+ }\r
+ }\r
+ }\r
\r
- if (treeSRelated != null) {\r
- if (treeSRelated.getBasePath() != null) {\r
- if (testResult instanceof StructureAware) {\r
- ((StructureAware<TreeSPath>) testResult)\r
- .notifyCurrentPath(treeSRelated.getRegistry(),\r
- treeSRelated.getBasePath());\r
- }\r
+ private static void resetStructure(TestResult testResult,\r
+ TreeSRelated treeSRelated) {\r
+ if (treeSRelated != null) {\r
+ if (treeSRelated.getBasePath() != null) {\r
+ if (testResult instanceof StructureAware) {\r
+ ((StructureAware<TreeSPath>) testResult).notifyCurrentPath(\r
+ treeSRelated.getRegistry(), treeSRelated\r
+ .getBasePath());\r
}\r
}\r
}\r
* Put into common map the values from child map which are not already\r
* defined in common map.\r
*/\r
- private static void putNotContained(Map<String, Object> commonMap,\r
+ public static void putNotContained(Map<String, Object> commonMap,\r
Map<String, Object> childMap) {\r
for (String key : childMap.keySet()) {\r
if (!commonMap.containsKey(key)) {\r
}\r
\r
/** Overrides child map values with the values already set in common map */\r
- private static void overrideContained(Map<String, Object> commonMap,\r
+ public static void overrideContained(Map<String, Object> commonMap,\r
Map<String, Object> childMap) {\r
for (String key : childMap.keySet()) {\r
if (commonMap.containsKey(key)) {\r