Loading src/main/java/es/redmic/exception/common/ExceptionType.java +2 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ public enum ExceptionType implements ExceptionTypeItfc { INTERNAL_EXCEPTION(Constants.INTERNAL_EXCEPTION), RESOURCE_NOT_FOUND(Constants.RESOURCE_NOT_FOUND), URL_EXCEPTION(Constants.URL_EXCEPTION), // Data DT_INCCORRECT_INTERVAL(Constants.DT_INCCORRECT_INTERVAL), Loading Loading @@ -241,6 +242,7 @@ public enum ExceptionType implements ExceptionTypeItfc { INTERNAL_EXCEPTION = "InternalException", RESOURCE_NOT_FOUND = "ResourceNotFound", URL_EXCEPTION = "URLException", // Data DT_INCCORRECT_INTERVAL = "IncorrectInterval", Loading src/main/java/es/redmic/exception/custom/URLException.java 0 → 100644 +43 −0 Original line number Diff line number Diff line package es.redmic.exception.custom; /*- * #%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.ExceptionType; import es.redmic.exception.common.NotFoundException; public class URLException extends NotFoundException { private static final long serialVersionUID = 6714485190161856195L; public URLException(Exception e, String url) { super(ExceptionType.URL_EXCEPTION, e); setFieldErrors(Arrays.asList(url)); } public URLException(String url) { super(ExceptionType.URL_EXCEPTION); setFieldErrors(Arrays.asList(url)); } } src/main/resources/i18n/messages_en_EN.properties +1 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ InvalidAphia=Trying to update a taxon with aphia {0}. Ahpia does not exist in wo #Common exception messages InternalException=An error occurred while processing the request. ResourceNotFound=The resource you are trying to access does not exist or is not available. URLException=URL {0} is not valid. #Database exception messages DBConstraintViolation=Error, data constraint violation. {0} Loading src/main/resources/i18n/messages_es_ES.properties +1 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ InvalidAphia=Intentando actualizar un tax #Common exception messages InternalException=Se ha producido un error al procesar la petición. Inténtelo más tarde. ResourceNotFound=El recurso al que está intentando acceder no existe o no está disponible. URLException=URL {0} no es válida #Database exception messages DBConstraintViolation=Error, violación de una reestricción de los datos. {0} Loading src/test/java/es/redmic/test/unit/exception/custom/URLExceptionTest.java 0 → 100644 +48 −0 Original line number Diff line number Diff line package es.redmic.test.unit.exception.custom; /*- * #%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.custom.URLException; import es.redmic.test.unit.exception.common.BaseExceptionTest; public class URLExceptionTest extends BaseExceptionTest { String url = "ht://www.marinespecies.org/rest/AphiaClassificationByAphiaID/3"; @Test public void checkPattern_IsEqualToMessage_WhenNoLocaleSet() throws IOException { checkMessage(new URLException(url), ExceptionType.URL_EXCEPTION.toString(), Arrays.asList(url)); } @Test public void checkPattern_IsEqualToMessage_WhenNoLocaleSetAndSendException() throws IOException { checkMessage(new URLException(new Exception(), url), ExceptionType.URL_EXCEPTION.toString(), Arrays.asList(url)); } } Loading
src/main/java/es/redmic/exception/common/ExceptionType.java +2 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ public enum ExceptionType implements ExceptionTypeItfc { INTERNAL_EXCEPTION(Constants.INTERNAL_EXCEPTION), RESOURCE_NOT_FOUND(Constants.RESOURCE_NOT_FOUND), URL_EXCEPTION(Constants.URL_EXCEPTION), // Data DT_INCCORRECT_INTERVAL(Constants.DT_INCCORRECT_INTERVAL), Loading Loading @@ -241,6 +242,7 @@ public enum ExceptionType implements ExceptionTypeItfc { INTERNAL_EXCEPTION = "InternalException", RESOURCE_NOT_FOUND = "ResourceNotFound", URL_EXCEPTION = "URLException", // Data DT_INCCORRECT_INTERVAL = "IncorrectInterval", Loading
src/main/java/es/redmic/exception/custom/URLException.java 0 → 100644 +43 −0 Original line number Diff line number Diff line package es.redmic.exception.custom; /*- * #%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.ExceptionType; import es.redmic.exception.common.NotFoundException; public class URLException extends NotFoundException { private static final long serialVersionUID = 6714485190161856195L; public URLException(Exception e, String url) { super(ExceptionType.URL_EXCEPTION, e); setFieldErrors(Arrays.asList(url)); } public URLException(String url) { super(ExceptionType.URL_EXCEPTION); setFieldErrors(Arrays.asList(url)); } }
src/main/resources/i18n/messages_en_EN.properties +1 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ InvalidAphia=Trying to update a taxon with aphia {0}. Ahpia does not exist in wo #Common exception messages InternalException=An error occurred while processing the request. ResourceNotFound=The resource you are trying to access does not exist or is not available. URLException=URL {0} is not valid. #Database exception messages DBConstraintViolation=Error, data constraint violation. {0} Loading
src/main/resources/i18n/messages_es_ES.properties +1 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ InvalidAphia=Intentando actualizar un tax #Common exception messages InternalException=Se ha producido un error al procesar la petición. Inténtelo más tarde. ResourceNotFound=El recurso al que está intentando acceder no existe o no está disponible. URLException=URL {0} no es válida #Database exception messages DBConstraintViolation=Error, violación de una reestricción de los datos. {0} Loading
src/test/java/es/redmic/test/unit/exception/custom/URLExceptionTest.java 0 → 100644 +48 −0 Original line number Diff line number Diff line package es.redmic.test.unit.exception.custom; /*- * #%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.custom.URLException; import es.redmic.test.unit.exception.common.BaseExceptionTest; public class URLExceptionTest extends BaseExceptionTest { String url = "ht://www.marinespecies.org/rest/AphiaClassificationByAphiaID/3"; @Test public void checkPattern_IsEqualToMessage_WhenNoLocaleSet() throws IOException { checkMessage(new URLException(url), ExceptionType.URL_EXCEPTION.toString(), Arrays.asList(url)); } @Test public void checkPattern_IsEqualToMessage_WhenNoLocaleSetAndSendException() throws IOException { checkMessage(new URLException(new Exception(), url), ExceptionType.URL_EXCEPTION.toString(), Arrays.asList(url)); } }