mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 16:35:45 +01:00
Rename group resource classes
This commit is contained in:
@@ -23,12 +23,12 @@ import javax.ws.rs.core.UriInfo;
|
||||
import java.util.Collection;
|
||||
|
||||
@Produces(VndMediaType.GROUP)
|
||||
public class GroupSubResource extends AbstractManagerResource<Group, GroupException> {
|
||||
public class GroupResource extends AbstractManagerResource<Group, GroupException> {
|
||||
|
||||
private final GroupToGroupDtoMapper groupToGroupDtoMapper;
|
||||
|
||||
@Inject
|
||||
public GroupSubResource(GroupManager manager, GroupToGroupDtoMapper groupToGroupDtoMapper) {
|
||||
public GroupResource(GroupManager manager, GroupToGroupDtoMapper groupToGroupDtoMapper) {
|
||||
super(manager);
|
||||
this.groupToGroupDtoMapper = groupToGroupDtoMapper;
|
||||
}
|
||||
@@ -3,18 +3,18 @@ package sonia.scm.api.v2.resources;
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
@Path(GroupV2Resource.GROUPS_PATH_V2)
|
||||
public class GroupV2Resource {
|
||||
@Path(GroupRootResource.GROUPS_PATH_V2)
|
||||
public class GroupRootResource {
|
||||
|
||||
public static final String GROUPS_PATH_V2 = "v2/groups/";
|
||||
|
||||
private final GroupCollectionResource groupCollectionResource;
|
||||
private final GroupSubResource groupSubResource;
|
||||
private final GroupResource groupResource;
|
||||
|
||||
@Inject
|
||||
public GroupV2Resource(GroupCollectionResource groupCollectionResource, GroupSubResource groupSubResource) {
|
||||
public GroupRootResource(GroupCollectionResource groupCollectionResource, GroupResource groupResource) {
|
||||
this.groupCollectionResource = groupCollectionResource;
|
||||
this.groupSubResource = groupSubResource;
|
||||
this.groupResource = groupResource;
|
||||
}
|
||||
|
||||
@Path("")
|
||||
@@ -23,7 +23,7 @@ public class GroupV2Resource {
|
||||
}
|
||||
|
||||
@Path("{id}")
|
||||
public GroupSubResource getGroupSubResource() {
|
||||
return groupSubResource;
|
||||
public GroupResource getGroupResource() {
|
||||
return groupResource;
|
||||
}
|
||||
}
|
||||
@@ -15,19 +15,19 @@ class ResourceLinks {
|
||||
private final LinkBuilder groupLinkBuilder;
|
||||
|
||||
private GroupLinks(UriInfo uriInfo) {
|
||||
groupLinkBuilder = new LinkBuilder(uriInfo, GroupV2Resource.class, GroupSubResource.class);
|
||||
groupLinkBuilder = new LinkBuilder(uriInfo, GroupRootResource.class, GroupResource.class);
|
||||
}
|
||||
|
||||
String self(String name) {
|
||||
return groupLinkBuilder.method("getGroupSubResource").parameters(name).method("get").parameters().href();
|
||||
return groupLinkBuilder.method("getGroupResource").parameters(name).method("get").parameters().href();
|
||||
}
|
||||
|
||||
String delete(String name) {
|
||||
return groupLinkBuilder.method("getGroupSubResource").parameters(name).method("delete").parameters().href();
|
||||
return groupLinkBuilder.method("getGroupResource").parameters(name).method("delete").parameters().href();
|
||||
}
|
||||
|
||||
String update(String name) {
|
||||
return groupLinkBuilder.method("getGroupSubResource").parameters(name).method("update").parameters().href();
|
||||
return groupLinkBuilder.method("getGroupResource").parameters(name).method("update").parameters().href();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class ResourceLinks {
|
||||
private final LinkBuilder collectionLinkBuilder;
|
||||
|
||||
private GroupCollectionLinks(UriInfo uriInfo) {
|
||||
collectionLinkBuilder = new LinkBuilder(uriInfo, GroupV2Resource.class, GroupCollectionResource.class);
|
||||
collectionLinkBuilder = new LinkBuilder(uriInfo, GroupRootResource.class, GroupCollectionResource.class);
|
||||
}
|
||||
|
||||
String self() {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class GroupCollectionToDtoMapperTest {
|
||||
public void init() throws URISyntaxException {
|
||||
uriInfoStore.set(uriInfo);
|
||||
URI baseUri = new URI("http://example.com/base/");
|
||||
expectedBaseUri = baseUri.resolve(GroupV2Resource.GROUPS_PATH_V2 + "/");
|
||||
expectedBaseUri = baseUri.resolve(GroupRootResource.GROUPS_PATH_V2 + "/");
|
||||
when(uriInfo.getBaseUri()).thenReturn(baseUri);
|
||||
subjectThreadState.bind();
|
||||
ThreadContext.bind(subject);
|
||||
|
||||
@@ -38,7 +38,7 @@ import static org.mockito.MockitoAnnotations.initMocks;
|
||||
password = "secret",
|
||||
configuration = "classpath:sonia/scm/repository/shiro.ini"
|
||||
)
|
||||
public class GroupV2ResourceTest {
|
||||
public class GroupRootResourceTest {
|
||||
|
||||
@Rule
|
||||
public ShiroRule shiro = new ShiroRule();
|
||||
@@ -73,10 +73,10 @@ public class GroupV2ResourceTest {
|
||||
when(groupManager.get("admin")).thenReturn(group);
|
||||
|
||||
GroupCollectionResource groupCollectionResource = new GroupCollectionResource(groupManager, dtoToGroupMapper, groupToDtoMapper, groupCollectionToDtoMapper);
|
||||
GroupSubResource groupSubResource = new GroupSubResource(groupManager, groupToDtoMapper);
|
||||
GroupV2Resource groupV2Resource = new GroupV2Resource(groupCollectionResource, groupSubResource);
|
||||
GroupResource groupResource = new GroupResource(groupManager, groupToDtoMapper);
|
||||
GroupRootResource groupRootResource = new GroupRootResource(groupCollectionResource, groupResource);
|
||||
|
||||
dispatcher.getRegistry().addSingletonResource(groupV2Resource);
|
||||
dispatcher.getRegistry().addSingletonResource(groupRootResource);
|
||||
|
||||
when(uriInfo.getBaseUri()).thenReturn(URI.create("/"));
|
||||
when(uriInfoStore.get()).thenReturn(uriInfo);
|
||||
@@ -84,7 +84,7 @@ public class GroupV2ResourceTest {
|
||||
|
||||
@Test
|
||||
public void shouldGetNotFoundForNotExistentGroup() throws URISyntaxException {
|
||||
MockHttpRequest request = MockHttpRequest.get("/" + GroupV2Resource.GROUPS_PATH_V2 + "nosuchgroup");
|
||||
MockHttpRequest request = MockHttpRequest.get("/" + GroupRootResource.GROUPS_PATH_V2 + "nosuchgroup");
|
||||
MockHttpResponse response = new MockHttpResponse();
|
||||
|
||||
dispatcher.invoke(request, response);
|
||||
@@ -95,7 +95,7 @@ public class GroupV2ResourceTest {
|
||||
@Test
|
||||
@SubjectAware(username = "unpriv")
|
||||
public void shouldGetNotAuthorizedForWrongUser() throws URISyntaxException {
|
||||
MockHttpRequest request = MockHttpRequest.get("/" + GroupV2Resource.GROUPS_PATH_V2 + "admin");
|
||||
MockHttpRequest request = MockHttpRequest.get("/" + GroupRootResource.GROUPS_PATH_V2 + "admin");
|
||||
MockHttpResponse response = new MockHttpResponse();
|
||||
|
||||
dispatcher.invoke(request, response);
|
||||
@@ -111,7 +111,7 @@ public class GroupV2ResourceTest {
|
||||
group.setMembers(Collections.singletonList("user"));
|
||||
when(groupManager.get("admin")).thenReturn(group);
|
||||
|
||||
MockHttpRequest request = MockHttpRequest.get("/" + GroupV2Resource.GROUPS_PATH_V2 + "admin");
|
||||
MockHttpRequest request = MockHttpRequest.get("/" + GroupRootResource.GROUPS_PATH_V2 + "admin");
|
||||
MockHttpResponse response = new MockHttpResponse();
|
||||
|
||||
dispatcher.invoke(request, response);
|
||||
@@ -129,7 +129,7 @@ public class GroupV2ResourceTest {
|
||||
byte[] groupJson = Resources.toByteArray(url);
|
||||
|
||||
MockHttpRequest request = MockHttpRequest
|
||||
.post("/" + GroupV2Resource.GROUPS_PATH_V2)
|
||||
.post("/" + GroupRootResource.GROUPS_PATH_V2)
|
||||
.contentType(VndMediaType.GROUP)
|
||||
.content(groupJson);
|
||||
MockHttpResponse response = new MockHttpResponse();
|
||||
@@ -41,7 +41,7 @@ public class GroupToGroupDtoMapperTest {
|
||||
public void init() throws URISyntaxException {
|
||||
initMocks(this);
|
||||
URI baseUri = new URI("http://example.com/base/");
|
||||
expectedBaseUri = baseUri.resolve(GroupV2Resource.GROUPS_PATH_V2 + "/");
|
||||
expectedBaseUri = baseUri.resolve(GroupRootResource.GROUPS_PATH_V2 + "/");
|
||||
when(uriInfo.getBaseUri()).thenReturn(baseUri);
|
||||
when(uriInfoStore.get()).thenReturn(uriInfo);
|
||||
subjectThreadState.bind();
|
||||
|
||||
@@ -52,31 +52,31 @@ public class ResourceLinksTest {
|
||||
@Test
|
||||
public void shouldCreateCorrectGroupSelfUrl() {
|
||||
String url = group(uriInfo).self("nobodies");
|
||||
assertEquals(BASE_URL + GroupV2Resource.GROUPS_PATH_V2 + "nobodies", url);
|
||||
assertEquals(BASE_URL + GroupRootResource.GROUPS_PATH_V2 + "nobodies", url);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCreateCorrectGroupDeleteUrl() {
|
||||
String url = group(uriInfo).delete("nobodies");
|
||||
assertEquals(BASE_URL + GroupV2Resource.GROUPS_PATH_V2 + "nobodies", url);
|
||||
assertEquals(BASE_URL + GroupRootResource.GROUPS_PATH_V2 + "nobodies", url);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCreateCorrectGroupUpdateUrl() {
|
||||
String url = group(uriInfo).update("nobodies");
|
||||
assertEquals(BASE_URL + GroupV2Resource.GROUPS_PATH_V2 + "nobodies", url);
|
||||
assertEquals(BASE_URL + GroupRootResource.GROUPS_PATH_V2 + "nobodies", url);
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void shouldCreateCorrectGroupCreateUrl() {
|
||||
// String url = ResourceLinks.groupCollection(uriInfo).create();
|
||||
// assertEquals(BASE_URL + GroupV2Resource.GROUPS_PATH_V2, url);
|
||||
// assertEquals(BASE_URL + GroupRootResource.GROUPS_PATH_V2, url);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void shouldCreateCorrectGroupCollectionUrl() {
|
||||
// String url = ResourceLinks.groupCollection(uriInfo).self();
|
||||
// assertEquals(BASE_URL + GroupV2Resource.GROUPS_PATH_V2, url);
|
||||
// assertEquals(BASE_URL + GroupRootResource.GROUPS_PATH_V2, url);
|
||||
// }
|
||||
|
||||
@Before
|
||||
|
||||
Reference in New Issue
Block a user