Commit 075cac8f authored by Noel Alonso's avatar Noel Alonso
Browse files

Añade cita para obtener resultado en búsqueda

parent 575f7928
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
package es.redmic.test.integration.common;

import java.io.IOException;
import java.io.InputStream;

/*-
 * #%L
 * API
@@ -23,6 +26,10 @@ package es.redmic.test.integration.common;
import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import org.junit.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -45,6 +52,9 @@ public abstract class IntegrationTestBase {
	@Autowired
	protected FilterChainProxy springSecurityFilterChain;

	@Autowired
	protected ObjectMapper mapper;

	protected MockMvc mockMvc;

	HttpClient client = new HttpClient();
@@ -116,4 +126,10 @@ public abstract class IntegrationTestBase {

		return result.get("access_token");
	}

	protected Object getModelToResource(String resourcePath, Class<?> resultClass) throws JsonParseException, JsonMappingException, IOException {

		InputStream resource = getClass().getResourceAsStream(resourcePath);
		return mapper.readValue(resource, resultClass);
	}
}
+11 −6
Original line number Diff line number Diff line
@@ -31,8 +31,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.

import java.util.HashMap;

import com.fasterxml.jackson.databind.ObjectMapper;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -48,7 +46,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;

import es.redmic.ApiApplication;
import es.redmic.es.geodata.citation.repository.CitationESRepository;
import es.redmic.models.es.common.query.dto.GeoDataQueryDTO;
import es.redmic.models.es.geojson.common.model.GeoPointData;
import es.redmic.test.integration.ApiApplicationTest;
import es.redmic.test.integration.common.IntegrationTestBase;

@@ -58,15 +58,17 @@ import es.redmic.test.integration.common.IntegrationTestBase;
@ActiveProfiles("test")
public class CitationControllerTest extends IntegrationTestBase {

	private static final String RESOURCE_PATH = "/geo/models/citation.json";

	@Rule
	public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation("target/generated-snippets");

	@Autowired
	ObjectMapper mapper;

	private RestDocumentationResultHandler document;

	private final String CITATIONS_BY_ACTIVITY_URL_BASE = "/activities/30/citations";
	@Autowired
	CitationESRepository repository;

	private final String CITATIONS_BY_ACTIVITY_URL_BASE = "/activities/1167/citations";

	@Override
	@Before
@@ -99,6 +101,9 @@ public class CitationControllerTest extends IntegrationTestBase {
	@Test
	public void searchCitationByActivity_Return200_WhenSearchIsCorrect() throws Exception {

		GeoPointData modelToIndex = (GeoPointData) getModelToResource(RESOURCE_PATH, GeoPointData.class);
		repository.save(modelToIndex);

		GeoDataQueryDTO geodataQuery = new GeoDataQueryDTO();
		geodataQuery.setSize(1);

+77 −0
Original line number Diff line number Diff line
{
	"geometry": {
		"coordinates": [
			-15.354766845703125,
			27.969818115234375
		],
		"type": "Point"
	},
	"id": 14529,
	"type": "Feature",
	"uuid": "9e122efc-a020-4293-8406-ccbfa09710ba",
	"properties": {
		"geodataRelations": null,
		"area": null,
		"length": null,
		"media": null,
		"weatherConditions": null,
		"samplingPlace": null,
		"activityId": "1167",
		"site": null,
		"inserted": "2017-03-15T08:15:38.742+00:00",
		"updated": "2018-10-09T08:44:47.573+00:00",
		"collect": {
			"collectionRegNo": null,
			"distance": null,
			"endDate": "2009-05-01T23:59:59.000+00:00",
			"remark": "Telde. Entre mayo y octubre de 2009\n",
			"analytics": null,
			"dataDefinition": null,
			"taxon": {
				"path": "root.1.13.148.19923.455.1726.4099.11887",
				"commonName": "Boga",
				"leaves": 0,
				"scientificName": "Boops boops",
				"authorship": "(Linnaeus, 1758)",
				"validAs": null,
				"rank": {
					"name": "Species",
					"id": 10,
					"name_en": "Species"
				},
				"aphia": 127047,
				"id": 11887
			},
			"molecular": null,
			"id": "ci-14529",
			"radius": 6000.0,
			"value": 41.0,
			"collectorName": null,
			"observationAngle": null,
			"vFlag": "A",
			"qFlag": "1",
			"confidence": {
				"name": "Fiable",
				"id": 4,
				"name_en": "Trustworthy"
			},
			"localityConfidence": {
				"name": "Fiable",
				"id": 4,
				"name_en": "Trustworthy"
			},
			"deviation": 15.5,
			"sample": null,
			"misidentification": null,
			"elements": null,
			"animal": null,
			"z": -35.5,
			"attributes": null,
			"metrics": null,
			"startDate": "2009-05-01T00:00:00.000+00:00",
			"object": null
		},
		"inTrack": null,
		"measurements": null
	}
}