Search in sources :

Example 1 with DefaultPullRequestService

use of com.cloudogu.scm.review.pullrequest.service.DefaultPullRequestService 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)

Aggregations

DefaultPullRequestService (com.cloudogu.scm.review.pullrequest.service.DefaultPullRequestService)1 Before (org.junit.Before)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 RestDispatcher (sonia.scm.web.RestDispatcher)1