use of sonia.scm.user.User in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method shouldReturnBranchesNotDifferResultIfNoChangesetsInDiff.
@Test
@SubjectAware(username = "dent")
public void shouldReturnBranchesNotDifferResultIfNoChangesetsInDiff() throws URISyntaxException, IOException {
mockLoggedInUser(new User("dent"));
mockLogCommandForPullRequestCheck(emptyList());
MockHttpRequest request = MockHttpRequest.get("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/ns/repo/check?source=feature&target=master");
dispatcher.invoke(request, response);
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentAsString()).contains("\"status\":\"BRANCHES_NOT_DIFFER\"");
assertThat(response.getContentAsString()).contains("\"_links\":{\"self\":{\"href\":\"/v2/pull-requests/ns/repo/check?source=feature&target=master\"}}");
}
use of sonia.scm.user.User in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method mockPrincipal.
private void mockPrincipal() {
ThreadContext.bind(subject);
PrincipalCollection principals = mock(PrincipalCollection.class);
when(subject.getPrincipals()).thenReturn(principals);
User user1 = new User();
user1.setName("user1");
user1.setDisplayName("User 1");
when(principals.oneByType(User.class)).thenReturn(user1);
}
use of sonia.scm.user.User in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method shouldNotReturnAnySubscriptionLinkOnMissingUserMail.
@Test
public void shouldNotReturnAnySubscriptionLinkOnMissingUserMail() throws URISyntaxException, IOException {
// the PR has no subscriber
mockLoggedInUser(new User("user1", "User 1", null));
MockHttpRequest request = MockHttpRequest.get("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/ns/repo/1/subscription");
dispatcher.invoke(request, response);
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentAsString()).isNullOrEmpty();
}
use of sonia.scm.user.User in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method shouldGetTheSubscriptionLink.
@Test
public void shouldGetTheSubscriptionLink() throws URISyntaxException, IOException {
// the PR has no subscriber
PullRequest pullRequest = createPullRequest();
when(store.get("1")).thenReturn(pullRequest);
mockLoggedInUser(new User("user1", "User 1", "email@d.de"));
MockHttpRequest request = MockHttpRequest.get("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/ns/repo/1/subscription");
dispatcher.invoke(request, response);
assertThat(response.getStatus()).isEqualTo(200);
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonNode = mapper.readValue(response.getContentAsString(), JsonNode.class);
assertThat(jsonNode.path("_links").get("subscribe")).isNotNull();
assertThat(jsonNode.path("_links").get("unsubscribe")).isNull();
}
use of sonia.scm.user.User in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method shouldGetTheUnsubscribeLink.
@Test
public void shouldGetTheUnsubscribeLink() throws URISyntaxException, IOException {
PullRequest pullRequest = createPullRequest();
pullRequest.setSubscriber(singleton("user1"));
when(store.get("1")).thenReturn(pullRequest);
mockLoggedInUser(new User("user1", "User 1", "email@d.de"));
MockHttpRequest request = MockHttpRequest.get("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/ns/repo/1/subscription");
dispatcher.invoke(request, response);
assertThat(response.getStatus()).isEqualTo(200);
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonNode = mapper.readValue(response.getContentAsString(), JsonNode.class);
assertThat(jsonNode.path("_links").get("subscribe")).isNull();
assertThat(jsonNode.path("_links").get("unsubscribe")).isNotNull();
}
Aggregations