Skip to content

Commit

Permalink
AF-71: getLoginLocations should support name localizations (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
mogoodrich authored Nov 28, 2023
1 parent 53d892a commit 1157f76
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ public List<SimpleObject> getLoginLocations(UiUtils ui, @SpringBean AppFramework
List<Location> loginLocations = appFrameworkService.getLoginLocations();
List<SimpleObject> ret = new ArrayList<SimpleObject>();
for (Location location : loginLocations) {
ret.add(SimpleObject.fromObject(location, ui, "id", "uuid", "name"));
SimpleObject obj = new SimpleObject();
obj.put("id", location.getId());
obj.put("uuid", location.getUuid());
obj.put("name", location.getName());
obj.put("display", ui.format(location));
ret.add(obj);
}
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion omod/src/main/webapp/fragments/header.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
.attr('locationUuid', location.uuid)
.attr('locationId', location.id)
.attr('locationName', location.name)
.text(location.name)
.text(location.display)
.appendTo(locationsList);
});
}).always(function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class SessionFragmentControllerTest {
private AppFrameworkService appFrameworkService;

@Mock
private MessageSource messageSource;
private UiUtils ui;

private List<Location> loginLocations;

Expand All @@ -48,25 +48,24 @@ public void setup() {
loginLocations.add(location2);

when(appFrameworkService.getLoginLocations()).thenReturn(loginLocations);
when(ui.format(location1)).thenReturn("location1_display");
when(ui.format(location2)).thenReturn("location2_display");
}

@Test
public void getLoginLocations_shouldReturnSimplifiedJsonLoginLocations() {
// setup
FormatterService formatterService = new FormatterService();
formatterService.setMessageSource(messageSource);
UiUtils ui = new FragmentActionUiUtils(null, null, null, formatterService);

// replay

List<SimpleObject> actualLoginLocations = new SessionFragmentController().getLoginLocations(ui, appFrameworkService);

// verify
assertEquals(loginLocations.size(), actualLoginLocations.size());
assertEquals(loginLocations.get(0).getName(), actualLoginLocations.get(0).get("name"));
assertEquals(loginLocations.get(0).getUuid(), actualLoginLocations.get(0).get("uuid"));
assertEquals(loginLocations.get(0).getId(), actualLoginLocations.get(0).get("id"));
assertEquals("location1_display", actualLoginLocations.get(0).get("display"));
assertEquals(loginLocations.get(1).getName(), actualLoginLocations.get(1).get("name"));
assertEquals(loginLocations.get(1).getUuid(), actualLoginLocations.get(1).get("uuid"));
assertEquals(loginLocations.get(1).getId(), actualLoginLocations.get(1).get("id"));
assertEquals("location2_display", actualLoginLocations.get(1).get("display"));
}
}

0 comments on commit 1157f76

Please sign in to comment.