Github user mikezaccardo commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/1066#discussion_r45933970
--- Diff:
usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleShellCommandTestImpl.java
---
@@ -228,89 +238,14 @@ private static String
getLastPartOfPath(Iterable<String> path, String defaultNam
return scriptName;
}
- private <T> void checkAssertions(AssertionSupport support, Map<?, ?>
assertions, String target, T actual) {
- if (null == assertions) {
- return;
- }
- if (null == actual) {
- support.fail(target, "no actual value", "");
- return;
- }
- for (Map.Entry<?, ?> assertion : assertions.entrySet()) {
- String condition = assertion.getKey().toString();
- Object expected = assertion.getValue();
- switch (condition) {
- case EQUALS :
- if (!actual.equals(expected)) {
- support.fail(target, EQUALS, expected);
- }
- break;
- case CONTAINS :
- if (!actual.toString().contains(expected.toString())) {
- support.fail(target, CONTAINS, expected);
- }
- break;
- case IS_EMPTY:
- if (!actual.toString().isEmpty() && truth(expected)) {
- support.fail(target, IS_EMPTY, expected);
- }
- break;
- case MATCHES :
- if (!actual.toString().matches(expected.toString())) {
- support.fail(target, MATCHES, expected);
- }
- break;
- default:
- support.fail(target, "unknown condition", condition);
- }
- }
- }
- private Map<?, ?> exitCodeAssertions() {
- Map<?, ?> assertStatus = getConfig(ASSERT_STATUS);
- if (isEmpty(assertStatus)) {
- assertStatus = ImmutableMap.of(EQUALS, SUCCESS);
+ private List<Map<String, Object>> exitCodeAssertions() {
+ List<Map<String, Object>> assertStatus = getConfig(ASSERT_STATUS);
+ if (assertStatus.isEmpty()) {
+ Map<String, Object> shouldSucceed =
ImmutableMap.<String,Object>of(EQUALS, SUCCESS);
--- End diff --
Might be nice to define this as a member variable `DEFAULT_ASSERTION` or
the like, for clarity.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---