Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1675 #1716

Merged
merged 3 commits into from
Apr 5, 2023
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 @@ -29,6 +29,7 @@
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -93,7 +94,7 @@ public final class ModelAssembler {
private TraitFactory traitFactory;
private ValidatorFactory validatorFactory;
private boolean disableValidation;
private final Map<String, Supplier<InputStream>> inputStreamModels = new HashMap<>();
private final Map<String, Supplier<InputStream>> inputStreamModels = new LinkedHashMap<>();
private final List<Validator> validators = new ArrayList<>();
private final List<Node> documentNodes = new ArrayList<>();
private final List<Model> mergeModels = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
import java.util.Map;
import java.util.Optional;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Assumptions;
Expand Down Expand Up @@ -391,6 +393,26 @@ public void detectsMetadataConflicts() {
containsString("Metadata conflict for key `foo`"));
}

@Test
public void metadataIsNotAffectedByTheSourceName() {
Model model1 = new ModelAssembler()
.addUnparsedModel("a1.smithy", "metadata items = [1]")
.addUnparsedModel("a2.smithy", "metadata items = [2]")
.addUnparsedModel("a3.smithy", "metadata items = [3]")
.assemble()
.unwrap();
Model model2 = new ModelAssembler()
.addUnparsedModel("b1.smithy", "metadata items = [1]")
.addUnparsedModel("b2.smithy", "metadata items = [2]")
.addUnparsedModel("b3.smithy", "metadata items = [3]")
.assemble()
.unwrap();
List<Number> metadata1 = model1.getMetadata().get("items").expectArrayNode().getElements().stream().map(s -> s.expectNumberNode().getValue()).collect(Collectors.toList());
List<Number> metadata2 = model2.getMetadata().get("items").expectArrayNode().getElements().stream().map(s -> s.expectNumberNode().getValue()).collect(Collectors.toList());
assertThat(metadata1, is(metadata2));
}


@Test
public void mergesMultipleModels() {
Model model = new ModelAssembler()
Expand Down