|
41 | 41 | import org.eclipse.syson.services.SemanticRunnableFactory; |
42 | 42 | import org.eclipse.syson.services.diagrams.api.IGivenDiagramSubscription; |
43 | 43 | import org.eclipse.syson.sysml.PartUsage; |
| 44 | +import org.eclipse.syson.sysml.PortionKind; |
44 | 45 | import org.eclipse.syson.sysml.helper.LabelConstants; |
45 | 46 | import org.junit.jupiter.api.BeforeEach; |
46 | 47 | import org.junit.jupiter.api.DisplayName; |
47 | 48 | import org.junit.jupiter.api.Test; |
48 | 49 | import org.springframework.beans.factory.annotation.Autowired; |
49 | 50 | import org.springframework.boot.test.context.SpringBootTest; |
50 | | -import org.springframework.test.context.jdbc.Sql; |
51 | | -import org.springframework.test.context.jdbc.SqlConfig; |
52 | 51 | import org.springframework.transaction.annotation.Transactional; |
53 | 52 |
|
54 | 53 | import reactor.core.publisher.Flux; |
@@ -92,9 +91,7 @@ public void beforeEach() { |
92 | 91 | } |
93 | 92 |
|
94 | 93 | @DisplayName("GIVEN a diagram with a part and a part definition, WHEN the part is typed with direct edit, THEN the feature typing is created") |
95 | | - @Sql(scripts = { GeneralViewDirectEditTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, |
96 | | - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
97 | | - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
| 94 | + @GivenSysONServer({ GeneralViewDirectEditTestProjectData.SCRIPT_PATH }) |
98 | 95 | @Test |
99 | 96 | public void directEditUsingName() { |
100 | 97 | var flux = this.givenSubscriptionToDiagram(); |
@@ -144,10 +141,58 @@ public void directEditUsingName() { |
144 | 141 | .verify(Duration.ofSeconds(10)); |
145 | 142 | } |
146 | 143 |
|
| 144 | + @DisplayName("GIVEN a diagram with a part, WHEN the part portion kind is changed with direct edit, THEN the portion kind property is updated") |
| 145 | + @GivenSysONServer({ GeneralViewDirectEditTestProjectData.SCRIPT_PATH }) |
| 146 | + @Test |
| 147 | + public void directEditUsingPortionKind() { |
| 148 | + var flux = this.givenSubscriptionToDiagram(); |
| 149 | + |
| 150 | + var diagramId = new AtomicReference<String>(); |
| 151 | + var partNodeId = new AtomicReference<String>(); |
| 152 | + var partNodeLabelId = new AtomicReference<String>(); |
| 153 | + |
| 154 | + Consumer<Object> initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram -> { |
| 155 | + diagramId.set(diagram.getId()); |
| 156 | + var partNode = new DiagramNavigator(diagram).nodeWithLabel(LabelConstants.OPEN_QUOTE + "part" + LabelConstants.CLOSE_QUOTE + "\npart1").getNode(); |
| 157 | + partNodeId.set(partNode.getId()); |
| 158 | + partNodeLabelId.set(partNode.getInsideLabel().getId()); |
| 159 | + }); |
| 160 | + |
| 161 | + Runnable editLabel = () -> { |
| 162 | + var input = new EditLabelInput(UUID.randomUUID(), GeneralViewDirectEditTestProjectData.EDITING_CONTEXT_ID, diagramId.get(), partNodeLabelId.get(), "timeslice part1"); |
| 163 | + var result = this.editLabelMutationRunner.run(input); |
| 164 | + |
| 165 | + String typename = JsonPath.read(result.data(), "$.data.editLabel.__typename"); |
| 166 | + assertThat(typename).isEqualTo(EditLabelSuccessPayload.class.getSimpleName()); |
| 167 | + }; |
| 168 | + |
| 169 | + Consumer<Object> updatedDiagramContentMatcher = assertRefreshedDiagramThat(diagram -> { |
| 170 | + var node = new DiagramNavigator(diagram).nodeWithId(partNodeId.get()).getNode(); |
| 171 | + DiagramAssertions.assertThat(node.getInsideLabel()).hasText(LabelConstants.OPEN_QUOTE + "timeslice" + LabelConstants.CLOSE_QUOTE + "\n" + LabelConstants.OPEN_QUOTE + "part" + LabelConstants.CLOSE_QUOTE + "\npart1"); |
| 172 | + }); |
| 173 | + |
| 174 | + Runnable exposedElementsChecker = this.semanticRunnableFactory.createRunnable(GeneralViewDirectEditTestProjectData.EDITING_CONTEXT_ID, |
| 175 | + (editingContext, executeEditingContextFunctionInput) -> { |
| 176 | + PartUsage part = this.objectSearchService.getObject(editingContext, GeneralViewDirectEditTestProjectData.SemanticIds.PART_USAGE_ID) |
| 177 | + .filter(PartUsage.class::isInstance) |
| 178 | + .map(PartUsage.class::cast) |
| 179 | + .orElse(null); |
| 180 | + assertThat(part).isNotNull(); |
| 181 | + assertThat(part.getPortionKind()).isEqualTo(PortionKind.TIMESLICE); |
| 182 | + return new ExecuteEditingContextFunctionSuccessPayload(executeEditingContextFunctionInput.id(), true); |
| 183 | + }); |
| 184 | + |
| 185 | + StepVerifier.create(flux) |
| 186 | + .consumeNextWith(initialDiagramContentConsumer) |
| 187 | + .then(editLabel) |
| 188 | + .consumeNextWith(updatedDiagramContentMatcher) |
| 189 | + .then(exposedElementsChecker) |
| 190 | + .thenCancel() |
| 191 | + .verify(Duration.ofSeconds(10)); |
| 192 | + } |
| 193 | + |
147 | 194 | @DisplayName("GIVEN a diagram with a part and a part definition, WHEN the part is typed with direct edit using the qualified name, THEN the feature typing is created") |
148 | | - @Sql(scripts = { GeneralViewDirectEditTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, |
149 | | - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
150 | | - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
| 195 | + @GivenSysONServer({ GeneralViewDirectEditTestProjectData.SCRIPT_PATH }) |
151 | 196 | @Test |
152 | 197 | public void directEditUsingWithQualifiedFullName() { |
153 | 198 | var flux = this.givenSubscriptionToDiagram(); |
@@ -198,9 +243,7 @@ public void directEditUsingWithQualifiedFullName() { |
198 | 243 | } |
199 | 244 |
|
200 | 245 | @DisplayName("GIVEN a diagram with a part and a part definition, WHEN the part is typed with direct edit using short name, THEN the feature typing is created") |
201 | | - @Sql(scripts = { GeneralViewDirectEditTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, |
202 | | - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
203 | | - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
| 246 | + @GivenSysONServer({ GeneralViewDirectEditTestProjectData.SCRIPT_PATH }) |
204 | 247 | @Test |
205 | 248 | public void directEditUsingShortName() { |
206 | 249 | var flux = this.givenSubscriptionToDiagram(); |
@@ -251,9 +294,7 @@ public void directEditUsingShortName() { |
251 | 294 | } |
252 | 295 |
|
253 | 296 | @DisplayName("GIVEN a diagram with a part and a part definition, WHEN the part is typed with direct edit using the qualified short name, THEN the feature typing is created") |
254 | | - @Sql(scripts = { GeneralViewDirectEditTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, |
255 | | - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
256 | | - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
| 297 | + @GivenSysONServer({ GeneralViewDirectEditTestProjectData.SCRIPT_PATH }) |
257 | 298 | @Test |
258 | 299 | public void directEditUsingQualifiedShortName() { |
259 | 300 | var flux = this.givenSubscriptionToDiagram(); |
@@ -304,9 +345,7 @@ public void directEditUsingQualifiedShortName() { |
304 | 345 | } |
305 | 346 |
|
306 | 347 | @DisplayName("GIVEN a diagram with a part and a part definition in the same scope, WHEN the part is typed with direct edit using short name, THEN the feature typing is created with the best candidat") |
307 | | - @Sql(scripts = { GeneralViewDirectEditTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, |
308 | | - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
309 | | - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
| 348 | + @GivenSysONServer({ GeneralViewDirectEditTestProjectData.SCRIPT_PATH }) |
310 | 349 | @Test |
311 | 350 | public void directEditUsingShortNameAndScope() { |
312 | 351 | var flux = this.givenSubscriptionToDiagram(); |
@@ -357,9 +396,7 @@ public void directEditUsingShortNameAndScope() { |
357 | 396 | } |
358 | 397 |
|
359 | 398 | @DisplayName("GIVEN a diagram with an attribute, WHEN we direct edit with an operation using an unimported namespace, THEN the attribute is correctly set") |
360 | | - @Sql(scripts = { GeneralViewItemAndAttributeProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, |
361 | | - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
362 | | - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
| 399 | + @GivenSysONServer({ GeneralViewItemAndAttributeProjectData.SCRIPT_PATH }) |
363 | 400 | @Test |
364 | 401 | public void directEditOperationUsingUnImportedNameSpaceName() { |
365 | 402 | var diagramEventInput = new DiagramEventInput(UUID.randomUUID(), |
@@ -403,9 +440,7 @@ public void directEditOperationUsingUnImportedNameSpaceName() { |
403 | 440 | } |
404 | 441 |
|
405 | 442 | @DisplayName("GIVEN a diagram with a part, WHEN we direct edit with multiplicity and subsetting, THEN the part is correctly set") |
406 | | - @Sql(scripts = { GeneralViewItemAndAttributeProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, |
407 | | - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
408 | | - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
| 443 | + @GivenSysONServer({ GeneralViewItemAndAttributeProjectData.SCRIPT_PATH }) |
409 | 444 | @Test |
410 | 445 | public void directEditMultiplicityWithSubsetting() { |
411 | 446 | var diagramEventInput = new DiagramEventInput(UUID.randomUUID(), |
@@ -466,9 +501,7 @@ public void directEditMultiplicityWithSubsetting() { |
466 | 501 | } |
467 | 502 |
|
468 | 503 | @DisplayName("GIVEN a diagram with a part, WHEN we direct edit with multiplicity and redefinition, THEN the part is correctly set") |
469 | | - @Sql(scripts = { GeneralViewItemAndAttributeProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, |
470 | | - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
471 | | - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
| 504 | + @GivenSysONServer({ GeneralViewItemAndAttributeProjectData.SCRIPT_PATH }) |
472 | 505 | @Test |
473 | 506 | public void directEditMultiplicityWithRedefinition() { |
474 | 507 | var diagramEventInput = new DiagramEventInput(UUID.randomUUID(), |
@@ -529,9 +562,7 @@ public void directEditMultiplicityWithRedefinition() { |
529 | 562 | } |
530 | 563 |
|
531 | 564 | @DisplayName("GIVEN a diagram with a part, WHEN we direct edit with multiplicity and feature typing, THEN the part is correctly set") |
532 | | - @Sql(scripts = { GeneralViewItemAndAttributeProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, |
533 | | - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
534 | | - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
| 565 | + @GivenSysONServer({ GeneralViewItemAndAttributeProjectData.SCRIPT_PATH }) |
535 | 566 | @Test |
536 | 567 | public void directEditMultiplicityWithFeatureTyping() { |
537 | 568 | var diagramEventInput = new DiagramEventInput(UUID.randomUUID(), |
@@ -592,9 +623,7 @@ public void directEditMultiplicityWithFeatureTyping() { |
592 | 623 | } |
593 | 624 |
|
594 | 625 | @DisplayName("GIVEN a diagram with a part, WHEN we direct edit with multiplicity and operation, THEN the part is correctly set only if the multiplicity is before the operation") |
595 | | - @Sql(scripts = { GeneralViewItemAndAttributeProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, |
596 | | - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
597 | | - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
| 626 | + @GivenSysONServer({ GeneralViewItemAndAttributeProjectData.SCRIPT_PATH }) |
598 | 627 | @Test |
599 | 628 | public void directEditMultiplicityWithOperation() { |
600 | 629 | var diagramEventInput = new DiagramEventInput(UUID.randomUUID(), |
|
0 commit comments