|
52 | 52 | import org.eclipse.syson.application.publication.SysONLibraryPublicationHandler; |
53 | 53 | import org.eclipse.syson.application.publication.SysONLibraryPublicationListener; |
54 | 54 | import org.eclipse.syson.sysml.SysmlPackage; |
| 55 | +import org.eclipse.syson.sysml.util.ElementUtil; |
55 | 56 | import org.junit.jupiter.api.BeforeEach; |
56 | 57 | import org.junit.jupiter.api.DisplayName; |
57 | 58 | import org.junit.jupiter.api.Test; |
@@ -124,11 +125,25 @@ public void givenProjectWhenLibraryIsPublishedThenLibraryExistsAndHasCorrectMeta |
124 | 125 | TestTransaction.end(); |
125 | 126 | TestTransaction.start(); |
126 | 127 |
|
127 | | - assertThat(this.librarySearchService.findByNamespaceAndNameAndVersion(SimpleProjectElementsTestProjectData.PROJECT_ID, SimpleProjectElementsTestProjectData.PROJECT_NAME, LIBRARY_VERSION)) |
| 128 | + Optional<Library> optionalLibrary = this.librarySearchService.findByNamespaceAndNameAndVersion(SimpleProjectElementsTestProjectData.PROJECT_ID, SimpleProjectElementsTestProjectData.PROJECT_NAME, LIBRARY_VERSION); |
| 129 | + assertThat(optionalLibrary) |
128 | 130 | .isPresent() |
129 | 131 | .hasValueSatisfying(library -> assertThat(library.getName()).isEqualTo(SimpleProjectElementsTestProjectData.PROJECT_NAME)) |
130 | 132 | .hasValueSatisfying(library -> assertThat(library.getVersion()).isEqualTo(LIBRARY_VERSION)) |
131 | 133 | .hasValueSatisfying(library -> assertThat(library.getDescription()).isEqualTo(LIBRARY_DESCRIPTION)); |
| 134 | + |
| 135 | + // Load the editing context manually, we can't use ExecuteEditingContextFunctionInput because the editing context dispatcher doesn't allow mutations on libraries |
| 136 | + Optional<IEditingContext> optionalEditingContext = this.editingContextSearchService.findById(optionalLibrary.get().getSemanticData().getId().toString()); |
| 137 | + assertThat(optionalEditingContext).isPresent(); |
| 138 | + IEditingContext editingContext = optionalEditingContext.get(); |
| 139 | + if (editingContext instanceof IEMFEditingContext emfEditingContext) { |
| 140 | + List<Resource> properLibraryResources = emfEditingContext.getDomain().getResourceSet().getResources().stream() |
| 141 | + .filter(resource -> !ElementUtil.isStandardLibraryResource(resource)) |
| 142 | + .toList(); |
| 143 | + assertThat(properLibraryResources).hasSize(1); |
| 144 | + assertThat(properLibraryResources.getFirst().eAdapters()) |
| 145 | + .anyMatch(adapter -> adapter instanceof ResourceMetadataAdapter resourceMetadataAdapter && resourceMetadataAdapter.isReadOnly()); |
| 146 | + } |
132 | 147 | } |
133 | 148 |
|
134 | 149 | @Test |
|
0 commit comments