Skip to content

Commit

Permalink
TASK: Adjust new change projection tests to dont handle discarding on…
Browse files Browse the repository at this point in the history
…e dimension for now
  • Loading branch information
mhsdesign committed Dec 5, 2024
1 parent 9e66ce6 commit ec01723
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Feature: Workspace publication - complex chained functionality
When the command PublishIndividualNodesFromWorkspace is executed with payload and exceptions are caught:
| Key | Value |
| workspaceName | "user-ws" |
| nodesToPublish | [{"dimensionSpacePoint": {"language": "de"}, "nodeAggregateId": "sir-david-nodenborough"}] |
| nodesToPublish | ["sir-david-nodenborough"] |
| newContentStreamId | "user-cs-id-rebased" |
Then the last command should have thrown the PartialWorkspaceRebaseFailed exception with:
| SequenceNumber | Event | Exception |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ abstract private function getObject(string $className): object;
public function iExpectTheChangeProjectionToHaveTheFollowingChangesInContentStream(TableNode $table, string $contentStreamId)
{
$changeFinder = $this->currentContentRepository->projectionState(ChangeFinder::class);
$changes = $changeFinder->findByContentStreamId(ContentStreamId::fromString($contentStreamId));
$changes = iterator_to_array($changeFinder->findByContentStreamId(ContentStreamId::fromString($contentStreamId)));

$tableRows = $table->getHash();
foreach ($changes as $change) {
Expand All @@ -63,14 +63,11 @@ public function iExpectTheChangeProjectionToHaveTheFollowingChangesInContentStre
}
}

if (count($tableRows) !== 0) {
$tableHeader = array_combine(array_values($table->getRow(0)), array_values($table->getRow(0)));
$tableRemain = $tableRows;
array_unshift($tableRemain, $tableHeader);

Assert::assertEmpty($tableRows, "Not all given changes where found." . PHP_EOL . (new TableNode($tableRemain))->getTableAsString());
}
Assert::assertSame(count($table->getHash()), $changes->count(), "More changes found as given.");
Assert::assertTrue(
$tableRows === [] && count($table->getHash()) === count($changes),
sprintf('Mismatch between all actual changes usages %s and leftover changes to match %s', json_encode($changes, JSON_PRETTY_PRINT), json_encode($tableRows, JSON_PRETTY_PRINT))
);
}

/**
Expand All @@ -79,8 +76,8 @@ public function iExpectTheChangeProjectionToHaveTheFollowingChangesInContentStre
public function iExpectTheChangeProjectionToHaveNoChangesInContentStream(string $contentStreamId)
{
$changeFinder = $this->currentContentRepository->projectionState(ChangeFinder::class);
$changes = $changeFinder->findByContentStreamId(ContentStreamId::fromString($contentStreamId));
$changes = iterator_to_array($changeFinder->findByContentStreamId(ContentStreamId::fromString($contentStreamId)));

Assert::assertSame(0, $changes->count(), "No changes expected.");
Assert::assertEmpty($changes, "No changes expected, got: " . json_encode($changes, JSON_PRETTY_PRINT));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Feature: Publish nodes partially without dimensions

When the command PublishIndividualNodesFromWorkspace is executed with payload:
| Key | Value |
| nodesToPublish | [{"workspaceName": "user-workspace", "dimensionSpacePoint": {}, "nodeAggregateId": "sir-david-nodenborough"}] |
| nodesToPublish | ["sir-david-nodenborough"] |
| contentStreamIdForRemainingPart | "user-cs-id-remaining" |

Then I expect the ChangeProjection to have the following changes in "user-cs-id-remaining":
Expand Down Expand Up @@ -99,7 +99,7 @@ Feature: Publish nodes partially without dimensions

When the command PublishIndividualNodesFromWorkspace is executed with payload:
| Key | Value |
| nodesToPublish | [{"workspaceName": "user-workspace", "dimensionSpacePoint": {}, "nodeAggregateId": "nody-mc-nodeface"}] |
| nodesToPublish | ["nody-mc-nodeface"] |
| contentStreamIdForRemainingPart | "user-cs-id-remaining" |

Then I expect the ChangeProjection to have the following changes in "user-cs-id-remaining":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Feature: Publish nodes partially with dimensions

When the command PublishIndividualNodesFromWorkspace is executed with payload:
| Key | Value |
| nodesToPublish | [{"workspaceName": "user-workspace", "dimensionSpacePoint": {"language": "de"}, "nodeAggregateId": "sir-david-nodenborough"}] |
| nodesToPublish | ["sir-david-nodenborough"] |
| contentStreamIdForRemainingPart | "user-cs-id-remaining" |

Then I expect the ChangeProjection to have the following changes in "user-cs-id-remaining":
Expand Down Expand Up @@ -129,19 +129,19 @@ Feature: Publish nodes partially with dimensions

When the command PublishIndividualNodesFromWorkspace is executed with payload:
| Key | Value |
| nodesToPublish | [{"workspaceName": "user-workspace", "dimensionSpacePoint": {"language": "de"}, "nodeAggregateId": "nody-mc-nodeface"}] |
| nodesToPublish | ["nody-mc-nodeface"] |
| contentStreamIdForRemainingPart | "user-cs-id-remaining" |

Then I expect the ChangeProjection to have the following changes in "user-cs-id-remaining":
| nodeAggregateId | created | changed | moved | deleted | originDimensionSpacePoint |
| nody-mc-nodeface | 1 | 1 | 0 | 0 | {"language":"gsw"} |
| sir-nodeward-nodington-iv | 1 | 1 | 0 | 0 | {"language":"de"} |
| sir-nodeward-nodington-iii | 1 | 1 | 0 | 0 | {"language":"fr"} |
And I expect the ChangeProjection to have no changes in "user-cs-id"
And I expect the ChangeProjection to have the following changes in "review-cs-id":
| nodeAggregateId | created | changed | moved | deleted | originDimensionSpacePoint |
| sir-david-nodenborough | 1 | 1 | 0 | 0 | {"language":"de"} |
| nody-mc-nodeface | 1 | 1 | 0 | 0 | {"language":"de"} |
| nody-mc-nodeface | 1 | 1 | 0 | 0 | {"language":"gsw"} |
And I expect the ChangeProjection to have no changes in "cs-identifier"

Scenario: Publish nodes partially from user workspace to live with new generalization
Expand Down Expand Up @@ -174,7 +174,7 @@ Feature: Publish nodes partially with dimensions

When the command PublishIndividualNodesFromWorkspace is executed with payload:
| Key | Value |
| nodesToPublish | [{"workspaceName": "user-workspace", "dimensionSpacePoint": {"language": "de"}, "nodeAggregateId": "sir-david-nodenborough"},{"workspaceName": "user-workspace", "dimensionSpacePoint": {"language": "en"}, "nodeAggregateId": "sir-david-nodenborough"}] |
| nodesToPublish | ["sir-david-nodenborough", "sir-david-nodenborough"] |
| contentStreamIdForRemainingPart | "user-cs-id-remaining" |

Then I expect the ChangeProjection to have the following changes in "user-cs-id-remaining":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Feature: Discard nodes partially without dimensions
When the command DiscardIndividualNodesFromWorkspace is executed with payload:
| Key | Value |
| workspaceName | "user-workspace" |
| nodesToDiscard | [{"workspaceName": "user-workspace", "dimensionSpacePoint": {}, "nodeAggregateId": "sir-nodeward-nodington-iii"}] |
| nodesToDiscard | ["sir-nodeward-nodington-iii"] |
| newContentStreamId | "user-cs-id-remaining" |

Then I expect the ChangeProjection to have the following changes in "user-cs-id-remaining":
Expand Down Expand Up @@ -85,7 +85,7 @@ Feature: Discard nodes partially without dimensions
When the command DiscardIndividualNodesFromWorkspace is executed with payload:
| Key | Value |
| workspaceName | "user-workspace" |
| nodesToDiscard | [{"workspaceName": "user-workspace", "dimensionSpacePoint": {}, "nodeAggregateId": "sir-nodeward-nodington-iii"},{"workspaceName": "user-workspace", "dimensionSpacePoint": {}, "nodeAggregateId": "sir-nodeward-nodington-iv"}] |
| nodesToDiscard | ["sir-nodeward-nodington-iii", "sir-nodeward-nodington-iv"] |
| newContentStreamId | "user-cs-id-remaining" |

Then I expect the ChangeProjection to have the following changes in "user-cs-id-remaining":
Expand Down Expand Up @@ -131,7 +131,7 @@ Feature: Discard nodes partially without dimensions
When the command DiscardIndividualNodesFromWorkspace is executed with payload:
| Key | Value |
| workspaceName | "user-workspace" |
| nodesToDiscard | [{"workspaceName": "user-workspace", "dimensionSpacePoint": {}, "nodeAggregateId": "sir-nodeward-nodington-iv"}] |
| nodesToDiscard | ["sir-nodeward-nodington-iv"] |
| newContentStreamId | "user-cs-id-remaining" |

Then I expect the ChangeProjection to have the following changes in "user-cs-id-remaining":
Expand Down Expand Up @@ -182,7 +182,7 @@ Feature: Discard nodes partially without dimensions
When the command DiscardIndividualNodesFromWorkspace is executed with payload:
| Key | Value |
| workspaceName | "user-workspace" |
| nodesToDiscard | [{"workspaceName": "user-workspace", "dimensionSpacePoint": {}, "nodeAggregateId": "sir-nodeward-nodington-iv"},{"workspaceName": "user-workspace", "dimensionSpacePoint": {}, "nodeAggregateId": "sir-nodeward-nodington-v"}] |
| nodesToDiscard | ["sir-nodeward-nodington-iv", "sir-nodeward-nodington-v"] |
| newContentStreamId | "user-cs-id-remaining" |

Then I expect the ChangeProjection to have the following changes in "user-cs-id-remaining":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Feature: Discard nodes partially with dimensions
When the command DiscardIndividualNodesFromWorkspace is executed with payload:
| Key | Value |
| workspaceName | "user-workspace" |
| nodesToDiscard | [{"workspaceName": "user-workspace", "dimensionSpacePoint": {"language": "de"}, "nodeAggregateId": "sir-david-nodenborough"}, {"workspaceName": "user-workspace", "dimensionSpacePoint": {"language": "de"}, "nodeAggregateId": "nody-mc-nodeface"}] |
| nodesToDiscard | ["sir-david-nodenborough", "nody-mc-nodeface"] |
| newContentStreamId | "user-cs-id-remaining" |

Then I expect the ChangeProjection to have the following changes in "user-cs-id-remaining":
Expand Down Expand Up @@ -129,15 +129,14 @@ Feature: Discard nodes partially with dimensions
When the command DiscardIndividualNodesFromWorkspace is executed with payload:
| Key | Value |
| workspaceName | "user-workspace" |
| nodesToDiscard | [{"workspaceName": "user-workspace", "dimensionSpacePoint": {"language": "gsw"}, "nodeAggregateId": "nody-mc-nodeface"}] |
| nodesToDiscard | ["nody-mc-nodeface"] |
| newContentStreamId | "user-cs-id-remaining" |

Then I expect the ChangeProjection to have the following changes in "review-cs-id":
| nodeAggregateId | created | changed | moved | deleted | originDimensionSpacePoint |
| sir-david-nodenborough | 1 | 1 | 0 | 0 | {"language":"de"} |
And I expect the ChangeProjection to have the following changes in "user-cs-id-remaining":
| nodeAggregateId | created | changed | moved | deleted | originDimensionSpacePoint |
| nody-mc-nodeface | 1 | 1 | 0 | 0 | {"language":"de"} |
| sir-nodeward-nodington-iii | 1 | 1 | 0 | 0 | {"language":"fr"} |
| sir-nodeward-nodington-iv | 1 | 1 | 0 | 0 | {"language":"fr"} |
And I expect the ChangeProjection to have no changes in "user-cs-id"
Expand Down Expand Up @@ -176,13 +175,11 @@ Feature: Discard nodes partially with dimensions
When the command DiscardIndividualNodesFromWorkspace is executed with payload:
| Key | Value |
| workspaceName | "user-workspace" |
| nodesToDiscard | [{"workspaceName": "user-workspace", "dimensionSpacePoint": {"language": "en"} , "nodeAggregateId": "sir-david-nodenborough"}, {"workspaceName": "user-workspace", "dimensionSpacePoint": {"language": "de"} , "nodeAggregateId": "sir-nodeward-nodington-iii"}] |
| nodesToDiscard | ["sir-david-nodenborough", "nody-mc-nodeface", "sir-nodeward-nodington-iii"] |
| newContentStreamId | "user-cs-id-remaining" |

Then I expect the ChangeProjection to have the following changes in "user-cs-id-remaining":
| nodeAggregateId | created | changed | moved | deleted | originDimensionSpacePoint |
| sir-david-nodenborough | 1 | 1 | 0 | 0 | {"language":"de"} |
| nody-mc-nodeface | 1 | 1 | 0 | 0 | {"language":"de"} |
| sir-nodeward-nodington-iv | 1 | 1 | 0 | 0 | {"language":"de"} |
And I expect the ChangeProjection to have no changes in "user-cs-id"
And I expect the ChangeProjection to have no changes in "cs-identifier"

0 comments on commit ec01723

Please sign in to comment.