Projects REST interface
parent
ce867018a7
commit
7bdf45340c
@ -1,5 +0,0 @@
|
||||
package org.gcube.application.geoportal.service.rest;
|
||||
|
||||
public class Profiles {
|
||||
|
||||
}
|
@ -1,75 +1,91 @@
|
||||
package org.gcube.application.geoportal.service;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.cms.tests.TokenSetter;
|
||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.client.Entity;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ProjectTests extends BasicServiceTestUnit{
|
||||
|
||||
String testProfileId="profiled_concessione";
|
||||
String projectId="asdlkjgdasfjklgadjhkl";
|
||||
|
||||
@Test
|
||||
public void getAll() {
|
||||
WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
||||
System.out.println(target.request(MediaType.APPLICATION_JSON).get(List.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFilteredAll() {
|
||||
WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
||||
Document document =new Document(Collections.singletonMap("key", "value"));
|
||||
|
||||
System.out.println(target.path("search").request(MediaType.APPLICATION_JSON).
|
||||
post(Entity.entity(document, MediaType.APPLICATION_JSON)));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllByProfile() {
|
||||
WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
||||
System.out.println(target.path(testProfileId).request(MediaType.APPLICATION_JSON).get(List.class));
|
||||
String testProfileId="profiled-concessioni";
|
||||
|
||||
@Before
|
||||
public void setContext(){
|
||||
TokenSetter.set(scope);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getFilteredByProfile() {
|
||||
WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
||||
Document document =new Document(Collections.singletonMap("key", "value"));
|
||||
|
||||
System.out.println(target.path("search").path(testProfileId).request(MediaType.APPLICATION_JSON).
|
||||
post(Entity.entity(document, MediaType.APPLICATION_JSON)));
|
||||
|
||||
public void testMissingProfile(){
|
||||
Response resp = target(InterfaceConstants.Methods.PROJECTS)
|
||||
.path("non-existent-profile").request().get();
|
||||
assertEquals(resp.getStatus(),404);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void getById() {
|
||||
WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
||||
System.out.println(target.path(testProfileId).path(projectId).request(MediaType.APPLICATION_JSON).get().readEntity(String.class));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void registerNew() {
|
||||
WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
||||
Document document =new Document(Collections.singletonMap("key", "value"));
|
||||
|
||||
System.out.println(target.path(testProfileId).request(MediaType.APPLICATION_JSON).
|
||||
put(Entity.entity(document, MediaType.APPLICATION_JSON)));
|
||||
public void getAll() {
|
||||
System.out.println(target(InterfaceConstants.Methods.PROJECTS).path(testProfileId).request(MediaType.APPLICATION_JSON).get(List.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateDocument() {
|
||||
WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
||||
Document document =new Document(Collections.singletonMap("key", "value"));
|
||||
|
||||
System.out.println(target.path(testProfileId).path(projectId).request(MediaType.APPLICATION_JSON).
|
||||
put(Entity.entity(document, MediaType.APPLICATION_JSON)));
|
||||
}
|
||||
// @Test
|
||||
// public void getFilteredAll() {
|
||||
// WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
||||
// Document document =new Document(Collections.singletonMap("key", "value"));
|
||||
//
|
||||
// System.out.println(target.path("search").request(MediaType.APPLICATION_JSON).
|
||||
// post(Entity.entity(document, MediaType.APPLICATION_JSON)));
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void getAllByProfile() {
|
||||
// WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
||||
// System.out.println(target.path(testProfileId).request(MediaType.APPLICATION_JSON).get(List.class));
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void getFilteredByProfile() {
|
||||
// WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
||||
// Document document =new Document(Collections.singletonMap("key", "value"));
|
||||
//
|
||||
// System.out.println(target.path("search").path(testProfileId).request(MediaType.APPLICATION_JSON).
|
||||
// post(Entity.entity(document, MediaType.APPLICATION_JSON)));
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// public void getById() {
|
||||
// WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
||||
// System.out.println(target.path(testProfileId).path(projectId).request(MediaType.APPLICATION_JSON).get().readEntity(String.class));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// public void registerNew() {
|
||||
// WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
||||
// Document document =new Document(Collections.singletonMap("key", "value"));
|
||||
//
|
||||
// System.out.println(target.path(testProfileId).request(MediaType.APPLICATION_JSON).
|
||||
// put(Entity.entity(document, MediaType.APPLICATION_JSON)));
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void updateDocument() {
|
||||
// WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
||||
// Document document =new Document(Collections.singletonMap("key", "value"));
|
||||
//
|
||||
// System.out.println(target.path(testProfileId).path(projectId).request(MediaType.APPLICATION_JSON).
|
||||
// put(Entity.entity(document, MediaType.APPLICATION_JSON)));
|
||||
// }
|
||||
}
|
||||
|
Loading…
Reference in New Issue