/**
*
* Copyright (C) norad.fr
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package fr.norad.visuwall.providers.teamcity;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class TeamCityUrlBuilderTest {
private static final String TEAM_CITY_URL = "http://teamcity.jetbrains.com";
TeamCityUrlBuilder builder = new TeamCityUrlBuilder(TEAM_CITY_URL);
@Test
public void should_create_valid_projects_url() {
String projectsUrl = builder.getProjects();
assertEquals(TEAM_CITY_URL + "/app/rest/projects", projectsUrl);
}
@Test
public void should_create_valid_project_url() {
String projectUrl = builder.getProject("project54");
assertEquals(TEAM_CITY_URL + "/app/rest/projects/id:project54", projectUrl);
}
@Test
public void should_create_valid_build_type_url() {
String buildTypeUrl = builder.getBuildType("bt296");
assertEquals(TEAM_CITY_URL + "/app/rest/buildTypes/id:bt296", buildTypeUrl);
}
@Test
public void should_create_valid_build_url() {
String buildTypeUrl = builder.getBuild(47068);
assertEquals(TEAM_CITY_URL + "/app/rest/builds/id:47068", buildTypeUrl);
}
@Test
public void should_create_valid_builds_list() {
String buildListUrl = builder.getBuildList("bt297");
assertEquals(TEAM_CITY_URL + "/app/rest/buildTypes/id:bt297/builds", buildListUrl);
}
@Test
public void should_create_valid_version() {
String versionUrl = builder.getVersion();
assertEquals(TEAM_CITY_URL + "/app/rest/version", versionUrl);
}
@Test
public void should_create_valid_server() {
String serverUrl = builder.getServer();
assertEquals(TEAM_CITY_URL + "/app/rest/server", serverUrl);
}
@Test
public void should_create_valid_change_url() {
String changeUrl = builder.getChange("3");
assertEquals(TEAM_CITY_URL + "/app/rest/changes/id:3", changeUrl);
}
@Test
public void should_create_valid_username_url() {
String usernameUrl = builder.getUserByUsername("davcamer");
assertEquals(TEAM_CITY_URL + "/app/rest/users/username:davcamer", usernameUrl);
}
@Test
public void should_create_pom_url() {
String pomUrl = builder.getPomUrl(26);
assertEquals(TEAM_CITY_URL + "/builds/id:26/pom.xml", pomUrl);
}
}