54 lines
2.2 KiB
Java
54 lines
2.2 KiB
Java
package org.gcube.data_catalogue.grsf_publish_ws;
|
|
|
|
import javax.ws.rs.client.Entity;
|
|
import javax.ws.rs.core.Application;
|
|
import javax.ws.rs.core.MediaType;
|
|
import javax.ws.rs.core.Response;
|
|
|
|
import org.gcube.data_catalogue.grsf_publish_ws.json.input.FisheryRecord;
|
|
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.Source;
|
|
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;
|
|
|
|
public class JJerseyTest extends JerseyTest{
|
|
|
|
//@Override
|
|
protected Application configure() {
|
|
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");
|
|
recordFishery.setType(Type.Fishing_Description);
|
|
recordFishery.setDatabaseSources(Source.FIRMS);
|
|
recordFishery.setStatus(Status.Pending);
|
|
recordFishery.setSpatial(
|
|
"{\"type\":\"Polygon\",\"coordinates\":[[[2.05827, 49.8625],[2.05827, 55.7447], [-6.41736, 55.7447], [-6.41736, 49.8625], [2.05827, 49.8625]]]}");
|
|
|
|
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);
|
|
stock.setDatabaseSources(Source.FIRMS);
|
|
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);
|
|
}
|
|
}
|