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 @@ -19,6 +19,8 @@ public class GlobalNavigationNodeDto

public string Url { get; set; } = string.Empty;

public string MatchPattern { get; set; } = string.Empty;

public string Icon { get; set; } = string.Empty;

public bool IsHidden { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ public interface IGlobalNavService
{
Task<List<GlobalNavigationAppDto>> GetGlobalNavigationsByClientIdAsync(string clientId);

Task<List<GlobalNavigationNodeDto>> GetMenusByPmIdentityAsync(string pmIdentity);

Task<List<AppEntryDto>> GetVisibleAppEntriesByClientIdAsync(string clientId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ public async Task<List<GlobalNavigationAppDto>> GetGlobalNavigationsByClientIdAs
return result ?? new();
}

public async Task<List<GlobalNavigationNodeDto>> GetMenusByPmIdentityAsync(string pmIdentity)
{
var requestUri = $"{GLOBAL_NAV_ROUTE_PREFIX}/menus/by-pm-identity/{pmIdentity}";
var result = await _caller.GetAsync<List<GlobalNavigationNodeDto>>(requestUri);
return result ?? new();
}

public async Task<List<AppEntryDto>> GetVisibleAppEntriesByClientIdAsync(string clientId)
{
var requestUri = $"{GLOBAL_NAV_ROUTE_PREFIX}/app-entries/by-client-id/{clientId}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ public async Task<List<GlobalNavigationAppDto>> GetGlobalNavigationsByClientIdAs
return result ?? new();
}

public async Task<List<GlobalNavigationNodeDto>> GetMenusByPmIdentityAsync(string pmIdentity)
{
var requestUri = $"{GLOBAL_NAV_ROUTE_PREFIX}/menus/by-pm-identity/{pmIdentity}";
var result = await _caller.GetAsync<List<GlobalNavigationNodeDto>>(requestUri);
return result ?? new();
}

public async Task<List<AppEntryDto>> GetVisibleAppEntriesByClientIdAsync(string clientId)
{
var requestUri = $"{GLOBAL_NAV_ROUTE_PREFIX}/app-entries/by-client-id/{clientId}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,38 @@ public async Task TestGetVisibleAppEntriesByClientIdWhenNullAsync(string clientI

Assert.AreEqual(0, result.Count);
}

[TestMethod]
[DataRow("pm.identity")]
public async Task TestGetMenusByPmIdentityAsync(string pmIdentity)
{
var data = new List<GlobalNavigationNodeDto> { new() };

var requestUri = $"api/global-nav/menus/by-pm-identity/{pmIdentity}";
var caller = new Mock<ICaller>();
caller.Setup(provider => provider.GetAsync<List<GlobalNavigationNodeDto>>(requestUri, default)).ReturnsAsync(data).Verifiable();
var sappClient = new SappClient(caller.Object);

var result = await sappClient.GlobalNavService.GetMenusByPmIdentityAsync(pmIdentity);
caller.Verify(provider => provider.GetAsync<List<GlobalNavigationNodeDto>>(requestUri, default), Times.Once);

Assert.AreEqual(1, result.Count);
}

[TestMethod]
[DataRow("pm.identity")]
public async Task TestGetMenusByPmIdentityWhenNullAsync(string pmIdentity)
{
List<GlobalNavigationNodeDto>? data = null;

var requestUri = $"api/global-nav/menus/by-pm-identity/{pmIdentity}";
var caller = new Mock<ICaller>();
caller.Setup(provider => provider.GetAsync<List<GlobalNavigationNodeDto>>(It.IsAny<string>(), default)).ReturnsAsync(data).Verifiable();
var sappClient = new SappClient(caller.Object);

var result = await sappClient.GlobalNavService.GetMenusByPmIdentityAsync(pmIdentity);
caller.Verify(provider => provider.GetAsync<List<GlobalNavigationNodeDto>>(requestUri, default), Times.Once);

Assert.AreEqual(0, result.Count);
}
}
Loading