Commit e6b283a1 authored by Noel Alonso's avatar Noel Alonso
Browse files

Adapta test para enviar solo id de las relaciones

parent 8dfc23ae
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -32,6 +32,9 @@ import org.joda.time.DateTime;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Polygon;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import es.redmic.atlaslib.dto.layer.ActivityDTO;
import es.redmic.atlaslib.dto.layer.AttributionDTO;
import es.redmic.atlaslib.dto.layer.ContactDTO;
@@ -286,6 +289,21 @@ public abstract class LayerDataUtil {
		return layerInfo;
	}

	public static String getLayerInfoToSave(LayerInfoDTO layerInfoDTO) throws JsonProcessingException {

		ObjectMapper mapper = new ObjectMapper();

		String layerInfoString = mapper.writeValueAsString(layerInfoDTO);

		layerInfoString = layerInfoString.replace(mapper.writeValueAsString(ThemeInspireDataUtil.getThemeInspire("cc")),
				"\"" + ThemeInspireDataUtil.getThemeInspire("cc").getId() + "\"");

		layerInfoString = layerInfoString.replace(mapper.writeValueAsString(CategoryDataUtil.getCategory("3442")),
				"\"" + CategoryDataUtil.getCategory("3442").getId() + "\"");

		return layerInfoString;
	}

	public static LayerDTO getLayer(String code) {

		LayerDTO layer = new LayerDTO();
+2 −2
Original line number Diff line number Diff line
@@ -170,7 +170,7 @@ public class LayerRestTest extends DocumentationCommandBaseTest {
		this.mockMvc
				.perform(post(CATEGORY_PATH)
						.header("Authorization", "Bearer " + getTokenOAGUser())
						.content(mapper.writeValueAsString(layerInfoDTO))
						.content(LayerDataUtil.getLayerInfoToSave(layerInfoDTO))
						.contentType(MediaType.APPLICATION_JSON)
						.accept(MediaType.APPLICATION_JSON))
				.andExpect(status().isOk())
@@ -209,7 +209,7 @@ public class LayerRestTest extends DocumentationCommandBaseTest {
		this.mockMvc
				.perform(put(CATEGORY_PATH + "/" + id)
						.header("Authorization", "Bearer " + getTokenOAGUser())
						.content(mapper.writeValueAsString(layerInfoDTO))
						.content(LayerDataUtil.getLayerInfoToSave(layerInfoDTO))
						.contentType(MediaType.APPLICATION_JSON)
						.accept(MediaType.APPLICATION_JSON))
				.andExpect(status().isOk())