use of org.mule.runtime.api.notification.PolicyNotificationListener in project mule by mulesoft.
the class ApplicationPolicyDeploymentTestCase method appliesApplicationPolicyWithNotificationListener.
@Test
public void appliesApplicationPolicyWithNotificationListener() throws Exception {
policyManager.registerPolicyTemplate(fooPolicyFileBuilder.getArtifactFile());
ApplicationFileBuilder applicationFileBuilder = createExtensionApplicationWithServices(APP_WITH_EXTENSION_PLUGIN_CONFIG, helloExtensionV1Plugin);
addPackedAppFromBuilder(applicationFileBuilder);
startDeployment();
assertApplicationDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder.getId());
List<Integer> notificationListenerActionIds = new ArrayList<>();
PolicyNotificationListener<PolicyNotification> notificationListener = notification -> notificationListenerActionIds.add(notification.getAction().getActionId());
policyManager.addPolicy(applicationFileBuilder.getId(), fooPolicyFileBuilder.getArtifactId(), new PolicyParametrization(FOO_POLICY_ID, pointparameters -> true, 1, singletonMap(POLICY_PROPERTY_KEY, POLICY_PROPERTY_VALUE), getResourceFile("/fooPolicy.xml"), singletonList(notificationListener)));
executeApplicationFlow("main");
assertThat(invocationCount, equalTo(1));
new PollingProber(POLICY_NOTIFICATION_TIMEOUT, 100).check(new JUnitProbe() {
@Override
protected boolean test() throws Exception {
assertThat(notificationListenerActionIds, hasSize(4));
assertThat(notificationListenerActionIds, hasItems(PROCESS_START, BEFORE_NEXT, AFTER_NEXT, PROCESS_END));
return true;
}
});
}
Aggregations