92 lines
2.9 KiB
Java
92 lines
2.9 KiB
Java
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="concessione";
|
|
|
|
@Before
|
|
public void setContext(){
|
|
TokenSetter.set(scope);
|
|
}
|
|
|
|
@Test
|
|
public void testMissingProfile(){
|
|
Response resp = target(InterfaceConstants.Methods.PROJECTS)
|
|
.path("non-existent-profile").request().get();
|
|
assertEquals(resp.getStatus(),404);
|
|
}
|
|
|
|
|
|
@Test
|
|
public void getAll() {
|
|
System.out.println(target(InterfaceConstants.Methods.PROJECTS).path(testProfileId).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));
|
|
// }
|
|
//
|
|
// @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)));
|
|
// }
|
|
}
|