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);
}
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);
}
Aggregations