Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ class ConcreteElementMetadataGenerator
private final ReferenceIdProvider referenceIdProvider;
private final ContainingElementIndex containingElementIndex;
private final ProcessorSupport processorSupport;
private final MapIterable<String, ImmutableList<String>> backReferenceProperties = M3PropertyPaths.BACK_REFERENCE_PROPERTY_PATHS.groupByUniqueKey(ImmutableList::getLast, Maps.mutable.ofInitialCapacity(M3PropertyPaths.BACK_REFERENCE_PROPERTY_PATHS.size()));
private final MapIterable<String, ImmutableList<String>> backReferenceProperties = M3PropertyPaths.BACK_REFERENCE_PROPERTY_PATHS.groupByUniqueKey(
ImmutableList::getLast,
Maps.mutable.ofInitialCapacity(M3PropertyPaths.BACK_REFERENCE_PROPERTY_PATHS.size() + 1))
.withKeyValue(M3PropertyPaths.children.getLast(), M3PropertyPaths.children);
private final ConcurrentMutableMap<CoreInstance, String> elementPathCache = ConcurrentHashMap.newMap();
private final ConcurrentMutableMap<CoreInstance, BackReferenceCollector> backRefCollectorCache = ConcurrentHashMap.newMap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,20 @@ public void testSerializeWithExcludedModule() throws IOException
assertModuleNotSerialized(deserializer, outputDirectory, OTHER_TEST_REPO);
}

@Test
public void testSerializeSingleVsMultiple() throws IOException
{
Path multiOutputDir = TMP.newFolder().toPath();
PureCompilerBinaryGenerator.serializeModules(multiOutputDir, Lists.immutable.with(PLATFORM, TEST_REPO, OTHER_TEST_REPO));

Path singleOutputDir = TMP.newFolder().toPath();
PureCompilerBinaryGenerator.serializeModules(singleOutputDir, Lists.immutable.with(PLATFORM));
PureCompilerBinaryGenerator.serializeModules(singleOutputDir, Lists.immutable.with(TEST_REPO));
PureCompilerBinaryGenerator.serializeModules(singleOutputDir, Lists.immutable.with(OTHER_TEST_REPO));

assertDirectoriesEquivalent(multiOutputDir, singleOutputDir);
}

private static void assertModuleSerialized(FileDeserializer deserializer, Path outputDirectory, String moduleName)
{
Assert.assertTrue(moduleName + " manifest should exist", deserializer.moduleManifestExists(outputDirectory, moduleName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.finos.legend.pure.m3.serialization.filesystem.repository.GenericCodeRepository;
import org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.classpath.ClassLoaderCodeStorage;
import org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.composite.CompositeCodeStorage;
import org.finos.legend.pure.m3.serialization.runtime.PureRuntime;
import org.finos.legend.pure.m3.serialization.runtime.PureRuntimeBuilder;
import org.finos.legend.pure.m3.tools.GraphTools;
import org.junit.After;
import org.junit.Assert;
Expand Down Expand Up @@ -123,8 +125,20 @@ public void testAllModules()
{
Assert.assertEquals(
getAllModuleMetadata().sortThisBy(ModuleMetadata::getName),
this.generator.generateAllModuleMetadata().sortThisBy(ModuleMetadata::getName)
);
this.generator.generateAllModuleMetadata().sortThisBy(ModuleMetadata::getName));
}

@Test
public void testIndividualVsMultiRepoGeneration()
{
ModuleMetadata platformFromMultiRepo = this.generator.generateModuleMetadata("platform");

CompositeCodeStorage platformOnlyStorage = new CompositeCodeStorage(
new ClassLoaderCodeStorage(runtime.getCodeStorage().getRepository("platform")));
PureRuntime platformOnlyRuntime = new PureRuntimeBuilder(platformOnlyStorage).buildAndInitialize();
ModuleMetadata platformFromSingleRepo = ModuleMetadataGenerator.fromPureRuntime(platformOnlyRuntime).generateModuleMetadata("platform");

Assert.assertEquals(platformFromMultiRepo, platformFromSingleRepo);
}

private ModuleMetadata getModuleMetadata(String moduleName)
Expand Down
Loading