use of org.eclipse.collections.api.map.primitive.MutableObjectIntMap in project legend-pure by finos.
the class TestIdBuilder method testIdUniqueness.
private void testIdUniqueness(IdBuilder idBuilder) {
MutableSet<CoreInstance> excludedClassifiers = PrimitiveUtilities.getPrimitiveTypes(processorSupport).toSet();
MutableMap<CoreInstance, MutableSet<String>> classifierIds = Maps.mutable.empty();
MutableMap<CoreInstance, MutableObjectIntMap<String>> idConflicts = Maps.mutable.empty();
GraphNodeIterable.fromModelRepository(runtime.getModelRepository()).forEach(instance -> {
CoreInstance classifier = instance.getClassifier();
if (!excludedClassifiers.contains(classifier)) {
String id = idBuilder.buildId(instance);
if (!classifierIds.getIfAbsentPut(classifier, Sets.mutable::empty).add(id)) {
idConflicts.getIfAbsentPut(classifier, ObjectIntMaps.mutable::empty).updateValue(id, 1, n -> n + 1);
}
}
});
if (idConflicts.notEmpty()) {
MutableMap<CoreInstance, String> classifierPaths = idConflicts.keysView().toMap(c -> c, PackageableElement::getUserPathForPackageableElement);
StringBuilder builder = new StringBuilder("The following ids have conflicts:");
idConflicts.keysView().toSortedListBy(classifierPaths::get).forEach(classifier -> {
builder.append("\n\t").append(classifierPaths.get(classifier));
ObjectIntMap<String> classifierIdConflicts = idConflicts.get(classifier);
classifierIdConflicts.forEachKeyValue((id, count) -> builder.append("\n\t\t").append(id).append(": ").append(count).append(" instances"));
});
Assert.fail(builder.toString());
}
}
use of org.eclipse.collections.api.map.primitive.MutableObjectIntMap in project legend-pure by finos.
the class TestIdBuilderCore method testIdUniqueness.
private void testIdUniqueness(IdBuilder idBuilder) {
// ImportGroup is excluded because of a known issue with conflicts with ImportGroup ids independent of IdBuilder
MutableSet<CoreInstance> excludedClassifiers = PrimitiveUtilities.getPrimitiveTypes(processorSupport).toSet().with(processorSupport.package_getByUserPath(M3Paths.ImportGroup));
MutableMap<CoreInstance, MutableSet<String>> classifierIds = Maps.mutable.empty();
MutableMap<CoreInstance, MutableObjectIntMap<String>> idConflicts = Maps.mutable.empty();
GraphNodeIterable.fromModelRepository(runtime.getModelRepository()).forEach(instance -> {
CoreInstance classifier = instance.getClassifier();
if (!excludedClassifiers.contains(classifier)) {
String id = idBuilder.buildId(instance);
if (!classifierIds.getIfAbsentPut(classifier, Sets.mutable::empty).add(id)) {
idConflicts.getIfAbsentPut(classifier, ObjectIntMaps.mutable::empty).updateValue(id, 1, n -> n + 1);
}
}
});
if (idConflicts.notEmpty()) {
MutableMap<CoreInstance, String> classifierPaths = idConflicts.keysView().toMap(c -> c, PackageableElement::getUserPathForPackageableElement);
StringBuilder builder = new StringBuilder("The following ids have conflicts:");
idConflicts.keysView().toSortedListBy(classifierPaths::get).forEach(classifier -> {
builder.append("\n\t").append(classifierPaths.get(classifier));
ObjectIntMap<String> classifierIdConflicts = idConflicts.get(classifier);
classifierIdConflicts.forEachKeyValue((id, count) -> builder.append("\n\t\t").append(id).append(": ").append(count).append(" instances"));
});
Assert.fail(builder.toString());
}
}
Aggregations