Skip to content

Commit

Permalink
[#1334] Net emf objects transfer should rely on domain resource factory
Browse files Browse the repository at this point in the history
Signed-off-by: eparovyshnaya <[email protected]>
  • Loading branch information
eparovyshnaya committed Apr 5, 2024
1 parent bad42b7 commit d8a2dab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.Resource.Factory.Descriptor;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
import org.eclipse.passage.lic.emf.resource.BlindResourceFactory;

Expand All @@ -37,9 +38,12 @@ public BlindResource(EObject source) {
public Resource get() {
String domain = type.getEPackage().getName();
Object factory = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().get(domain);
if (factory instanceof Resource.Factory.Descriptor) {
Resource.Factory.Descriptor descriptor = (Descriptor) factory;
factory = descriptor.createFactory();
}
if (factory instanceof BlindResourceFactory) {
return ((BlindResourceFactory) factory).createResource();

}
return new XMIResourceImpl();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2021 ArSysOp
* Copyright (c) 2020, 2024 ArSysOp
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -9,6 +9,7 @@
*
* Contributors:
* ArSysOp - initial API and implementation
* ArSysOp - further support
*******************************************************************************/
package org.eclipse.passage.seal.demo.tests.condition.mining;

Expand Down Expand Up @@ -47,6 +48,7 @@
import org.eclipse.passage.lic.base.conditions.MatchingRuleCompatible;
import org.eclipse.passage.lic.base.conditions.mining.BaseLicenseReadingService;
import org.eclipse.passage.lic.base.conditions.mining.PersonalLicenseMiningEquipment;
import org.eclipse.passage.lic.base.diagnostic.DiagnosticExplained;
import org.eclipse.passage.lic.base.io.PathFromLicensedProduct;
import org.eclipse.passage.lic.base.registry.ReadOnlyRegistry;
import org.eclipse.passage.lic.bc.BcStreamCodec;
Expand All @@ -71,9 +73,9 @@ public final class BaseLicenseReadingServiceTest {
@Test
public void test() throws Exception {
ServiceInvocationResult<Collection<ConditionPack>> result = service().read(license());
assertTrue(result.diagnostic().severe().isEmpty());
assertTrue(result.diagnostic().bearable().isEmpty());
assertTrue(result.data().isPresent());
assertTrue(new DiagnosticExplained(result.diagnostic()).get(), result.diagnostic().severe().isEmpty());
assertTrue(new DiagnosticExplained(result.diagnostic()).get(), result.diagnostic().bearable().isEmpty());
assertTrue(new DiagnosticExplained(result.diagnostic()).get(), result.data().isPresent());
assertEquals(1, result.data().get().size());
assertPackState(result.data().get().iterator().next());
}
Expand Down

0 comments on commit d8a2dab

Please sign in to comment.