Skip to content

Commit

Permalink
Fix toShapeId call in EndpointModifierIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
kstich committed Nov 16, 2023
1 parent 79ad214 commit bfb4c97
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public EndpointModifierIndex(Model model) {
for (ServiceShape serviceShape : model.getServiceShapes()) {
Map<ShapeId, Trait> result = new TreeMap<>();
for (Trait trait : serviceShape.getAllTraits().values()) {
Shape traitShape = model.getShape(trait.toShapeId()).get();
Shape traitShape = model.expectShape(trait.toShapeId());
if (traitShape.hasTrait(EndpointModifierTrait.ID)) {
result.put(trait.toShapeId(), trait);
}
Expand All @@ -49,6 +49,6 @@ public static EndpointModifierIndex of(Model model) {
* @return Map of endpoint modifier trait ID to the trait
*/
public Map<ShapeId, Trait> getEndpointModifierTraits(ToShapeId toShapeId) {
return endpointModifierTraits.get(toShapeId);
return endpointModifierTraits.get(toShapeId.toShapeId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public void loadsFromModel() {
EndpointModifierIndex index = new EndpointModifierIndex(model);

assertEquals(index.getEndpointModifierTraits(service1).size(), 1);
// Assert this works if you pass in the shape as well.
assertEquals(index.getEndpointModifierTraits(model.expectShape(service1)).size(), 1);
assertInstanceOf(StandardRegionalEndpointsTrait.class,
index.getEndpointModifierTraits(service1).get(StandardRegionalEndpointsTrait.ID));

Expand Down

0 comments on commit bfb4c97

Please sign in to comment.