use of org.eclipse.che.api.core.rest.shared.dto.Link in project che by eclipse.
the class ProjectServiceTest method validateFileLinks.
private void validateFileLinks(ItemReference item) {
Link link = item.getLink("delete");
assertNotNull(link);
assertEquals(link.getMethod(), DELETE);
assertEquals(link.getHref(), "http://localhost:8080/api/project" + item.getPath());
link = item.getLink("update content");
assertNotNull(link);
assertEquals(link.getMethod(), PUT);
assertEquals(link.getConsumes(), "*/*");
assertEquals(link.getHref(), "http://localhost:8080/api/project" + "/file" + item.getPath());
}
use of org.eclipse.che.api.core.rest.shared.dto.Link in project che by eclipse.
the class ProjectServiceLinksInjectorTest method verifyFileLinks.
@Test
public void verifyFileLinks() throws Exception {
ItemReference itemReference = DtoFactory.newDto(ItemReference.class);
itemReference.withPath(FILE_PATH);
ItemReference result = projectServiceLinksInjector.injectFileLinks(itemReference, serviceContext);
assertEquals(3, result.getLinks().size());
Link updateLink = result.getLink("update content");
assertNotNull(updateLink);
assertEquals("localhost:8080/project/file/project1/folder/file", updateLink.getHref());
assertEquals(HttpMethod.PUT, updateLink.getMethod());
assertEquals(LINK_REL_UPDATE_CONTENT, updateLink.getRel());
assertEquals(null, updateLink.getProduces());
assertEquals(MediaType.WILDCARD, updateLink.getConsumes());
Link getContentLink = result.getLink("get content");
assertNotNull(getContentLink);
assertEquals("localhost:8080/project/file/project1/folder/file", getContentLink.getHref());
assertEquals(HttpMethod.GET, getContentLink.getMethod());
assertEquals(LINK_REL_GET_CONTENT, getContentLink.getRel());
assertEquals(APPLICATION_JSON, getContentLink.getProduces());
Link deleteLink = result.getLink("delete");
assertNotNull(deleteLink);
assertEquals("localhost:8080/project/project1/folder/file", deleteLink.getHref());
assertEquals(HttpMethod.DELETE, deleteLink.getMethod());
assertEquals(LINK_REL_DELETE, deleteLink.getRel());
}
use of org.eclipse.che.api.core.rest.shared.dto.Link in project che by eclipse.
the class RecipeWidgetImplTest method recipeURLShouldBeReturned.
@Test
public void recipeURLShouldBeReturned() {
Link link = mock(Link.class);
when(descriptor.getLink(anyString())).thenReturn(link);
tag.getRecipeUrl();
verify(descriptor).getLink("get recipe script");
verify(link).getHref();
}
use of org.eclipse.che.api.core.rest.shared.dto.Link in project che by eclipse.
the class ProjectServiceLinksInjector method injectFolderLinks.
/**
* Adds links for working with a folder.
* Operations which are supported:
* <p>get children</p>
* <p>get tree</p>
* <p>delete</p>
*
* @param itemReference
* information about node
* @param serviceContext
* context of {@link ProjectService}
* @return node with injected folder's links
*/
public ItemReference injectFolderLinks(ItemReference itemReference, ServiceContext serviceContext) {
final UriBuilder uriBuilder = getUriBuilder(serviceContext);
final List<Link> links = new ArrayList<>();
final String relPath = itemReference.getPath().substring(1);
links.add(createLink(GET, tuneUrl(uriBuilder.clone().path(ProjectService.class).path(ProjectService.class, "getChildren").build(new String[] { relPath }, false)), APPLICATION_JSON, LINK_REL_CHILDREN));
links.add(createLink(GET, tuneUrl(uriBuilder.clone().path(ProjectService.class).path(ProjectService.class, "getTree").build(new String[] { relPath }, false)), APPLICATION_JSON, LINK_REL_TREE));
links.add(createLink(DELETE, tuneUrl(uriBuilder.clone().path(ProjectService.class).path(ProjectService.class, "delete").build(new String[] { relPath }, false)), LINK_REL_DELETE));
return itemReference.withLinks(links);
}
use of org.eclipse.che.api.core.rest.shared.dto.Link in project che by eclipse.
the class RemoteOAuthTokenProviderTest method shouldConstructCorrectUrl.
@Test
public void shouldConstructCorrectUrl() throws Exception {
//given
OAuthToken expected = DtoFactory.newDto(OAuthToken.class).withScope("scope").withToken("token");
when(httpJsonResponse.asDto(any(Class.class))).thenReturn(expected);
when(httpJsonRequest.request()).thenReturn(httpJsonResponse);
//when
tokenProvider.getToken("google", "id");
//then
ArgumentCaptor<Link> argumentCaptor = ArgumentCaptor.forClass(Link.class);
verify(httpJsonRequestFactory).fromLink(argumentCaptor.capture());
Link link = argumentCaptor.getValue();
assertEquals(link.getMethod(), "GET");
assertEquals(link.getHref(), "http://dev.box.com/api/oauth/token?oauth_provider=google");
assertEquals(link.getParameters().size(), 0);
}
Aggregations