2016-10-09 16:06:45 +02:00
|
|
|
package org.gcube.data_catalogue.grsf_publish_ws;
|
|
|
|
|
2016-10-13 11:46:42 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2016-10-09 16:06:45 +02:00
|
|
|
import javax.ws.rs.client.Entity;
|
|
|
|
import javax.ws.rs.core.Application;
|
|
|
|
import javax.ws.rs.core.MediaType;
|
|
|
|
import javax.ws.rs.core.Response;
|
|
|
|
|
2016-10-13 11:46:42 +02:00
|
|
|
import org.gcube.data_catalogue.grsf_publish_ws.json.input.DatabaseSource;
|
2016-10-09 16:06:45 +02:00
|
|
|
import org.gcube.data_catalogue.grsf_publish_ws.json.input.FisheryRecord;
|
2016-10-13 11:46:42 +02:00
|
|
|
import org.gcube.data_catalogue.grsf_publish_ws.json.input.Resource;
|
2016-10-09 16:06:45 +02:00
|
|
|
import org.gcube.data_catalogue.grsf_publish_ws.json.input.StockRecord;
|
|
|
|
import org.gcube.data_catalogue.grsf_publish_ws.services.GrsfPublisherFisheryService;
|
|
|
|
import org.gcube.data_catalogue.grsf_publish_ws.services.GrsfPublisherStockService;
|
|
|
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Status;
|
|
|
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Type;
|
|
|
|
import org.glassfish.jersey.server.ResourceConfig;
|
|
|
|
import org.glassfish.jersey.test.JerseyTest;
|
2016-10-11 11:39:25 +02:00
|
|
|
import org.glassfish.jersey.test.TestProperties;
|
2016-10-09 16:06:45 +02:00
|
|
|
|
|
|
|
public class JJerseyTest extends JerseyTest{
|
|
|
|
|
|
|
|
//@Override
|
|
|
|
protected Application configure() {
|
2016-10-11 11:39:25 +02:00
|
|
|
forceSet(TestProperties.CONTAINER_PORT, "0");
|
2016-10-09 16:06:45 +02:00
|
|
|
return new ResourceConfig(GrsfPublisherFisheryService.class, GrsfPublisherStockService.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
//@Test
|
|
|
|
public void testFishery() {
|
|
|
|
FisheryRecord recordFishery = new FisheryRecord();
|
|
|
|
recordFishery.setAuthor("Costantino Perciante");
|
|
|
|
recordFishery.setAuthorContact("costantino.perciante@isti.cnr.it");
|
2016-10-13 11:46:42 +02:00
|
|
|
recordFishery.setLicense("a caso una lincense");
|
|
|
|
recordFishery.setDataOwner("data owner");
|
2016-10-09 16:06:45 +02:00
|
|
|
recordFishery.setType(Type.Fishing_Description);
|
2016-10-13 11:46:42 +02:00
|
|
|
recordFishery.setDatabaseSources(new ArrayList<DatabaseSource>(1));
|
|
|
|
recordFishery.setSourceOfInformation(new ArrayList<Resource>(1));
|
2016-10-09 16:06:45 +02:00
|
|
|
recordFishery.setStatus(Status.Pending);
|
|
|
|
Response res = target("fishery").path("/publish-product").request().post(Entity.entity(recordFishery, MediaType.APPLICATION_JSON));
|
|
|
|
System.out.println("Result is " + res.readEntity(String.class));
|
|
|
|
}
|
|
|
|
|
|
|
|
//@Test
|
|
|
|
public void testStock() {
|
|
|
|
StockRecord stock = new StockRecord();
|
|
|
|
stock.setAuthor("Costantino Perciante");
|
|
|
|
stock.setAuthorContact("costantino.perciante@isti.cnr.it");
|
|
|
|
stock.setType(Type.Fishing_Description);
|
2016-10-13 11:46:42 +02:00
|
|
|
stock.setDatabaseSources(null);
|
2016-10-09 16:06:45 +02:00
|
|
|
stock.setStatus(Status.Pending);
|
|
|
|
|
|
|
|
Response res = target("stock").path("/publish-product").request().post(Entity.entity(stock, MediaType.APPLICATION_JSON));
|
|
|
|
|
|
|
|
System.out.println("Result is " + res);
|
|
|
|
}
|
2016-10-11 11:39:25 +02:00
|
|
|
|
|
|
|
//@Test
|
|
|
|
public void getLicenses(){
|
|
|
|
|
|
|
|
Response res = target("fishery").path("/get-licenses").request().get();
|
|
|
|
System.out.println("Result is " + res);
|
|
|
|
|
|
|
|
}
|
2016-10-09 16:06:45 +02:00
|
|
|
}
|