use of org.eclipse.emf.ecore.impl.EPackageRegistryImpl in project sirius-components by eclipse-sirius.
the class ViewValidatorTests method testNodeStyleDescriptionValidQualifiedDomainInPackageRegistry.
@Test
public void testNodeStyleDescriptionValidQualifiedDomainInPackageRegistry() {
Map<Object, Object> defaultContext = Diagnostician.INSTANCE.createDefaultContext();
NodeDescription nodeDescription = ViewFactory.eINSTANCE.createNodeDescription();
// $NON-NLS-1$
nodeDescription.setDomainType(SAMPLE_DOMAIN_NAME + "::" + SAMPLE_ENTITY_NAME);
ResourceSetImpl resourceSet = new ResourceSetImpl();
XMIResourceImpl viewResource = new XMIResourceImpl();
viewResource.getContents().add(nodeDescription);
resourceSet.getResources().add(viewResource);
EPackageRegistryImpl packageRegistryImpl = new EPackageRegistryImpl();
EPackage ePackage = EcoreFactory.eINSTANCE.createEPackage();
ePackage.setName(SAMPLE_DOMAIN_NAME);
ePackage.setNsPrefix(SAMPLE_DOMAIN_NAME);
// $NON-NLS-1$
ePackage.setNsURI("domain://sample");
EClass sampleClass = EcoreFactory.eINSTANCE.createEClass();
sampleClass.setName(SAMPLE_ENTITY_NAME);
ePackage.getEClassifiers().add(sampleClass);
packageRegistryImpl.put(ePackage.getNsURI(), ePackage);
resourceSet.setPackageRegistry(packageRegistryImpl);
BasicDiagnostic diagnosticChain = new BasicDiagnostic(Diagnostic.OK, null, 0, null, null);
boolean validationResult = new DiagramDescriptionValidator().validate(nodeDescription.eClass(), nodeDescription, diagnosticChain, defaultContext);
assertThat(validationResult).isTrue();
assertThat(diagnosticChain).isEqualTo(new BasicDiagnostic(Diagnostic.OK, null, 0, null, null));
}
use of org.eclipse.emf.ecore.impl.EPackageRegistryImpl in project sirius-components by eclipse-sirius.
the class EditService method getPackageRegistry.
private EPackage.Registry getPackageRegistry(String editingContextId) {
EPackageRegistryImpl ePackageRegistry = new EPackageRegistryImpl();
this.globalEPackageRegistry.forEach(ePackageRegistry::put);
List<EPackage> additionalEPackages = this.editingContextEPackageService.getEPackages(editingContextId);
additionalEPackages.forEach(ePackage -> ePackageRegistry.put(ePackage.getNsURI(), ePackage));
return ePackageRegistry;
}
Aggregations