Commit 6e554f32 authored by Noel Alonso's avatar Noel Alonso
Browse files

Convierte parent en notnull + cambia tests

parent d1c5e1ca
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -268,6 +268,8 @@ public abstract class LayerDataUtil {
		contact.setName("Pepe");
		layer.setContact(contact);

		layer.setParent(CategoryDataUtil.getCategory("3442"));

		layer.setThemeInspire(ThemeInspireDataUtil.getThemeInspire("cc"));

		layer.setProtocols(getProtocols());
+2 −2
Original line number Diff line number Diff line
@@ -47,11 +47,11 @@
			"type": "string"
		},
		"parent": {
			"type": ["integer", "null"],
			"type": "integer",
			"url": "/api/atlas/commands/category"
		}
	},
	"required": ["name", "protocols", "atlas", "refresh", "urlSource"],
	"required": ["name", "protocols", "atlas", "refresh", "urlSource", "parent"],
	"definitions": {
		"LatLonBoundingBoxDTO": {
			"type": ["object", "null"],
+2 −2
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ public class LayerDTO extends LayerInfoDTO {
				+ "\"default\": null},"
			+ "{\"name\":\"updated\",\"type\":[\"null\",{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}],"
				+ "\"default\": null},"
			+ "{\"name\":\"parent\",\"type\":[" + CategoryDTO.SCHEMA$ + ",\"null\"]},"
			+ "{\"name\":\"parent\",\"type\":" + CategoryDTO.SCHEMA$ + "},"
			+ "{\"name\":\"themeInspire\",\"type\":["+ ThemeInspireDTO.SCHEMA$ +", \"null\"]},"
			+ "{\"name\":\"latLonBoundsImage\",\"type\":[" + LatLonBoundingBoxDTO.SCHEMA$ + ", \"null\"]},"
			+ "{\"name\": \"protocols\",\"type\": [{\"type\": \"array\",\"items\":" + ProtocolDTO.SCHEMA$ + "},\"null\"]},"
@@ -429,7 +429,7 @@ public class LayerDTO extends LayerInfoDTO {
			setUpdated(value != null ? new DateTime(value, DateTimeZone.UTC).toDateTime() : null);
			break;
		case 17:
			setParent(value != null ? (CategoryDTO) value : null);
			setParent((CategoryDTO) value);
			break;
		case 18:
			setThemeInspire(value != null ? (ThemeInspireDTO) value : null);
+4 −2
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ package es.redmic.atlaslib.dto.layerinfo;
 */

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import org.apache.avro.Schema;

@@ -49,7 +50,7 @@ public class LayerInfoDTO extends LayerCompactDTO {
	@JsonIgnore
	public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse(
		"{\"type\":\"record\",\"name\":\"LayerDTO\",\"namespace\":\"es.redmic.atlaslib.dto.layerinfo\",\"fields\":["
			+ "{\"name\":\"parent\",\"type\":[" + CategoryDTO.SCHEMA$ + ",\"null\"]},"
			+ "{\"name\":\"parent\",\"type\":" + CategoryDTO.SCHEMA$ + "},"
			+ "{\"name\":\"themeInspire\",\"type\":["+ ThemeInspireDTO.SCHEMA$ +", \"null\"]},"
			+ "{\"name\":\"latLonBoundsImage\",\"type\":[" + LatLonBoundingBoxDTO.SCHEMA$ + ", \"null\"]},"
			+ "{\"name\": \"protocols\",\"type\": [{\"type\": \"array\",\"items\":" + ProtocolDTO.SCHEMA$ + "},\"null\"]},"
@@ -66,6 +67,7 @@ public class LayerInfoDTO extends LayerCompactDTO {
		super();
	}

	@NotNull
	@JsonDeserialize(using = CustomRelationDeserializer.class)
	@JsonSchemaUrl(value = "controller.mapping.CATEGORY")
	@Valid
@@ -122,7 +124,7 @@ public class LayerInfoDTO extends LayerCompactDTO {
	public void put(int field, Object value) {
		switch (field) {
		case 0:
			setParent(value != null ? (CategoryDTO) value : null);
			setParent((CategoryDTO) value);
			break;
		case 1:
			setThemeInspire(value != null ? (ThemeInspireDTO) value : null);
+8 −0
Original line number Diff line number Diff line
@@ -127,4 +127,12 @@ public class LayerInfoCheckDTOValidationTest extends DTOBaseTest<LayerInfoDTO> {

		checkDTOHasError(dto, NOT_NULL_MESSAGE_TEMPLATE);
	}

	@Test
	public void validationDTO_ReturnNotNullError_IfParentFieldIsNull() {

		dto.setParent(null);

		checkDTOHasError(dto, NOT_NULL_MESSAGE_TEMPLATE);
	}
}