Commit graph

134 commits

Author SHA1 Message Date
Sipke Schoorstra 489750432a Remove Email and UserTask projects from Elsa project 2021-04-21 14:46:17 +02:00
Sipke Schoorstra d9094575fd Remove unused namespaces 2021-04-16 12:48:06 +02:00
Craig Fowler fa7601ca1a WIP #751 - Add integration test for using Postgres
From this commit onwards, in order to run all of the tests, you
must now have postgresql installed and running on your dev
environment.  The credentials/config is:
* Database name: elsa-yessql
* Username: postgres (this is the default anyway)
* Password: Password12! (this matches AppVeyor's postgres password)
* Port: 5432 (this is the default anyway)
2021-04-07 20:38:13 +01:00
Sipke Schoorstra a3e7b1e023 Disable YesSQL test (temp) 2021-04-07 15:06:30 +02:00
Sipke Schoorstra ae46e0e143 Update packages and accommodate for breaking changes 2021-04-07 14:48:30 +02:00
Sipke Schoorstra ce957b95e7 Cleanup 2021-04-07 13:13:13 +02:00
Sipke Schoorstra df6ad74eec Replace custom distributed locking implementation with DistributedLock
https://github.com/madelson/DistributedLock
2021-04-07 13:13:13 +02:00
Craig Fowler 8413cb0e55
Merge pull request #834 from craigfowler/composable-autofixture-attributes
Add composable autofixture attributes
2021-04-02 21:04:18 +01:00
Craig Fowler 189b4a69bb
Correct typo 2021-04-02 21:03:33 +01:00
Sipke Schoorstra a6d05cfce0 Remove StringValuesModel
Deserialization causes problems when a value is a single string
2021-04-02 16:52:31 +02:00
Craig Fowler da88ee1b95 Trivial: Make running tests less noisy 2021-04-02 13:46:47 +01:00
Craig Fowler 2e3aef2740 Merge remote-tracking branch 'elsa-core/feature/elsa-2.0' into 751-postgres-yessql-exception 2021-04-02 13:46:13 +01:00
Craig Fowler 7044e69231 Refactor one test to use new Autofixture resolution attribute
This change means that a service provider may use both the Frozen
specimen builder and also the 'with autofixture resolution' behaviour.
That means that some unwanted extra logic in the test may now be
removed, with the test objects also coming from Autofixture.
2021-04-02 13:29:46 +01:00
Craig Fowler 282c90f80f Further fixup & refactoring of Autofixture attribs
This now also includes reworking the attribute which activates
Autofixture-style resolution upon an IServiceProvider.
This has now been renamed to WithAutofixtureResolutionAttribute.

The new/reworked attribute is composable with other Autofixture
attributes.
2021-04-02 13:28:27 +01:00
Craig Fowler f2b27480fc Trivial - remove redundant types 2021-04-02 12:08:05 +01:00
Sipke Schoorstra 881f0acb7a Fix tests 2021-04-02 12:43:14 +02:00
Sipke Schoorstra 23e3d1fd81 Fix JavaScriptExpressionsIntegrationTests 2021-04-02 12:43:14 +02:00
Sipke Schoorstra 38be994e31 Break up WorkflowRunner into smaller types and extracted reusable trigger logic 2021-04-02 12:43:14 +02:00
Sipke Schoorstra 4cf43882dc Update packages 2021-04-02 12:43:14 +02:00
Sipke Schoorstra 5796cf2893 Fix warnings and formatting 2021-04-02 12:43:14 +02:00
Craig Fowler 8379d4a70c Complete refactoring for composable attributes
This takes the work begun in
  d285b8b505
and completes it for all other attributes/usages.
2021-04-02 11:41:06 +01:00
Craig Fowler 088cf7fdf6 Merge remote-tracking branch 'elsa-core/feature/elsa-2.0' into 751-postgres-yessql-exception 2021-04-02 11:14:16 +01:00
Craig Fowler d285b8b505 WIP composing customize attributes
This isn't really related to #751 - it's a refactor of some of
our test logic, to avoid bloat of semi-repeated autofixture
customization attributes.

By switching to a behaviour-driven model, it's possible to
compose them, which means that there's no need to part-duplicate
between them.  It should also reduce the overall number of them,
as combinations can be put together on-demand, rather than needing
a new attribute of their own.
2021-04-02 11:12:21 +01:00
Craig Fowler e21154f7b8 Fixup for #761 - Now with 100% fewer compile errors!
Yeah, my bad :D
2021-04-01 20:25:09 +02:00
Craig Fowler 0eaa11e69d Trivial - correct a typo in class naming 2021-04-01 20:25:09 +02:00
Craig Fowler 8e16f5f269 Related to #761 - Refactor complex conversion
This removes all of the (now actually non-trivial) conversion logic from
the class which is actually responsible for executing the Jint engine.
This moves it all to a new service which uses chain of responsibility to
convert the result, using one of a few different mechanisms.

Of note is the handling of ExpandoObject when no specific type
information has been provided, and also the handling of enumerables,
with the exception of strings.
2021-04-01 20:25:09 +02:00
Craig Fowler 4b5d86135d Follow-up #761 - Fix for recursive case
Unfortunately Jint still chokes in this case if the expando contains
further nested expandos.  It turns out that I need to do this
recursively for it to always work.

We also have trouble with IEnumerable types.  They also can't be
round-tripped from/to JSON when they aren't deserialized as a very
specific type.
2021-04-01 20:25:09 +02:00
Craig Fowler 7ed875e53c Resolve #761 - Add special-case for ExpandoObject
It appears that this can be fixed by intercepting occasions
when Jint returns an ExpandoObject but the desired return type
is simply object.  In this scenario we must return
a Dictionary<string,object> instead of a simple object, or else
Jint freaks out should we try to stringify it later.

I also added a second test to prove that making this change hasn't
broken the way we expect Jint to work for us.
2021-04-01 20:25:09 +02:00
Craig Fowler dd9c1f5cdc WIP #761 - Unit test indicates location of problem
This unit test narrows the problem down to the class
JavaScriptService.
2021-04-01 20:25:09 +02:00
Craig Fowler 84f3d3d32c WIP #761 - Integration test reproduces problem
StackOverflowException reproduced exactly as reported.
2021-04-01 20:25:09 +02:00
Craig Fowler ef117eced7 Trivial - correct a typo in class naming
This is a cherry-pick to get the same fix into this branch.
2021-04-01 19:04:28 +01:00
Sipke Schoorstra 6fef9874da **BREAKING API** Update Builder API to allow to connect to named activities as well as activities by type name
This replaces the `Then(string activityName)` method with `ThenNamed(string activityName)`.
A new method is added to allow connecting to activities by type name: `ThenTypeNamed(string activityTypeName)`.

The reason for this change and addition is to allow workflow builders to connect to activity types that do not have a corresponding type.
For example, the Telnyx project has an activity type provider that *dynamically* provides activity types based on Telnyx webhook callback types.
2021-03-26 11:40:22 +01:00
Craig Fowler a81d47afff Resolve #785 - improve API for StringValuesModel
This means that the model:
* Implements IConvertible so that Jint may implicitly convert
  it to other types as if it were just a string.
* The Values & Values properties are perhaps a little less confusing
  now, and present a more consistent set of state, regardless of
  the inner model.
* There's a minor simplification to ToString, since String.Join already
  did what we wanted for one or many values.

Notable though is - because this class implements IConvertible,
it is no longer CLS compliant.  We do not currently mark this assembly
as CLS complient so as things stand that's OK.  I do not know if there
are any plans/expectations for CLS compliance in Elsa.

If we do plan to mark the assemblies as compliant then we must mark this
class [CLSCompliant(false)].
2021-03-25 21:10:25 +00:00
Craig Fowler ee7a8cdb1b
Merge pull request #775 from craigfowler/feature/738-Composite-Activities-may-be-triggers
Refactor for comprehension & add test coverage
2021-03-20 11:29:28 +00:00
Craig Fowler f91e224314 Fix intermittent failing tests
The issue here is that the elsa.db for sqlite is going in the same
path every time.  Depending on the order in which tests are run,
sometimes it means that migrations are run on a DB which is
expected to be empty but which already exists.  That causes an
error & test failure.

Here I've just used temp folders to ensure that the DB file is in a
different path every time.
2021-03-20 11:14:35 +00:00
Craig Fowler 2539f6425a WIP #738 - Integration tests for Trigger Indexer
One of these tests is failing and this is the one which
demonstrates issue #738. The composite activity which begins
with ReceiveSignal doesn't generate a trigger.
2021-03-20 10:42:41 +00:00
Craig Fowler 3943e64c70 WIP #738 - Add test coverage to replace big test
The large/complex test is now removed, replaced by
smaller/simpler unit tests for the individual units in
the overall process of getting triggers.
2021-03-19 19:45:16 +00:00
Craig Fowler 6700ac2402 WIP #738 - Simplify unit test
Now that the class is a little less complex, this
simplified unit test covers just what remains.
2021-03-18 21:22:19 +00:00
Craig Fowler 9ec698c7bc WIP #738 - Refactor a troublesome extension method
This extension method is quite complex and is frustrating
when a unit test passes-through it.  That's because extension
methods can't be mocked in tests.
2021-03-18 21:09:04 +00:00
Craig Fowler d9724e5267 WIP #738 - Refactor-out a further service
The triggers-for-activity-blueprint functionality
is quite complex just on its own, so I have moved this to
a new service.

Once again the integration test which is left behind proves
that it still does the same job.
2021-03-18 20:29:06 +00:00
Craig Fowler 654f3072d9 WIP #738 - Refactor some logic into services
This simplifies the unit a little and the test proves that
it still does the same thing overall.  Strictly speaking, this
is now an integration test.
2021-03-18 19:35:05 +00:00
Craig Fowler 1dee17b904 WIP #738 - Add test coverage for new service
This test passes, but as you can see it's
massive because of the complexity of what the
class has to do.
2021-03-18 18:54:23 +00:00
Sipke Schoorstra 0434b4825a Update packages 2021-03-18 11:24:04 +01:00
Sipke Schoorstra 0c15c94ea7
Telnyx Activities (#768)
* Fix liquid syntax for accessing activity output

* Initial scaffolding of Telnyx module + API changes

* Make Telnyx Notification activity blocking

* Implement Telnyx correlation

* Post workflow suspension tasks improvements

* Add Telnyx activities

* Add HangupCall and TransferCall activities

* Call activity improvements
2021-03-17 13:07:14 +01:00
Craig Fowler 4bc3539c4d
Merge branch 'feature/elsa-2.0' into feature/748-multi-tenant-EntityFramework 2021-03-14 13:51:06 +00:00
Craig Fowler 2320d216f2
Resolve #683 - Tests to prove no exception (#758)
As stated in the comments for
  WorkflowMayContainDuplicateActivitiesIntegrationTests

These tests might not describe actually-desired behaviour.
If they begin to "get in the way" in future, then it would
probably be safe to remove them.
2021-03-14 14:38:58 +01:00
Craig Fowler 4873aac316 Resolve #748 - Test coverage for EF Db Contexts
As well as providing a unit test which matches other persistence
provider tests (round-tripping a workflow instance), two other tests
are included here:

* When using the default DI registration extension method, this sets
  up pooling of DB contexts and so a resolved context will come from
  the pool.

* When using the non-pooled DI registration extension method, this
  sets up EF without pooling, which is more useful in a multi-tenanted
  environment.

There are also some other changes in this commit corresponding to
improving the tests.  Mainly de-duplicating logic & improving names.
2021-03-13 15:21:44 +00:00
Sipke Schoorstra 044caf533f MongoDB provider improvements 2021-03-11 22:50:50 +01:00
Craig Fowler 8751bead5a WIP #728 - Make WorkflowBurst default behaviour
In the comments to #728 it was suggested that
WorkflowBurst persistence behaviour was a more
sane default.
2021-03-09 19:57:45 +00:00
Craig Fowler 32bcf9a751 WIP #728 - Add test cases for persistence
This also includes a change to the workflow used in the test-case.
There are quite complex reasons for this, as explained here:

  https://github.com/elsa-workflows/elsa-core/issues/728#issuecomment-794319236

The real crux of it is that the workflow must have an activity
which suspends it, and that activity that suspends the workflow
must not be the starting activity.  This is why I added an unused
set-variable activity as the starter.

This commit shows that the various persistence test cases _mostly_
work OK, with the one exception of ActivityExecuted.
2021-03-09 19:57:02 +00:00