Search in sources :

Example 1 with IProjectRepository

use of org.eclipse.sirius.web.persistence.repositories.IProjectRepository in project sirius-web by eclipse-sirius.

the class EditingContextSearchServiceTests method testEditingContextWithNoDocuments.

// @formatter:on
@Test
public void testEditingContextWithNoDocuments() {
    IProjectRepository projectRepository = new NoOpProjectRepository();
    IDocumentRepository documentRepository = new NoOpDocumentRepository();
    ComposedAdapterFactory composedAdapterFactory = new ComposedAdapterFactory();
    EPackage.Registry ePackageRegistry = new EPackageRegistryImpl();
    ePackageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
    String projectId = UUID.randomUUID().toString();
    IEditingContextEPackageService editingContextEPackageService = editingContextId -> List.of();
    IEditingContextSearchService editingContextSearchService = new EditingContextSearchService(projectRepository, documentRepository, editingContextEPackageService, composedAdapterFactory, ePackageRegistry, new SimpleMeterRegistry());
    IEditingContext editingContext = editingContextSearchService.findById(projectId).get();
    assertThat(editingContext).isInstanceOf(EditingContext.class);
    EditingDomain editingDomain = ((EditingContext) editingContext).getDomain();
    assertThat(editingDomain.getResourceSet().getResources()).hasSize(0);
}
Also used : IProjectRepository(org.eclipse.sirius.web.persistence.repositories.IProjectRepository) DocumentEntity(org.eclipse.sirius.web.persistence.entities.DocumentEntity) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) DocumentMetadataAdapter(org.eclipse.sirius.web.services.documents.DocumentMetadataAdapter) URI(org.eclipse.emf.common.util.URI) ProjectEntity(org.eclipse.sirius.web.persistence.entities.ProjectEntity) EcorePackage(org.eclipse.emf.ecore.EcorePackage) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) UUID(java.util.UUID) IProjectRepository(org.eclipse.sirius.web.persistence.repositories.IProjectRepository) IEditingContextSearchService(org.eclipse.sirius.components.core.api.IEditingContextSearchService) EPackage(org.eclipse.emf.ecore.EPackage) EPackageRegistryImpl(org.eclipse.emf.ecore.impl.EPackageRegistryImpl) IEditingContextEPackageService(org.eclipse.sirius.components.emf.services.IEditingContextEPackageService) Test(org.junit.jupiter.api.Test) List(java.util.List) EditingDomain(org.eclipse.emf.edit.domain.EditingDomain) EditingContext(org.eclipse.sirius.components.emf.services.EditingContext) IDocumentRepository(org.eclipse.sirius.web.persistence.repositories.IDocumentRepository) ECrossReferenceAdapter(org.eclipse.emf.ecore.util.ECrossReferenceAdapter) Resource(org.eclipse.emf.ecore.resource.Resource) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) IEditingContextSearchService(org.eclipse.sirius.components.core.api.IEditingContextSearchService) IEditingContextEPackageService(org.eclipse.sirius.components.emf.services.IEditingContextEPackageService) EditingDomain(org.eclipse.emf.edit.domain.EditingDomain) EPackage(org.eclipse.emf.ecore.EPackage) IDocumentRepository(org.eclipse.sirius.web.persistence.repositories.IDocumentRepository) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) EditingContext(org.eclipse.sirius.components.emf.services.EditingContext) EPackageRegistryImpl(org.eclipse.emf.ecore.impl.EPackageRegistryImpl) IEditingContextSearchService(org.eclipse.sirius.components.core.api.IEditingContextSearchService) Test(org.junit.jupiter.api.Test)

Example 2 with IProjectRepository

use of org.eclipse.sirius.web.persistence.repositories.IProjectRepository in project sirius-web by eclipse-sirius.

the class EditingContextSearchServiceTests method testEditingContextWithDocuments.

@Test
public void testEditingContextWithDocuments() {
    UUID projectId = UUID.randomUUID();
    ProjectEntity projectEntity = new ProjectEntity();
    projectEntity.setId(projectId);
    // $NON-NLS-1$
    projectEntity.setName("");
    DocumentEntity firstDocumentEntity = new DocumentEntity();
    firstDocumentEntity.setId(UUID.randomUUID());
    // $NON-NLS-1$
    firstDocumentEntity.setName("First Document");
    firstDocumentEntity.setProject(projectEntity);
    firstDocumentEntity.setContent(CONTENT);
    DocumentEntity secondDocumentEntity = new DocumentEntity();
    secondDocumentEntity.setId(UUID.randomUUID());
    // $NON-NLS-1$
    secondDocumentEntity.setName("Second Document");
    secondDocumentEntity.setProject(projectEntity);
    secondDocumentEntity.setContent(CONTENT);
    IProjectRepository projectRepository = new NoOpProjectRepository();
    IDocumentRepository documentRepository = new NoOpDocumentRepository() {

        @Override
        public List<DocumentEntity> findAllByProjectId(UUID projectId) {
            return List.of(firstDocumentEntity, secondDocumentEntity);
        }
    };
    ComposedAdapterFactory composedAdapterFactory = new ComposedAdapterFactory();
    EPackage.Registry ePackageRegistry = new EPackageRegistryImpl();
    ePackageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
    IEditingContextEPackageService editingContextEPackageService = editingContextId -> List.of();
    IEditingContextSearchService editingContextSearchService = new EditingContextSearchService(projectRepository, documentRepository, editingContextEPackageService, composedAdapterFactory, ePackageRegistry, new SimpleMeterRegistry());
    IEditingContext editingContext = editingContextSearchService.findById(projectId.toString()).get();
    assertThat(editingContext).isInstanceOf(EditingContext.class);
    EditingDomain editingDomain = ((EditingContext) editingContext).getDomain();
    assertThat(editingDomain.getResourceSet().getResources()).hasSize(2);
    Resource firstResource = editingDomain.getResourceSet().getResource(URI.createURI(firstDocumentEntity.getId().toString()), true);
    this.assertProperResourceLoading(firstResource, firstDocumentEntity);
    Resource secondResource = editingDomain.getResourceSet().getResource(URI.createURI(secondDocumentEntity.getId().toString()), true);
    this.assertProperResourceLoading(secondResource, secondDocumentEntity);
}
Also used : IProjectRepository(org.eclipse.sirius.web.persistence.repositories.IProjectRepository) DocumentEntity(org.eclipse.sirius.web.persistence.entities.DocumentEntity) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) DocumentMetadataAdapter(org.eclipse.sirius.web.services.documents.DocumentMetadataAdapter) URI(org.eclipse.emf.common.util.URI) ProjectEntity(org.eclipse.sirius.web.persistence.entities.ProjectEntity) EcorePackage(org.eclipse.emf.ecore.EcorePackage) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) UUID(java.util.UUID) IProjectRepository(org.eclipse.sirius.web.persistence.repositories.IProjectRepository) IEditingContextSearchService(org.eclipse.sirius.components.core.api.IEditingContextSearchService) EPackage(org.eclipse.emf.ecore.EPackage) EPackageRegistryImpl(org.eclipse.emf.ecore.impl.EPackageRegistryImpl) IEditingContextEPackageService(org.eclipse.sirius.components.emf.services.IEditingContextEPackageService) Test(org.junit.jupiter.api.Test) List(java.util.List) EditingDomain(org.eclipse.emf.edit.domain.EditingDomain) EditingContext(org.eclipse.sirius.components.emf.services.EditingContext) IDocumentRepository(org.eclipse.sirius.web.persistence.repositories.IDocumentRepository) ECrossReferenceAdapter(org.eclipse.emf.ecore.util.ECrossReferenceAdapter) Resource(org.eclipse.emf.ecore.resource.Resource) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Resource(org.eclipse.emf.ecore.resource.Resource) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) IEditingContextSearchService(org.eclipse.sirius.components.core.api.IEditingContextSearchService) IEditingContextEPackageService(org.eclipse.sirius.components.emf.services.IEditingContextEPackageService) EditingDomain(org.eclipse.emf.edit.domain.EditingDomain) EPackage(org.eclipse.emf.ecore.EPackage) IDocumentRepository(org.eclipse.sirius.web.persistence.repositories.IDocumentRepository) DocumentEntity(org.eclipse.sirius.web.persistence.entities.DocumentEntity) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) EditingContext(org.eclipse.sirius.components.emf.services.EditingContext) ProjectEntity(org.eclipse.sirius.web.persistence.entities.ProjectEntity) EPackageRegistryImpl(org.eclipse.emf.ecore.impl.EPackageRegistryImpl) IEditingContextSearchService(org.eclipse.sirius.components.core.api.IEditingContextSearchService) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Aggregations

SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)2 List (java.util.List)2 UUID (java.util.UUID)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 URI (org.eclipse.emf.common.util.URI)2 EPackage (org.eclipse.emf.ecore.EPackage)2 EcorePackage (org.eclipse.emf.ecore.EcorePackage)2 EPackageRegistryImpl (org.eclipse.emf.ecore.impl.EPackageRegistryImpl)2 Resource (org.eclipse.emf.ecore.resource.Resource)2 ECrossReferenceAdapter (org.eclipse.emf.ecore.util.ECrossReferenceAdapter)2 EditingDomain (org.eclipse.emf.edit.domain.EditingDomain)2 ComposedAdapterFactory (org.eclipse.emf.edit.provider.ComposedAdapterFactory)2 IEditingContext (org.eclipse.sirius.components.core.api.IEditingContext)2 IEditingContextSearchService (org.eclipse.sirius.components.core.api.IEditingContextSearchService)2 EditingContext (org.eclipse.sirius.components.emf.services.EditingContext)2 IEditingContextEPackageService (org.eclipse.sirius.components.emf.services.IEditingContextEPackageService)2 DocumentEntity (org.eclipse.sirius.web.persistence.entities.DocumentEntity)2 ProjectEntity (org.eclipse.sirius.web.persistence.entities.ProjectEntity)2 IDocumentRepository (org.eclipse.sirius.web.persistence.repositories.IDocumentRepository)2 IProjectRepository (org.eclipse.sirius.web.persistence.repositories.IProjectRepository)2