1 package com.atlassian.plugins.rest.module;
2
3 import com.atlassian.plugins.rest.common.version.ApiVersion;
4 import org.junit.Test;
5
6 import java.util.Collections;
7
8 import static org.hamcrest.MatcherAssert.assertThat;
9 import static org.hamcrest.Matchers.is;
10
11
12 public class TestRestApiContext {
13 @Test
14 public void fullyParametrisedRestApiContextProducesCorrectUrl() {
15 RestApiContext context = new RestApiContext("restContext", "apiContext", new com.atlassian.plugins.rest.module.ApiVersion("1.2.3"), Collections.<String>emptySet());
16 assertThat(context.getPathToVersion(), is("/restContext/apiContext/1.2.3"));
17 }
18
19 @Test
20 public void restApiContextWithoutVersionProducesLatestVersionUrl() {
21 RestApiContext context = new RestApiContext("restContext", "apiContext", new com.atlassian.plugins.rest.module.ApiVersion(ApiVersion.NONE_STRING), Collections.<String>emptySet());
22 assertThat(context.getPathToVersion(), is("/restContext/apiContext"));
23 }
24
25 @Test
26 public void contextlessPathIsCorrect() {
27 RestApiContext restApiContext = new RestApiContext("restContext", "apiContext", new com.atlassian.plugins.rest.module.ApiVersion("1.2.3"), Collections.<String>emptySet());
28 assertThat(restApiContext.getContextlessPathToVersion(), is(restApiContext.getApiPath() + RestApiContext.SLASH + restApiContext.getVersion()));
29 }
30 }