Commit 29cc5080 authored by Noel Alonso's avatar Noel Alonso
Browse files

Añade excepción borrado de elementos referenciados

parent ec25e128
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ public enum ExceptionType implements ExceptionTypeItfc {
	ES_INSERT_DOCUMENT(Constants.ES_INSERT_DOCUMENT),
	ES_CREATE_MAPPING_ERROR(Constants.ES_CREATE_MAPPING_ERROR),
	ES_DELETE_ITEM_WITH_CHILDREN_ERROR(Constants.ES_DELETE_ITEM_WITH_CHILDREN_ERROR),
	ES_DELETE_ITEM_REFERENCED_ERROR(Constants.ES_DELETE_ITEM_REFERENCED_ERROR),
	ES_PARENT_NOT_EXIST_ERROR(Constants.ES_PARENT_NOT_EXIST_ERROR),
	
	// DTOs
@@ -224,6 +225,7 @@ public enum ExceptionType implements ExceptionTypeItfc {
			ES_INSERT_DOCUMENT = "ESInsertError",
			ES_CREATE_MAPPING_ERROR = "ESCreateMappingError",
			ES_DELETE_ITEM_WITH_CHILDREN_ERROR = "ESDeleteItemWithChildrenError",
			ES_DELETE_ITEM_REFERENCED_ERROR="ESDeleteItemReferencedError",
			ES_PARENT_NOT_EXIST_ERROR = "ESParentNotExistError",
			
			// DTOs
+37 −0
Original line number Diff line number Diff line
package es.redmic.exception.elasticsearch;

/*-
 * #%L
 * Exceptions
 * %%
 * Copyright (C) 2019 REDMIC Project / Server
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import java.util.Arrays;

import es.redmic.exception.common.BadRequestException;
import es.redmic.exception.common.ExceptionType;

public class ESDeleteItemReferencedException extends BadRequestException {

	private static final long serialVersionUID = 1L;

	public ESDeleteItemReferencedException(String field, String value) {

		super(ExceptionType.ES_DELETE_ITEM_REFERENCED_ERROR);
		setFieldErrors(Arrays.asList(field, value));
	}
}
+1 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ ESQueryError=Error. Query is erroneous.
ESInsertError=Error. Register with field {0} and value {1} already exists.
ESCreateMappingError=Error. Mapping for index {0} could not be created.
ESDeleteItemWithChildrenError=Error. Unable to delete the item with field {0} with value {1}. Has children and it is not possible to remove it.
ESDeleteItemReferencedError=Error. Unable to delete the item with field {0} with value {1}. Item is referenced in another service and cannot be deleted.
ESParentNotExistError=Error. Trying to associate an item with a father with id {0} who does not exist.

#Layer
+1 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ ESQueryError=Error. La consulta realizada es erronea.
ESInsertError=Error. El registro con campo {0} y valor {1} ya existe.
ESCreateMappingError=Error. El mapping para el índice {0} no se ha podido crear.
ESDeleteItemWithChildrenError=Error. No se ha podido eliminar el item con campo {0} y valor {1}. Tiene hijo/s asociado/s y no es posible borrarlo.
ESDeleteItemReferencedError=Error. No se ha podido eliminar el item con campo {0} y valor {1}. Está referenciado en otro servicio no es posible borrarlo.
ESParentNotExistError=Error. Tratando de asociar un item a un padre con id {0} que no existe.

#Layer
+47 −0
Original line number Diff line number Diff line
package es.redmic.test.unit.exception.elasticsearch;

/*-
 * #%L
 * Exceptions
 * %%
 * Copyright (C) 2019 REDMIC Project / Server
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import java.io.IOException;
import java.util.Arrays;

import org.junit.Test;

import es.redmic.exception.common.ExceptionType;
import es.redmic.exception.elasticsearch.ESDeleteItemReferencedException;
import es.redmic.test.unit.exception.common.BaseExceptionTest;

public class ESDeleteItemReferencedExceptionTest extends BaseExceptionTest {

	@Test
	public void checkPattern_IsEqualToMessage_WhenNoLocaleSet() throws IOException {

		// @formatter:off

		String field = "id",
				value = "category-1234";
		
		// @formatter:on

		checkMessage(new ESDeleteItemReferencedException(field, value),
				ExceptionType.ES_DELETE_ITEM_REFERENCED_ERROR.toString(), Arrays.asList(field, value));
	}
}