use of jetbrains.buildServer.buildTriggers.vcs.git.SpaceExternalChangeViewerExtension in project teamcity-git by JetBrains.
the class SpaceExternalChangeViewerExtensionTest method jetbrainsTeamVcsRoot.
@Test
void jetbrainsTeamVcsRoot() {
// given
final VcsRootInstanceImpl vcsRoot = Mockito.mock(VcsRootInstanceImpl.class);
Mockito.doReturn(Constants.VCS_NAME).when(vcsRoot).getVcsName();
Mockito.doReturn(selfHosted).when(vcsRoot).getProperty(Constants.FETCH_URL);
final SProject project = Mockito.mock(SProject.class);
final SVcsRoot sVcsRoot = Mockito.mock(SVcsRoot.class);
Mockito.doReturn(sVcsRoot).when(vcsRoot).getParent();
Mockito.doReturn(project).when(sVcsRoot).getProject();
final OAuthConnectionDescriptor connection = Mockito.mock(OAuthConnectionDescriptor.class);
Mockito.doReturn(ImmutableList.of(connection)).when(myOAuthConnectionsManager).getAvailableConnectionsOfType(project, SpaceOAuthProvider.TYPE);
Mockito.doReturn(ImmutableMap.of(SPACE_SERVER_URL, selfHostedServerUrl, SPACE_CLIENT_ID, "ignore", SPACE_CLIENT_SECRET, "ignore")).when(connection).getParameters();
// test
SpaceExternalChangeViewerExtension extension = mySpaceExternalChangeViewerExtension();
final Map<String, String> availableProperties = extension.getAvailableProperties(vcsRoot);
assertEquals(availableProperties, ImmutableMap.of(PropertyType.CHANGE_SET_TYPE, "https://jetbrains.team/p/tc/repositories/TeamCity/revision/${changeSetId}", PropertyType.LINK_TEXT, "Open in Space", PropertyType.LINK_ICON_CLASS, "tc-icon_space"));
}
use of jetbrains.buildServer.buildTriggers.vcs.git.SpaceExternalChangeViewerExtension in project teamcity-git by JetBrains.
the class SpaceExternalChangeViewerExtensionTest method jetbrainsTeamVcsRoot_connectionNotFound.
@Test
void jetbrainsTeamVcsRoot_connectionNotFound() {
// given
final VcsRootInstanceImpl vcsRoot = Mockito.mock(VcsRootInstanceImpl.class);
Mockito.doReturn(Constants.VCS_NAME).when(vcsRoot).getVcsName();
Mockito.doReturn(selfHosted).when(vcsRoot).getProperty(Constants.FETCH_URL);
final SProject project = Mockito.mock(SProject.class);
final SVcsRoot sVcsRoot = Mockito.mock(SVcsRoot.class);
Mockito.doReturn(sVcsRoot).when(vcsRoot).getParent();
Mockito.doReturn(project).when(sVcsRoot).getProject();
// test
SpaceExternalChangeViewerExtension extension = mySpaceExternalChangeViewerExtension();
final Map<String, String> availableProperties = extension.getAvailableProperties(vcsRoot);
assertNull(availableProperties);
}
use of jetbrains.buildServer.buildTriggers.vcs.git.SpaceExternalChangeViewerExtension in project teamcity-git by JetBrains.
the class SpaceExternalChangeViewerExtensionTest method jetbrainsTeamVcsRoot_twoConnections.
@Test
void jetbrainsTeamVcsRoot_twoConnections() {
// given
final VcsRootInstanceImpl vcsRoot = Mockito.mock(VcsRootInstanceImpl.class);
Mockito.doReturn(Constants.VCS_NAME).when(vcsRoot).getVcsName();
Mockito.doReturn(selfHosted).when(vcsRoot).getProperty(Constants.FETCH_URL);
final SProject project = Mockito.mock(SProject.class);
final SVcsRoot sVcsRoot = Mockito.mock(SVcsRoot.class);
Mockito.doReturn(sVcsRoot).when(vcsRoot).getParent();
Mockito.doReturn(project).when(sVcsRoot).getProject();
final OAuthConnectionDescriptor connection1 = Mockito.mock(OAuthConnectionDescriptor.class);
final OAuthConnectionDescriptor connection2 = Mockito.mock(OAuthConnectionDescriptor.class);
Mockito.doReturn(ImmutableList.of(connection1, connection2)).when(myOAuthConnectionsManager).getAvailableConnectionsOfType(project, SpaceOAuthProvider.TYPE);
Mockito.doReturn(ImmutableMap.of(SPACE_SERVER_URL, hostedOnJetBrainsSideServerUrl, SPACE_CLIENT_ID, "ignore", SPACE_CLIENT_SECRET, "ignore")).when(connection1).getParameters();
Mockito.doReturn(ImmutableMap.of(SPACE_SERVER_URL, selfHostedServerUrl, SPACE_CLIENT_ID, "ignore", SPACE_CLIENT_SECRET, "ignore")).when(connection2).getParameters();
// test
SpaceExternalChangeViewerExtension extension = mySpaceExternalChangeViewerExtension();
final Map<String, String> availableProperties = extension.getAvailableProperties(vcsRoot);
assertEquals(availableProperties, ImmutableMap.of(PropertyType.CHANGE_SET_TYPE, "https://jetbrains.team/p/tc/repositories/TeamCity/revision/${changeSetId}", PropertyType.LINK_TEXT, "Open in Space", PropertyType.LINK_ICON_CLASS, "tc-icon_space"));
}
use of jetbrains.buildServer.buildTriggers.vcs.git.SpaceExternalChangeViewerExtension in project teamcity-git by JetBrains.
the class SpaceExternalChangeViewerExtensionTest method jetbrainsTeamVcsRoot_urlNotFound.
@Test
void jetbrainsTeamVcsRoot_urlNotFound() {
// given
final VcsRootInstanceImpl vcsRoot = Mockito.mock(VcsRootInstanceImpl.class);
Mockito.doReturn(Constants.VCS_NAME).when(vcsRoot).getVcsName();
// test
SpaceExternalChangeViewerExtension extension = mySpaceExternalChangeViewerExtension();
final Map<String, String> availableProperties = extension.getAvailableProperties(vcsRoot);
assertNull(availableProperties);
}
use of jetbrains.buildServer.buildTriggers.vcs.git.SpaceExternalChangeViewerExtension in project teamcity-git by JetBrains.
the class SpaceExternalChangeViewerExtensionTest method jetbrainsTeamVcsRoot_urlIsIncorrect.
@Test
void jetbrainsTeamVcsRoot_urlIsIncorrect() {
// given
final VcsRootInstanceImpl vcsRoot = Mockito.mock(VcsRootInstanceImpl.class);
Mockito.doReturn(Constants.VCS_NAME).when(vcsRoot).getVcsName();
Mockito.doReturn("").when(vcsRoot).getProperty(Constants.FETCH_URL);
// test
SpaceExternalChangeViewerExtension extension = mySpaceExternalChangeViewerExtension();
final Map<String, String> availableProperties = extension.getAvailableProperties(vcsRoot);
assertNull(availableProperties);
}
Aggregations