Projects REST interface
This commit is contained in:
parent
ce867018a7
commit
7bdf45340c
|
@ -34,4 +34,5 @@ public class ProfiledDocument {
|
||||||
private TemporalReference temporalReference;
|
private TemporalReference temporalReference;
|
||||||
|
|
||||||
private Document theDocument;
|
private Document theDocument;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ public class InterfaceConstants {
|
||||||
public static final String PROFILES="profiles";
|
public static final String PROFILES="profiles";
|
||||||
public static final String SECTIONS="sections";
|
public static final String SECTIONS="sections";
|
||||||
public static final String PROJECTS="projects";
|
public static final String PROJECTS="projects";
|
||||||
|
|
||||||
|
|
||||||
public static final String CONCESSIONI="concessioni";
|
public static final String CONCESSIONI="concessioni";
|
||||||
public static final String MONGO_CONCESSIONI="mongo-concessioni";
|
public static final String MONGO_CONCESSIONI="mongo-concessioni";
|
||||||
|
|
|
@ -3,7 +3,7 @@ package org.gcube.application.geoportal.service;
|
||||||
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
||||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||||
import org.gcube.application.geoportal.service.rest.ConcessioniOverMongo;
|
import org.gcube.application.geoportal.service.rest.ConcessioniOverMongo;
|
||||||
import org.gcube.application.geoportal.service.rest.Profiles;
|
|
||||||
import org.gcube.application.geoportal.service.rest.Projects;
|
import org.gcube.application.geoportal.service.rest.Projects;
|
||||||
import org.gcube.application.geoportal.service.rest.Sections;
|
import org.gcube.application.geoportal.service.rest.Sections;
|
||||||
import org.gcube.application.geoportal.service.utils.Serialization;
|
import org.gcube.application.geoportal.service.utils.Serialization;
|
||||||
|
@ -23,7 +23,7 @@ public class GeoPortalService extends ResourceConfig{
|
||||||
registerClasses(ConcessioniOverMongo.class);
|
registerClasses(ConcessioniOverMongo.class);
|
||||||
registerClasses(Projects.class);
|
registerClasses(Projects.class);
|
||||||
registerClasses(Sections.class);
|
registerClasses(Sections.class);
|
||||||
registerClasses(Profiles.class);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ public interface MongoManagerI<T> {
|
||||||
|
|
||||||
// create
|
// create
|
||||||
|
|
||||||
public T registerNew(T toRegister) throws IOException;
|
public T registerNew(Document toRegister) throws IOException;
|
||||||
|
|
||||||
// update
|
// update
|
||||||
public T update(String id,T toSet) throws IOException;
|
public T update(String id,T toSet) throws IOException;
|
||||||
|
@ -27,7 +27,8 @@ public interface MongoManagerI<T> {
|
||||||
|
|
||||||
// query
|
// query
|
||||||
|
|
||||||
public Iterable<T> query(QueryRequest request);
|
public Iterable<Document> query(QueryRequest request);
|
||||||
|
public Iterable<T> filter(QueryRequest request);
|
||||||
|
|
||||||
// materialize
|
// materialize
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,10 @@ import org.gcube.application.geoportal.service.model.internal.faults.Configurati
|
||||||
import org.gcube.application.geoportal.service.model.internal.faults.DeletionException;
|
import org.gcube.application.geoportal.service.model.internal.faults.DeletionException;
|
||||||
import org.gcube.application.geoportal.service.utils.Serialization;
|
import org.gcube.application.geoportal.service.utils.Serialization;
|
||||||
|
|
||||||
|
import javax.ws.rs.WebApplicationException;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.security.InvalidParameterException;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
@ -23,7 +26,16 @@ import static org.gcube.application.geoportal.service.engine.mongo.ConcessioniMo
|
||||||
public class ProfiledMongoManager extends MongoManager implements MongoManagerI<ProfiledDocument>{
|
public class ProfiledMongoManager extends MongoManager implements MongoManagerI<ProfiledDocument>{
|
||||||
|
|
||||||
|
|
||||||
public ProfiledMongoManager() throws ConfigurationException {
|
String profileId;
|
||||||
|
|
||||||
|
public ProfiledMongoManager(String profileId) throws ConfigurationException {
|
||||||
|
if(profileId==null) throw new InvalidParameterException("Profile ID cannot be null");
|
||||||
|
//check profile existance
|
||||||
|
//ProfileManager.get(profileId);
|
||||||
|
// TODO GET FROM PROFILES
|
||||||
|
if (!profileId.equals("profiled-concessioni")) throw new WebApplicationException("Profile "+profileId+" not registered", Response.Status.NOT_FOUND);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProfiledDocument onUpdate(ProfiledDocument updatedDocument){
|
private ProfiledDocument onUpdate(ProfiledDocument updatedDocument){
|
||||||
|
@ -48,8 +60,13 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProfiledDocument registerNew(ProfiledDocument toRegister) throws IOException {
|
public ProfiledDocument registerNew(Document toRegisterDoc) throws IOException {
|
||||||
super.insert(asDocument(toRegister),getCollectionName());
|
ProfiledDocument toRegister = new ProfiledDocument();
|
||||||
|
toRegister.setTheDocument(toRegisterDoc);
|
||||||
|
|
||||||
|
//TODO initialize ProfiledDocument values
|
||||||
|
|
||||||
|
insert(asDocument(toRegister),getCollectionName());
|
||||||
|
|
||||||
log.trace("Going to register {} ",toRegister);
|
log.trace("Going to register {} ",toRegister);
|
||||||
toRegister=onUpdate(toRegister);
|
toRegister=onUpdate(toRegister);
|
||||||
|
@ -107,7 +124,19 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<ProfiledDocument> query(QueryRequest queryRequest) {
|
public Iterable<Document> query(QueryRequest queryRequest) {
|
||||||
|
log.info("Querying {} ",queryRequest);
|
||||||
|
LinkedBlockingQueue queue=new LinkedBlockingQueue<Concessione>();
|
||||||
|
query(queryRequest,getCollectionName()).forEach(
|
||||||
|
(Consumer<? super Document>) (Document d)->{try{
|
||||||
|
queue.put(d);
|
||||||
|
}catch(Throwable t){log.warn("Unable to translate "+d);}});
|
||||||
|
log.info("Returned {} elements ",queue.size());
|
||||||
|
return queue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<ProfiledDocument> filter(QueryRequest queryRequest) {
|
||||||
log.info("Searching concessione for filter {} ",queryRequest);
|
log.info("Searching concessione for filter {} ",queryRequest);
|
||||||
LinkedBlockingQueue queue=new LinkedBlockingQueue<Concessione>();
|
LinkedBlockingQueue queue=new LinkedBlockingQueue<Concessione>();
|
||||||
query(queryRequest,getCollectionName()).forEach(
|
query(queryRequest,getCollectionName()).forEach(
|
||||||
|
|
|
@ -65,6 +65,9 @@ public class DBConstants {
|
||||||
public static final String PAROLE_CHIAVE="parole_chiave";
|
public static final String PAROLE_CHIAVE="parole_chiave";
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static final ArrayList<Field> COLUMNS=new ArrayList<PostgisTable.Field>();
|
public static final ArrayList<Field> COLUMNS=new ArrayList<PostgisTable.Field>();
|
||||||
public static final PostgisTable CENTROIDS=new PostgisTable("centroids_concessioni",
|
public static final PostgisTable CENTROIDS=new PostgisTable("centroids_concessioni",
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
package org.gcube.application.geoportal.service.rest;
|
|
||||||
|
|
||||||
public class Profiles {
|
|
||||||
|
|
||||||
}
|
|
|
@ -2,133 +2,117 @@ package org.gcube.application.geoportal.service.rest;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.gcube.application.geoportal.common.model.project.Project;
|
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||||
|
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||||
|
import org.gcube.application.geoportal.common.model.rest.Configuration;
|
||||||
|
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||||
|
import org.gcube.application.geoportal.service.engine.mongo.ConcessioniMongoManager;
|
||||||
|
import org.gcube.application.geoportal.service.engine.mongo.ProfiledMongoManager;
|
||||||
|
import org.gcube.application.geoportal.service.engine.postgis.PostgisIndex;
|
||||||
|
import org.gcube.application.geoportal.service.model.internal.faults.ConfigurationException;
|
||||||
|
import org.gcube.application.geoportal.service.utils.Serialization;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Path(InterfaceConstants.Methods.PROJECTS)
|
@Path(InterfaceConstants.Methods.PROJECTS+"/{"+InterfaceConstants.Parameters.PROFILE_ID+"}")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class Projects {
|
public class Projects {
|
||||||
|
|
||||||
//***************** GENERIC PROJECTS
|
private ProfiledMongoManager manager;
|
||||||
// GET ALL
|
|
||||||
@GET
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
public List<Project> getAll() {
|
|
||||||
return new GuardedMethod<List<Project>>() {
|
|
||||||
protected List<Project> run() throws Exception ,WebApplicationException {
|
|
||||||
return Collections.singletonList(new Project());
|
|
||||||
};
|
|
||||||
}.execute().getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
@POST
|
public Projects(@PathParam(InterfaceConstants.Parameters.PROFILE_ID) String profileID) throws ConfigurationException {
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
log.debug("Accessing profiles "+profileID);
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
manager=new GuardedMethod<ProfiledMongoManager>(){
|
||||||
@Path("/search")
|
@Override
|
||||||
public List<Project> getFilteredAll(Document filter){
|
protected ProfiledMongoManager run() throws Exception {
|
||||||
return new GuardedMethod<List<Project>>() {
|
return new ProfiledMongoManager(profileID);
|
||||||
protected List<Project> run() throws Exception ,WebApplicationException {
|
}
|
||||||
return Collections.singletonList(new Project());
|
}.execute().getResult();
|
||||||
};
|
}
|
||||||
}.execute().getResult();
|
|
||||||
}
|
@GET
|
||||||
|
@Path(InterfaceConstants.Methods.CONFIGURATION_PATH)
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public Configuration getConfiguration(){
|
||||||
|
return new GuardedMethod<Configuration>(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Configuration run() throws Exception, WebApplicationException {
|
||||||
|
//manager.getConfiguration();
|
||||||
|
throw new Exception("Implement This Method");
|
||||||
|
}
|
||||||
|
}.execute().getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//***************** BY PROFILE ID
|
@POST
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public ProfiledDocument createNew(Document d) {
|
||||||
|
return new GuardedMethod<ProfiledDocument>() {
|
||||||
|
@Override
|
||||||
|
protected ProfiledDocument run() throws Exception, WebApplicationException {
|
||||||
|
return manager.registerNew(d);
|
||||||
|
}
|
||||||
|
}.execute().getResult();
|
||||||
|
}
|
||||||
|
|
||||||
// Create new Project
|
//********************************** READ
|
||||||
@PUT
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@GET
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Path("{"+InterfaceConstants.Parameters.PROFILE_ID+"}")
|
public Iterable<?> list() {
|
||||||
public Project registerNew(@PathParam(InterfaceConstants.Parameters.PROFILE_ID)String profileId,
|
return new GuardedMethod<Iterable<?>>() {
|
||||||
Document toRegister) {
|
protected Iterable<?> run() throws Exception ,WebApplicationException {
|
||||||
return new GuardedMethod<Project>() {
|
return manager.query(new QueryRequest());
|
||||||
@Override
|
};
|
||||||
protected Project run() throws Exception, WebApplicationException {
|
}.execute().getResult();
|
||||||
return new Project();
|
}
|
||||||
}
|
|
||||||
}.execute().getResult();
|
// BY ID
|
||||||
}
|
@GET
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@Path("{"+InterfaceConstants.Parameters.PROJECT_ID+"}")
|
||||||
|
public ProfiledDocument getById(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id) {
|
||||||
|
return new GuardedMethod<ProfiledDocument>() {
|
||||||
|
@Override
|
||||||
|
protected ProfiledDocument run() throws Exception, WebApplicationException {
|
||||||
|
return manager.getByID(id);
|
||||||
|
}
|
||||||
|
}.execute().getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// GET ALL (Filters apply)
|
@POST
|
||||||
@POST
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Path("/"+InterfaceConstants.Methods.SEARCH_PATH)
|
||||||
@Path("/search/{"+InterfaceConstants.Parameters.PROFILE_ID+"}")
|
public String search(String filter){
|
||||||
public List<Project> getFilteredAllInProfiles(@PathParam(InterfaceConstants.Parameters.PROFILE_ID)String profileId,
|
return new GuardedMethod<String>() {
|
||||||
Document filters) {
|
@Override
|
||||||
return new GuardedMethod<List<Project>>() {
|
protected String run() throws Exception, WebApplicationException {
|
||||||
protected List<Project> run() throws Exception ,WebApplicationException {
|
QueryRequest req=new QueryRequest();
|
||||||
return Collections.singletonList(new Project());
|
req.setFilter(Document.parse(filter));
|
||||||
};
|
return Serialization.write(manager.query(req));
|
||||||
}.execute().getResult();
|
}
|
||||||
}
|
}.execute().getResult();
|
||||||
|
}
|
||||||
|
|
||||||
// GET ALL
|
@POST
|
||||||
@GET
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Path("/"+InterfaceConstants.Methods.QUERY_PATH)
|
||||||
@Path("{"+InterfaceConstants.Parameters.PROFILE_ID+"}")
|
public Iterable<?> query(String queryString){
|
||||||
public List<Project> getAllinProfile(@PathParam(InterfaceConstants.Parameters.PROFILE_ID)String profileId) {
|
return new GuardedMethod<Iterable<?>>() {
|
||||||
return new GuardedMethod<List<Project>>() {
|
@Override
|
||||||
protected List<Project> run() throws Exception ,WebApplicationException {
|
protected Iterable<?> run() throws Exception, WebApplicationException {
|
||||||
return Collections.singletonList(new Project());
|
return manager.query(Serialization.parseQuery(queryString));
|
||||||
};
|
}
|
||||||
}.execute().getResult();
|
}.execute().getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//***************** BY PROFILE ID + PROJECT ID
|
|
||||||
// GET BY ID
|
|
||||||
@GET
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
@Path("{"+InterfaceConstants.Parameters.PROFILE_ID+"}/{"+InterfaceConstants.Parameters.PROJECT_ID+"}")
|
|
||||||
public Project getByID(@PathParam(InterfaceConstants.Parameters.PROFILE_ID) String profile,
|
|
||||||
@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id) {
|
|
||||||
Project toReturn=new GuardedMethod<Project>() {
|
|
||||||
@Override
|
|
||||||
protected Project run() throws Exception ,WebApplicationException{
|
|
||||||
return new Project();
|
|
||||||
}
|
|
||||||
}.execute().getResult();
|
|
||||||
return toReturn;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// DELETE BY ID
|
|
||||||
@DELETE
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
@Path("{"+InterfaceConstants.Parameters.PROFILE_ID+"}/{"+InterfaceConstants.Parameters.PROJECT_ID+"}")
|
|
||||||
public void delete(@PathParam(InterfaceConstants.Parameters.PROFILE_ID) String profile,
|
|
||||||
@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id) {
|
|
||||||
new GuardedMethod<Project>() {
|
|
||||||
@Override
|
|
||||||
protected Project run() throws Exception ,WebApplicationException{
|
|
||||||
// TODO DELETE
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.execute().getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PUT
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
@Path("{"+InterfaceConstants.Parameters.PROFILE_ID+"}/{"+InterfaceConstants.Parameters.PROJECT_ID+"}")
|
|
||||||
public Project updateDocument(@PathParam(InterfaceConstants.Parameters.PROFILE_ID) String profile,
|
|
||||||
@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id,Document toSetDocument) {
|
|
||||||
Project toReturn=new GuardedMethod<Project>() {
|
|
||||||
@Override
|
|
||||||
protected Project run() throws Exception ,WebApplicationException{
|
|
||||||
return new Project();
|
|
||||||
}
|
|
||||||
}.execute().getResult();
|
|
||||||
return toReturn;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,40 +33,6 @@ public class BasicServiceTestUnit extends JerseyTest {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
ImplementationProvider.get().setStorageProvider(new StorageClientProvider() {
|
|
||||||
@Override
|
|
||||||
public IClient getObject() throws ConfigurationException {
|
|
||||||
TokenSetter.set(scope);
|
|
||||||
return super.getObject();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
ImplementationProvider.get().setMongoConnectionProvider(new MongoConnectionProvider() {
|
|
||||||
@Override
|
|
||||||
public org.gcube.application.geoportal.service.model.internal.db.MongoConnection getObject() throws ConfigurationException {
|
|
||||||
TokenSetter.set(scope);
|
|
||||||
return super.getObject();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ImplementationProvider.get().setMongoClientProvider(new MongoClientProvider() {
|
|
||||||
@Override
|
|
||||||
public MongoClient getObject() throws ConfigurationException {
|
|
||||||
TokenSetter.set(scope);
|
|
||||||
return super.getObject();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ImplementationProvider.get().setDbProvider(new PostgisConnectionProvider() {
|
|
||||||
@Override
|
|
||||||
public PostgisDBManager getObject() throws ConfigurationException {
|
|
||||||
TokenSetter.set(scope);
|
|
||||||
return super.getObject();
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,75 +1,91 @@
|
||||||
package org.gcube.application.geoportal.service;
|
package org.gcube.application.geoportal.service;
|
||||||
|
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
|
import org.gcube.application.cms.tests.TokenSetter;
|
||||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import javax.ws.rs.client.Entity;
|
import javax.ws.rs.client.Entity;
|
||||||
import javax.ws.rs.client.WebTarget;
|
import javax.ws.rs.client.WebTarget;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class ProjectTests extends BasicServiceTestUnit{
|
public class ProjectTests extends BasicServiceTestUnit{
|
||||||
|
|
||||||
String testProfileId="profiled_concessione";
|
String testProfileId="profiled-concessioni";
|
||||||
String projectId="asdlkjgdasfjklgadjhkl";
|
|
||||||
|
@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
|
@Test
|
||||||
public void getAll() {
|
public void getAll() {
|
||||||
WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
System.out.println(target(InterfaceConstants.Methods.PROJECTS).path(testProfileId).request(MediaType.APPLICATION_JSON).get(List.class));
|
||||||
System.out.println(target.request(MediaType.APPLICATION_JSON).get(List.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
// @Test
|
||||||
public void getFilteredAll() {
|
// public void getFilteredAll() {
|
||||||
WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
// WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
||||||
Document document =new Document(Collections.singletonMap("key", "value"));
|
// Document document =new Document(Collections.singletonMap("key", "value"));
|
||||||
|
//
|
||||||
System.out.println(target.path("search").request(MediaType.APPLICATION_JSON).
|
// System.out.println(target.path("search").request(MediaType.APPLICATION_JSON).
|
||||||
post(Entity.entity(document, MediaType.APPLICATION_JSON)));
|
// post(Entity.entity(document, MediaType.APPLICATION_JSON)));
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void getAllByProfile() {
|
// public void getAllByProfile() {
|
||||||
WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
// WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
||||||
System.out.println(target.path(testProfileId).request(MediaType.APPLICATION_JSON).get(List.class));
|
// System.out.println(target.path(testProfileId).request(MediaType.APPLICATION_JSON).get(List.class));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void getFilteredByProfile() {
|
// public void getFilteredByProfile() {
|
||||||
WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
// WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
||||||
Document document =new Document(Collections.singletonMap("key", "value"));
|
// Document document =new Document(Collections.singletonMap("key", "value"));
|
||||||
|
//
|
||||||
System.out.println(target.path("search").path(testProfileId).request(MediaType.APPLICATION_JSON).
|
// System.out.println(target.path("search").path(testProfileId).request(MediaType.APPLICATION_JSON).
|
||||||
post(Entity.entity(document, MediaType.APPLICATION_JSON)));
|
// post(Entity.entity(document, MediaType.APPLICATION_JSON)));
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void getById() {
|
// public void getById() {
|
||||||
WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
// WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
||||||
System.out.println(target.path(testProfileId).path(projectId).request(MediaType.APPLICATION_JSON).get().readEntity(String.class));
|
// System.out.println(target.path(testProfileId).path(projectId).request(MediaType.APPLICATION_JSON).get().readEntity(String.class));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void registerNew() {
|
// public void registerNew() {
|
||||||
WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
// WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
||||||
Document document =new Document(Collections.singletonMap("key", "value"));
|
// Document document =new Document(Collections.singletonMap("key", "value"));
|
||||||
|
//
|
||||||
System.out.println(target.path(testProfileId).request(MediaType.APPLICATION_JSON).
|
// System.out.println(target.path(testProfileId).request(MediaType.APPLICATION_JSON).
|
||||||
put(Entity.entity(document, MediaType.APPLICATION_JSON)));
|
// put(Entity.entity(document, MediaType.APPLICATION_JSON)));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void updateDocument() {
|
// public void updateDocument() {
|
||||||
WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
// WebTarget target=target(InterfaceConstants.Methods.PROJECTS);
|
||||||
Document document =new Document(Collections.singletonMap("key", "value"));
|
// Document document =new Document(Collections.singletonMap("key", "value"));
|
||||||
|
//
|
||||||
System.out.println(target.path(testProfileId).path(projectId).request(MediaType.APPLICATION_JSON).
|
// System.out.println(target.path(testProfileId).path(projectId).request(MediaType.APPLICATION_JSON).
|
||||||
put(Entity.entity(document, MediaType.APPLICATION_JSON)));
|
// put(Entity.entity(document, MediaType.APPLICATION_JSON)));
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue