Search in sources :

Example 1 with RestDispatcher

use of sonia.scm.web.RestDispatcher in project scm-review-plugin by scm-manager.

the class CommentRootResourceTest method init.

@Before
public void init() {
    when(repositoryResolver.resolve(any())).thenReturn(repository);
    commentMapper.setReplyMapper(replyMapper);
    commentMapper.setExecutedTransitionMapper(executedTransitionMapper);
    commentMapper.setPossibleTransitionMapper(possibleTransitionMapper);
    replyMapper.setExecutedTransitionMapper(executedTransitionMapper);
    CommentRootResource resource = new CommentRootResource(commentMapper, repositoryResolver, service, commentResourceProvider, commentPathBuilder, pullRequestService, branchRevisionResolver);
    when(uriInfo.getAbsolutePathBuilder()).thenReturn(UriBuilder.fromPath("/scm"));
    dispatcher = new RestDispatcher();
    PullRequestRootResource pullRequestRootResource = new PullRequestRootResource(new PullRequestMapperImpl(), null, serviceFactory, Providers.of(new PullRequestResource(new PullRequestMapperImpl(), null, Providers.of(resource), null, channelRegistry)));
    dispatcher.addSingletonResource(pullRequestRootResource);
    when(branchRevisionResolver.getRevisions(any(), any(), any())).thenReturn(new BranchRevisionResolver.RevisionResult("source", "target"));
    when(branchRevisionResolver.getRevisions(any(), any())).thenReturn(new BranchRevisionResolver.RevisionResult("source", "target"));
}
Also used : PullRequestResource(com.cloudogu.scm.review.pullrequest.api.PullRequestResource) BranchRevisionResolver(com.cloudogu.scm.review.pullrequest.dto.BranchRevisionResolver) PullRequestMapperImpl(com.cloudogu.scm.review.pullrequest.dto.PullRequestMapperImpl) RestDispatcher(sonia.scm.web.RestDispatcher) PullRequestRootResource(com.cloudogu.scm.review.pullrequest.api.PullRequestRootResource) Before(org.junit.Before)

Example 2 with RestDispatcher

use of sonia.scm.web.RestDispatcher in project scm-review-plugin by scm-manager.

the class MergeResourceTest method initDispatcher.

@BeforeEach
void initDispatcher() {
    dispatcher = new RestDispatcher();
    dispatcher.addSingletonResource(mergeResource);
}
Also used : RestDispatcher(sonia.scm.web.RestDispatcher) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with RestDispatcher

use of sonia.scm.web.RestDispatcher in project scm-review-plugin by scm-manager.

the class PullRequestRootResourceTest method init.

@Before
public void init() {
    when(repository.getId()).thenReturn(REPOSITORY_ID);
    when(repository.getName()).thenReturn(REPOSITORY_NAME);
    when(repository.getNamespace()).thenReturn(REPOSITORY_NAMESPACE);
    when(repository.getNamespaceAndName()).thenReturn(new NamespaceAndName(REPOSITORY_NAMESPACE, REPOSITORY_NAME));
    when(repositoryResolver.resolve(any())).thenReturn(repository);
    when(pullRequestService.getRepository(repository.getNamespace(), repository.getName())).thenReturn(repository);
    DefaultPullRequestService service = new DefaultPullRequestService(repositoryResolver, branchResolver, storeFactory, eventBus, repositoryServiceFactory);
    pullRequestRootResource = new PullRequestRootResource(mapper, service, repositoryServiceFactory, Providers.of(new PullRequestResource(mapper, service, null, null, channelRegistry)));
    when(storeFactory.create(null)).thenReturn(store);
    when(storeFactory.create(any())).thenReturn(store);
    when(store.add(pullRequestStoreCaptor.capture())).thenReturn("1");
    when(branchLinkProvider.get(any(NamespaceAndName.class), anyString())).thenReturn("");
    dispatcher = new RestDispatcher();
    dispatcher.addSingletonResource(pullRequestRootResource);
    lenient().when(repositoryServiceFactory.create(any(Repository.class))).thenReturn(repositoryService);
    lenient().when(userDisplayManager.get("reviewer")).thenReturn(Optional.of(DisplayUser.from(new User("reviewer", "reviewer", ""))));
}
Also used : Repository(sonia.scm.repository.Repository) DefaultPullRequestService(com.cloudogu.scm.review.pullrequest.service.DefaultPullRequestService) DisplayUser(sonia.scm.user.DisplayUser) User(sonia.scm.user.User) NamespaceAndName(sonia.scm.repository.NamespaceAndName) RestDispatcher(sonia.scm.web.RestDispatcher) Before(org.junit.Before)

Example 4 with RestDispatcher

use of sonia.scm.web.RestDispatcher in project scm-review-plugin by scm-manager.

the class PullRequestRootResourceTest method initPullRequestRootResource.

private void initPullRequestRootResource() {
    PullRequestRootResource rootResource = new PullRequestRootResource(mapper, pullRequestService, repositoryServiceFactory, Providers.of(new PullRequestResource(mapper, pullRequestService, null, null, channelRegistry)));
    dispatcher = new RestDispatcher();
    dispatcher.addSingletonResource(rootResource);
}
Also used : RestDispatcher(sonia.scm.web.RestDispatcher)

Example 5 with RestDispatcher

use of sonia.scm.web.RestDispatcher in project scm-review-plugin by scm-manager.

the class RepositoryEngineConfigResourceTest method init.

@BeforeEach
void init() {
    RepositoryEngineConfigMapperImpl mapper = new RepositoryEngineConfigMapperImpl();
    mapper.availableRules = new AvailableRules(availableRules);
    mapper.configurationValidator = configurationValidator;
    mapper.globalEngineConfigurator = globalEngineConfigurator;
    RepositoryEngineConfigResource repositoryEngineConfigResource = new RepositoryEngineConfigResource(repositoryManager, repositoryEngineConfigurator, mapper, availableRules);
    dispatcher = new RestDispatcher();
    dispatcher.addSingletonResource(repositoryEngineConfigResource);
    lenient().when(uriInfo.getBaseUri()).thenReturn(URI.create("localhost/scm/api"));
}
Also used : RestDispatcher(sonia.scm.web.RestDispatcher) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

RestDispatcher (sonia.scm.web.RestDispatcher)9 BeforeEach (org.junit.jupiter.api.BeforeEach)5 Before (org.junit.Before)3 PullRequestResource (com.cloudogu.scm.review.pullrequest.api.PullRequestResource)2 PullRequestRootResource (com.cloudogu.scm.review.pullrequest.api.PullRequestRootResource)2 BranchRevisionResolver (com.cloudogu.scm.review.pullrequest.dto.BranchRevisionResolver)2 PullRequestMapperImpl (com.cloudogu.scm.review.pullrequest.dto.PullRequestMapperImpl)2 GlobalPullRequestConfig (com.cloudogu.scm.review.config.service.GlobalPullRequestConfig)1 PullRequestConfig (com.cloudogu.scm.review.config.service.PullRequestConfig)1 DefaultPullRequestService (com.cloudogu.scm.review.pullrequest.service.DefaultPullRequestService)1 NamespaceAndName (sonia.scm.repository.NamespaceAndName)1 Repository (sonia.scm.repository.Repository)1 DisplayUser (sonia.scm.user.DisplayUser)1 User (sonia.scm.user.User)1