stable

Clone or download

Read-only

refactor: introduce AddReverseLinksCommand

How to test: - No functional change in the REST API POST /artifacts. You can still set reverse links through the "all_links" key. Notes: - Having a distinct Command object for the "Creation" case is better, because it's impossible to change the type or delete a reverse link to an artifact that does not yet exist. When creating an artifact, you can only add new reverse links. Having distinct objects should help us avoid mixing those cases. - Introducing an intermediary "converter" objects that builds changesets from Command objects has several advantages. It isolates the logic of "flipping" reverse links to forward links in the "domain" of trackers, where we only deal with business objects. It also lets us unit-test its output in details: it is easier to assert directly on NewChangeset objects than to have a stub and ask it for its last parameters. This intermediary will also be reused in the "update" case and will completely replace ArtifactUpdateHandler. - FieldsDataBuilder stubs are completely removed. As they do not deal with DB directly, we should use the real objects and stub their dependencies (which are few). This lets us do a "sociable" test: in ArtifactCreatorTest, we can give it an array of Representation objects, mock only the DB accesses (for fields, artifacts) and assert that we created the expected reverse link changesets. part of request #34374 Be able to explicitly add, change or remove forward and reverse links Change-Id: Ib3ac0f4c5c92c6d9f92b6a3ef4da0a1d4b3dafbc

Modified Files

Name
M plugins/kanban/include/Kanban/REST/v1/KanbanItemsResource.php +4 −3 Go to diff View file
M plugins/testmanagement/include/TestManagement/REST/v1/CampaignsResource.class.php +4 −3 Go to diff View file
M plugins/testmanagement/include/TestManagement/REST/v1/ExecutionsResource.class.php +4 −3 Go to diff View file
R plugins/tracker/include/REST/Artifact/ArtifactCreator.class.php Go to diff View file
D plugins/tracker/include/REST/Artifact/ChangesetValue/BuildFieldDataFromValuesByField.php +0 −30 Go to diff View file
D plugins/tracker/include/REST/Artifact/ChangesetValue/BuildFieldsData.php +0 −45 Go to diff View file
M plugins/tracker/include/REST/Artifact/ChangesetValue/FieldsDataBuilder.php +1 −1 Go to diff View file
M plugins/tracker/include/REST/Artifact/ChangesetValue/FieldsDataFromValuesByFieldBuilder.php +1 −1 Go to diff View file
M plugins/tracker/include/REST/v1/ArtifactsResource.class.php +4 −2 Go to diff View file
A plugins/tracker/include/Tracker/Artifact/ChangesetValue/ArtifactLink/AddReverseLinksCommand.php +53 −0 Go to diff View file
A plugins/tracker/include/Tracker/Artifact/ChangesetValue/ArtifactLink/ReverseLinksToNewChangesetsConverter.php +140 −0 Go to diff View file
M plugins/tracker/tests/unit/Builders/ArtifactLinkFieldBuilder.php +6 −0 Go to diff View file
M plugins/tracker/tests/unit/Builders/ArtifactValuesRepresentationBuilder.php +1 −2 Go to diff View file
M plugins/tracker/tests/unit/REST/Artifact/ArtifactCreatorTest.php +233 −51 Go to diff View file
D plugins/tracker/tests/unit/Stub/BuildFieldDataFromValuesByFieldStub.php +0 −73 Go to diff View file
D plugins/tracker/tests/unit/Stub/BuildFieldsDataStub.php +0 −84 Go to diff View file
A plugins/tracker/tests/unit/Tracker/Artifact/ChangesetValue/ArtifactLink/AddReverseLinksCommandTest.php +46 −0 Go to diff View file
M plugins/tracker/tests/unit/Tracker/Artifact/ChangesetValue/ArtifactLink/NewArtifactLinkInitialChangesetValueTest.php +1 −0 Go to diff View file
A plugins/tracker/tests/unit/Tracker/Artifact/ChangesetValue/ArtifactLink/ReverseLinksToNewChangesetsConverterTest.php +155 −0 Go to diff View file