Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CanCreateRelationshipUseCase and handling of expired Relationship…
…Templates (#212) * Fix: throw error when responding to Request of expired RelationshipTemplate * fix: throw error when try to create Relationship with expired RelationshipTemplate * test: add first version of test * feat: adjust auxiliary function for RelationshipTemplate * feat: adjust createTemplate testUtil function * fix: return error instead of throwing error * test: temporary changes for tests * fix: test by using auxiliary function * test: shortened test duration * chore: comment out code more consistently * chore: make default expirationDateTime recognizable * chore: add error for delay function * feat: LocalRequest is expired when source RelationshipTemplate is expired * test: add test for CreateRelationshipUseCase * chore: remove comments * test: add tests for updateStatusBasedOnTemplateExpiration function * chore: adjust isExpired function for reasons of consistency * fix: ensure to throw error only if no other is more relevant * chore: adjust test naming to be more appropriate * fix: ensure more precisely to throw error only if no other is more relevant * feat: throw error only for onNewRelationship * fix: prettier * chore: renaming variables and use $in operator * feat: implement canCreate route for Relationships * chore: use CanCreateRelationshipUseCase in other use cases * chore: use CanCreateRelationshipUseCase in more other use cases * chore: rename error message relationshipAlreadyExists * refactor: naming of response variable of CanCreateRelationshipUseCase * fix: do not use CanCreateRelationshipUseCase in other UseCases * feat: add noRequestToAccept error for CanCreateRelationshipUseCase * refactor: do not expose the term LocalRequest in error messages * feat: expose CanCreateRelationshipUseCase to facade * test: should not create Relationship with CreateRelationshipUseCase if RelationshipTemplateContent used * feat: use CreateRelationshipUseCase only for ArbitraryRelationshipTemplateContent * fix: missing imports * fix: unused import * chore: build schema of CanCreateRelationshipUseCase * refactor: choose more appropriate variable name * chore: reduce CanCreateRelationshipUseCase to split pull requests * chore: reduce CanCreateRelationshipUseCase to split pull requests * fix: error message of CreateRelationship use case * feat: update expiry of Requests also within CreateRelationshipUseCase * fix: error message used for contradicting cases * feat: only allow Request which expires after RelationshipTemplate for new Relationships * test: request for new Relationship cannot expire after RelationshipTemplate * fix: tests for expiration date of Requests * refactor: rename to error for Relationships instead of RelationshipTemplates * chore: remove unused Runtime error * refactor: throw only Runtime errors in use cases * refactor: add function for getting existing Relationships * refactor: reuse CreateRelationshipRequest for CanCreateUseCase * fix: incorrect use of recordNotFound error * feat: define canSendRelationship method in Controller * fix: failed Result for CanAcceptIncomingRequest and CanRejectIncomingRequest use cases * feat: add canCreateRelationship Backbone service * fix: value not used for sendRelationship method * fix: value not used for sendRelationship method * feat: use canCreate route of Backbone * fix: request type of canCreateRelationship Backbone route * fix: canCreateRelationship Backbone route * fix: return value of canCreateRelationship Backbone route * refactor: use variable for peerAddress * chore: do not use imprecise Backbone result * fix: return value of canSendRelationship method * feat: use canSendRelationship method in corresponding use case * chore: remove unneccessary type conversion * feat: incorporate RelationshipTemplate expiry in canSendRelationship method * refactor: CanCreateRelationshipUseCase * feat: taking rejected Requests into account * refactor: return code and message instead of error to avoid misunderstandings * refactor: take rejected Requests at a lower level into account * chore: simply code because cases handled at a lower level * feat: handle expired RelationshipTemplate error appropriately * test: does not change status of rejected Request when RelationshipTemplate expires * fix: tests * chore: update Backbone version * test: automatic update of Request of expired RelationshipTemplate * test: CanCreateRelationshipUseCase * fix: LocalRequest test * refactor: rename temporary error message * chore: remove todo comments * feat: apply Request expiry update in GetIncomingRequest(s)UseCase * test: update Request status to expired when querying Requests if RelationshipTemplate expired * chore: remove unused Runtime error relationshipCurrentlyExists * chore: use imported sleep function instead of own delay function * feat: add minimum of type validation for creationContent of CanCreateRelationshipUseCase * feat: integrate comments * fix: adjust test * feat: generate expiration date for Request in onNewRelationship property if none is set * refactor: use elvis operator * test: remove assertIsCanCreateRelationshipFailureResponse * feat: update expirationDate of Request if RelationshipTemplate expires * test: set expiresAt of Request if none provided * fix: clone template content in tests * feat: remove 10 second tolerance * refactor: move validation into controller * refactor: getExistingRelationship * feat: add min to CoreDate * refactor: remove updates from create rel and get request use cases * feat/refactor: update after received, update during get * refactor: adapt local request * refactor: rename incoming requests getter * refactor: remove now unnecessary validation * fix: remove debugging stuff from tests * fix: consumption * fix: runtime tests * test: reduce sleep duration after removing tolerance * test/fix: add tests and fix revealed errors * test: typos and status settings * chore: remove unused package * test: sleep longer * refactor/test: getOutgoingRequestWithUpdateExpiry and use it * refactor: try-catch in sendRelationship * fix: adapt the tests to the refactoring * fix: more adaptations * feat: canCreate never throws * feat: canCreate with error codes * refactor: use regex, debugging cleanup * fix: variable access * fix: unfound typescript-ioc module * fix: unused caught error * fix: unknown transportServices1 variable * fix: failing test of DeciderModule * fix: shady instanceOf check * refactor: add empty line * refactor: switch some lines in tests * test: proper variable naming * refactor: remove redundant test * refactor: rephrase of test name to give more context * fix: copy-paste error in tests * chore: bump backbone * refactor: remove unused code from request controller * test: emphazise tests expecting errors * refactor: re-simplify naming * fix: do not get the template for every incoming request query * refactor: de-dupe code * refactor: remove empty line again * refactor: distinguish success and failure response of CanCreateRelationshipUseCase * fix: use correct CanCreateRelationshipResonse type in tests * refactor: remove unused expiration code * refactor: simplify * fix: satisfy compiler --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Milena Czierlinski <[email protected]> Co-authored-by: mkuhn <[email protected]> Co-authored-by: Magnus Kuhn <[email protected]> Co-authored-by: Julian König <[email protected]>
- Loading branch information