Skip to content

Commit

Permalink
Merge branch 'master' into alias-for-ontransitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Voycawojka committed Jul 15, 2020
2 parents 9a4a4e9 + cd1d87b commit b70764a
Show file tree
Hide file tree
Showing 41 changed files with 218 additions and 160 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ All notable changes to `knotx-fragments` will be documented in this file.

## Unreleased
List of changes that are finished but not yet released in any final version.
- [PR-170](https://github.com/Knotx/knotx-stack/pull/170) - Upgrade to Vert.x `3.9.1`, replace deprecated `setHandler` with `onComplete`.

## 2.2.1
- [PR-165](https://github.com/Knotx/knotx-stack/pull/165) - Knotx/knotx-fragments#161 enable passing status code from handlers to end user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void apply(FragmentContext fragmentContext,
.onErrorReturn(
error -> handleFailure(fragmentContext, actionLogger, error))
.map(Future::succeededFuture)
.doOnSuccess(future -> future.setHandler(resultHandler))
.doOnSuccess(future -> future.onComplete(resultHandler))
.subscribe();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private void successTransition(FragmentContext fragmentContext, ActionLogger act
Future<FragmentResult> resultFuture = Future.succeededFuture(
new FragmentResult(fragmentContext.getFragment(), FragmentResult.SUCCESS_TRANSITION,
actionLogger.toLog().toJson()));
resultFuture.setHandler(resultHandler);
resultFuture.onComplete(resultHandler);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void successTransition(FragmentContext fragmentContext, ActionLogger act
Future<FragmentResult> resultFuture = Future.succeededFuture(
new FragmentResult(fragmentContext.getFragment(), FragmentResult.SUCCESS_TRANSITION,
actionLogger.toLog().toJson()));
resultFuture.setHandler(resultHandler);
resultFuture.onComplete(resultHandler);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public Action create(String alias, JsonObject config, Vertx vertx, Action doActi
.orElse(new FragmentResult(fragment, FragmentResult.ERROR_TRANSITION));

Future<FragmentResult> resultFuture = succeededFuture(result);
resultFuture.setHandler(resultHandler);
resultFuture.onComplete(resultHandler);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void apply(FragmentContext fragmentContext,
circuitBreaker.executeWithFallback(
promise -> executeCommand(promise, fragmentContext, counter, actionLogger),
throwable -> handleFallback(fragmentContext, throwable, counter, actionLogger)
).setHandler(resultHandler);
).onComplete(resultHandler);
}

private void executeCommand(Promise<FragmentResult> promise, FragmentContext fragmentContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void apply(FragmentContext fragmentContext,
Single.just(fragmentContext)
.flatMap(this::process)
.map(Future::succeededFuture)
.map(future -> future.setHandler(resultHandler))
.map(future -> future.onComplete(resultHandler))
.subscribe();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void callActionWithSuccessTransition(VertxTestContext testContext) throws Throwa
// given
Action doAction = (fragmentContext, resultHandler) -> Future
.succeededFuture(new FragmentResult(firstFragment, FragmentResult.SUCCESS_TRANSITION))
.setHandler(resultHandler);
.onComplete(resultHandler);

Action tested = new InMemoryCacheActionFactory()
.create(ACTION_ALIAS, ACTION_CONFIG, null, doAction);
Expand All @@ -88,7 +88,7 @@ void callActionWithErrorTransition(VertxTestContext testContext) throws Throwabl
// given
Action doAction = (fragmentContext, resultHandler) -> Future
.succeededFuture(new FragmentResult(firstFragment, ERROR_TRANSITION))
.setHandler(resultHandler);
.onComplete(resultHandler);

Action tested = new InMemoryCacheActionFactory()
.create(ACTION_ALIAS, ACTION_CONFIG, null, doAction);
Expand Down Expand Up @@ -116,7 +116,7 @@ void callActionThatThrowsException(VertxTestContext testContext) throws Throwabl
// given
Action doAction = (fragmentContext, resultHandler) -> Future
.<FragmentResult>failedFuture(new IllegalStateException())
.setHandler(resultHandler);
.onComplete(resultHandler);

Action tested = new InMemoryCacheActionFactory()
.create(ACTION_ALIAS, ACTION_CONFIG, null, doAction);
Expand Down Expand Up @@ -150,7 +150,7 @@ void callActionWithPayloadUpdate(VertxTestContext testContext) throws Throwable
fragment.appendPayload(PAYLOAD_KEY, expectedPayloadValue);
Future
.succeededFuture(new FragmentResult(fragment, FragmentResult.SUCCESS_TRANSITION))
.setHandler(resultHandler);
.onComplete(resultHandler);
};

Action tested = new InMemoryCacheActionFactory()
Expand Down Expand Up @@ -183,7 +183,7 @@ void callDoActionTwice(VertxTestContext testContext) throws Throwable {
fragment.appendPayload(PAYLOAD_KEY, uniqueValue(fragmentContext.hashCode()));
Future
.succeededFuture(new FragmentResult(fragment, FragmentResult.SUCCESS_TRANSITION))
.setHandler(resultHandler);
.onComplete(resultHandler);
};

Action tested = new InMemoryCacheActionFactory()
Expand Down Expand Up @@ -215,7 +215,7 @@ void callDoActionOnce(VertxTestContext testContext) throws Throwable {
fragment.appendPayload(PAYLOAD_KEY, uniqueValue(fragmentContext.hashCode()));
Future
.succeededFuture(new FragmentResult(fragment, FragmentResult.SUCCESS_TRANSITION))
.setHandler(resultHandler);
.onComplete(resultHandler);
};

Action tested = new InMemoryCacheActionFactory()
Expand Down Expand Up @@ -247,7 +247,7 @@ void callActionsDifferentCacheKeys(VertxTestContext testContext) throws Throwabl
fragment.appendPayload(PAYLOAD_KEY, uniqueValue(fragmentContext.hashCode()));
Future
.succeededFuture(new FragmentResult(fragment, FragmentResult.SUCCESS_TRANSITION))
.setHandler(resultHandler);
.onComplete(resultHandler);
};

Action tested = new InMemoryCacheActionFactory()
Expand Down Expand Up @@ -287,13 +287,13 @@ void callDoActionWithErrorAndDoActionWithSuccess(VertxTestContext testContext) t
if (fragmentContext.getClientRequest().getParams().contains("error")) {
Future
.<FragmentResult>failedFuture(new IllegalStateException())
.setHandler(resultHandler);
.onComplete(resultHandler);
} else {
Fragment fragment = fragmentContext.getFragment();
fragment.appendPayload(PAYLOAD_KEY, expectedPayloadValue);
Future
.succeededFuture(new FragmentResult(fragment, FragmentResult.SUCCESS_TRANSITION))
.setHandler(resultHandler);
.onComplete(resultHandler);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static void applySuccess(FragmentContext fragmentContext,
actionLogger.info("info", "success");
Future.succeededFuture(new FragmentResult(fragmentContext.getFragment(), SUCCESS_TRANSITION,
actionLogger.toLog().toJson()))
.setHandler(resultHandler);
.onComplete(resultHandler);
}

static void applyCustomTransition(FragmentContext fragmentContext,
Expand All @@ -48,7 +48,7 @@ static void applyCustomTransition(FragmentContext fragmentContext,
actionLogger.info("info", "custom");
Future.succeededFuture(new FragmentResult(fragmentContext.getFragment(), CUSTOM_TRANSITION,
actionLogger.toLog().toJson()))
.setHandler(resultHandler);
.onComplete(resultHandler);
}

static void applyErrorTransition(FragmentContext fragmentContext,
Expand All @@ -57,15 +57,15 @@ static void applyErrorTransition(FragmentContext fragmentContext,
actionLogger.info("info", "error");
Future.succeededFuture(new FragmentResult(fragmentContext.getFragment(), ERROR_TRANSITION,
actionLogger.toLog().toJson()))
.setHandler(resultHandler);
.onComplete(resultHandler);
}

static void applyFailure(FragmentContext fragmentContext,
Handler<AsyncResult<FragmentResult>> resultHandler) {
ActionLogger actionLogger = ActionLogger.create("action", INFO);
actionLogger.info("info", "failure");
Future.<FragmentResult>failedFuture(new IllegalStateException("Application failed!"))
.setHandler(resultHandler);
.onComplete(resultHandler);
}

static void applyException(FragmentContext fragmentContext,
Expand All @@ -80,7 +80,7 @@ static void applySuccessDelay(FragmentContext fragmentContext,
l ->
Future.succeededFuture(
new FragmentResult(fragmentContext.getFragment(), SUCCESS_TRANSITION)
).setHandler(resultHandler));
).onComplete(resultHandler));
}

static Action applyOneAfterAnother(Action first, Action second) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void callActionWithPayloadUpdate(JsonObject configuration, boolean isLogLevelInf
fragment.appendPayload(PAYLOAD_KEY, expectedPayloadValue);
Future
.succeededFuture(new FragmentResult(fragment, FragmentResult.SUCCESS_TRANSITION))
.setHandler(resultHandler);
.onComplete(resultHandler);
};

Action tested = new InMemoryCacheActionFactory()
Expand Down Expand Up @@ -128,7 +128,7 @@ void callActionTwiceWithTheSameKey(JsonObject configuration, boolean isLogLevelI
fragment.appendPayload(PAYLOAD_KEY, expectedPayloadValue);
Future
.succeededFuture(new FragmentResult(fragment, FragmentResult.SUCCESS_TRANSITION))
.setHandler(resultHandler);
.onComplete(resultHandler);
};

Action tested = new InMemoryCacheActionFactory()
Expand Down Expand Up @@ -176,7 +176,7 @@ void callActionWithDoActionReturningSuccessTransition(JsonObject configuration,
.succeededFuture(
new FragmentResult(fragmentContext.getFragment(), FragmentResult.SUCCESS_TRANSITION,
innerActionLog.toLog().toJson()))
.setHandler(resultHandler);
.onComplete(resultHandler);

Action tested = new InMemoryCacheActionFactory()
.create(ACTION_ALIAS, configuration, null, doAction);
Expand Down Expand Up @@ -222,7 +222,7 @@ void callActionWithDoActionReturningErrorTransition(JsonObject configuration,
.succeededFuture(
new FragmentResult(fragmentContext.getFragment(), FragmentResult.ERROR_TRANSITION,
innerActionLog.toLog().toJson()))
.setHandler(resultHandler);
.onComplete(resultHandler);

Action tested = new InMemoryCacheActionFactory()
.create(ACTION_ALIAS, configuration, null, doAction);
Expand Down Expand Up @@ -258,7 +258,7 @@ void callActionThatDoesNotAddPayload(JsonObject configuration, boolean isLogLeve
Action doAction = (fragmentContext, resultHandler) -> Future
.succeededFuture(
new FragmentResult(fragmentContext.getFragment(), FragmentResult.SUCCESS_TRANSITION))
.setHandler(resultHandler);
.onComplete(resultHandler);

Action tested = new InMemoryCacheActionFactory()
.create(ACTION_ALIAS, configuration, null, doAction);
Expand Down Expand Up @@ -288,7 +288,7 @@ void callActionCausingFailure(JsonObject configuration, boolean isLogLevelInfo,
VertxTestContext testContext) throws Throwable {
Action doAction = (fragmentContext, resultHandler) -> Future
.<FragmentResult>failedFuture(new IllegalStateException("Application failed!"))
.setHandler(resultHandler);
.onComplete(resultHandler);

Action tested = new InMemoryCacheActionFactory()
.create(ACTION_ALIAS, configuration, null, doAction);
Expand Down
Loading

0 comments on commit b70764a

Please sign in to comment.