use of sonia.scm.api.v2.resources.HalEnricherContext in project scm-review-plugin by scm-manager.
the class IndexLinkEnricher method enrich.
@Override
public void enrich(HalEnricherContext context, HalAppender appender) {
if (PermissionCheck.mayReadGlobalConfig()) {
String globalConfigUrl = new LinkBuilder(scmPathInfoStore.get().get(), GlobalConfigResource.class).method("getGlobalConfig").parameters().href();
appender.appendLink("pullRequestConfig", globalConfigUrl);
}
if (PermissionCheck.mayReadGlobalWorkflowConfig()) {
String globalEngineConfigUrl = new LinkBuilder(scmPathInfoStore.get().get(), GlobalEngineConfigResource.class).method("getGlobalEngineConfig").parameters().href();
appender.appendLink("workflowConfig", globalEngineConfigUrl);
}
}
use of sonia.scm.api.v2.resources.HalEnricherContext in project scm-review-plugin by scm-manager.
the class RepositoryLinkEnricherTest method shouldNotEnrichRepositoriesForConfigWhenRepositoryConfigIsDisabled.
@Test
@SubjectAware(username = "dent", password = "secret")
public void shouldNotEnrichRepositoriesForConfigWhenRepositoryConfigIsDisabled() {
enricher = new RepositoryLinkEnricher(scmPathInfoStoreProvider, pullRequestService, configService, globalEngineConfigurator);
when(pullRequestService.supportsPullRequests(any())).thenReturn(true);
mockGlobalConfig(true);
Repository repo = new Repository("id", "type", "space", "name");
HalEnricherContext context = HalEnricherContext.of(repo);
enricher.enrich(context, appender);
verify(appender).appendLink("pullRequest", "https://scm-manager.org/scm/api/v2/pull-requests/space/name");
verify(appender, never()).appendLink(eq("pullRequestConfig"), any());
}
use of sonia.scm.api.v2.resources.HalEnricherContext in project scm-review-plugin by scm-manager.
the class RepositoryLinkEnricherTest method shouldEnrichPullRequestCheckLink.
@Test
@SubjectAware(username = "dent", password = "secret")
public void shouldEnrichPullRequestCheckLink() {
when(pullRequestService.supportsPullRequests(any())).thenReturn(true);
mockGlobalConfig(true);
enricher = new RepositoryLinkEnricher(scmPathInfoStoreProvider, pullRequestService, configService, globalEngineConfigurator);
Repository repo = new Repository("id", "type", "space", "name");
HalEnricherContext context = HalEnricherContext.of(repo);
enricher.enrich(context, appender);
verify(appender).appendLink("pullRequestCheck", "https://scm-manager.org/scm/api/v2/pull-requests/space/name/check");
}
Aggregations