You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2018/02/25 19:19:14 UTC
[isis] branch master updated: ISIS-1827 remove guava from
ExceptionRecognizer implementation
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new ed9d958 ISIS-1827 remove guava from ExceptionRecognizer implementation
ed9d958 is described below
commit ed9d95848839dc9fc3cc1a856e8c3e8a939efb6b
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sun Feb 25 20:19:13 2018 +0100
ISIS-1827 remove guava from ExceptionRecognizer implementation
provide legacy variants to ease transition from 1.x to 2.0:
* ExceptionRecognizerAbstractLegacy
* ExceptionRecognizerForTypeLegacy
---
.../exceprecog/ExceptionRecognizerAbstract.java | 33 ----------
...java => ExceptionRecognizerAbstractLegacy.java} | 43 ++++---------
.../exceprecog/ExceptionRecognizerComposite.java | 3 +-
.../exceprecog/ExceptionRecognizerForType.java | 58 ++++++++---------
....java => ExceptionRecognizerForTypeLegacy.java} | 68 ++++++++++----------
...xceptionRecognizerForJDODataStoreException.java | 4 +-
...traintViolationForeignKeyNoActionException.java | 4 +-
...ionRecognizerForJDOObjectNotFoundException.java | 4 +-
...yConstraintViolationUniqueOrIndexException.java | 4 +-
.../repository/RepositoryServiceLegacy.java | 4 +-
.../ExceptionRecognizerForType2Test.java | 73 ----------------------
.../exceprecog/ExceptionRecognizerForTypeTest.java | 36 ++++++++++-
.../exceprecog/ExceptionRecognizerGeneralTest.java | 8 +--
13 files changed, 125 insertions(+), 217 deletions(-)
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerAbstract.java b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerAbstract.java
index f586624..4965b49 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerAbstract.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerAbstract.java
@@ -117,39 +117,6 @@ public abstract class ExceptionRecognizerAbstract implements ExceptionRecognizer
this(Category.OTHER, predicate);
}
- // -- GUAVA LEGACY
-
- @Deprecated //TODO ISIS-1827 remove guava from public API
- public ExceptionRecognizerAbstract(final Category category,
- com.google.common.base.Predicate<Throwable> predicate,
- final com.google.common.base.Function<String,String> messageParser) {
- Objects.requireNonNull(predicate);
- this.category = category;
- this.predicate = predicate::apply;
- this.messageParser = messageParser != null ? messageParser::apply : Function.identity();
- }
-
- @Deprecated //TODO ISIS-1827 remove guava from public API
- public ExceptionRecognizerAbstract(
- com.google.common.base.Predicate<Throwable> predicate,
- final com.google.common.base.Function<String,String> messageParser) {
- this(Category.OTHER, predicate, messageParser);
- }
-
- @Deprecated //TODO ISIS-1827 remove guava from public API
- public ExceptionRecognizerAbstract(Category category, com.google.common.base.Predicate<Throwable> predicate) {
- this(category, predicate, null);
- }
-
- @Deprecated //TODO ISIS-1827 remove guava from public API
- public ExceptionRecognizerAbstract(com.google.common.base.Predicate<Throwable> predicate) {
- this(Category.OTHER, predicate);
- }
-
- // --
-
-
-
@PostConstruct
public void init(Map<String, String> properties) {
final String prop = properties.get(KEY_LOG_RECOGNIZED_EXCEPTIONS);
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerAbstract.java b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerAbstractLegacy.java
similarity index 79%
copy from core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerAbstract.java
copy to core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerAbstractLegacy.java
index f586624..f39e942 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerAbstract.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerAbstractLegacy.java
@@ -44,10 +44,15 @@ import com.google.common.base.Throwables;
* <p>
* If a messaging-parsing {@link Function} is provided through the constructor,
* then the message can be altered. Otherwise the exception's {@link Throwable#getMessage() message} is returned as-is.
+ *
+ * @deprecated use {@link ExceptionRecognizerAbstract} instead. (Will not be removed before Version 2.1.)
+ * (Requires you to refactor Guava Predicates, Functions, ... to Java Predicates, Functions, ... in your domain code.)
+ *
*/
-public abstract class ExceptionRecognizerAbstract implements ExceptionRecognizer {
+@Deprecated // (Will not be removed before Version 2.1.)
+public abstract class ExceptionRecognizerAbstractLegacy implements ExceptionRecognizer {
- public static final Logger LOG = LoggerFactory.getLogger(ExceptionRecognizerAbstract.class);
+ public static final Logger LOG = LoggerFactory.getLogger(ExceptionRecognizerAbstractLegacy.class);
/**
* Normally recognized exceptions are not logged (because they are expected and handled).
@@ -95,32 +100,11 @@ public abstract class ExceptionRecognizerAbstract implements ExceptionRecognizer
private boolean logRecognizedExceptions;
// //////////////////////////////////////
-
- // -- JAVA 8+
-
- public ExceptionRecognizerAbstract(final Category category, Predicate<Throwable> predicate, final Function<String,String> messageParser) {
- Objects.requireNonNull(predicate);
- this.category = category;
- this.predicate = predicate;
- this.messageParser = messageParser != null ? messageParser : Function.identity();
- }
-
- public ExceptionRecognizerAbstract(Predicate<Throwable> predicate, final Function<String,String> messageParser) {
- this(Category.OTHER, predicate, messageParser);
- }
-
- public ExceptionRecognizerAbstract(Category category, Predicate<Throwable> predicate) {
- this(category, predicate, null);
- }
- public ExceptionRecognizerAbstract(Predicate<Throwable> predicate) {
- this(Category.OTHER, predicate);
- }
// -- GUAVA LEGACY
- @Deprecated //TODO ISIS-1827 remove guava from public API
- public ExceptionRecognizerAbstract(final Category category,
+ public ExceptionRecognizerAbstractLegacy(final Category category,
com.google.common.base.Predicate<Throwable> predicate,
final com.google.common.base.Function<String,String> messageParser) {
Objects.requireNonNull(predicate);
@@ -129,27 +113,22 @@ public abstract class ExceptionRecognizerAbstract implements ExceptionRecognizer
this.messageParser = messageParser != null ? messageParser::apply : Function.identity();
}
- @Deprecated //TODO ISIS-1827 remove guava from public API
- public ExceptionRecognizerAbstract(
+ public ExceptionRecognizerAbstractLegacy(
com.google.common.base.Predicate<Throwable> predicate,
final com.google.common.base.Function<String,String> messageParser) {
this(Category.OTHER, predicate, messageParser);
}
- @Deprecated //TODO ISIS-1827 remove guava from public API
- public ExceptionRecognizerAbstract(Category category, com.google.common.base.Predicate<Throwable> predicate) {
+ public ExceptionRecognizerAbstractLegacy(Category category, com.google.common.base.Predicate<Throwable> predicate) {
this(category, predicate, null);
}
- @Deprecated //TODO ISIS-1827 remove guava from public API
- public ExceptionRecognizerAbstract(com.google.common.base.Predicate<Throwable> predicate) {
+ public ExceptionRecognizerAbstractLegacy(com.google.common.base.Predicate<Throwable> predicate) {
this(Category.OTHER, predicate);
}
// --
-
-
@PostConstruct
public void init(Map<String, String> properties) {
final String prop = properties.get(KEY_LOG_RECOGNIZED_EXCEPTIONS);
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerComposite.java b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerComposite.java
index 3484d4c..3d4b4db 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerComposite.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerComposite.java
@@ -89,7 +89,8 @@ public class ExceptionRecognizerComposite implements ExceptionRecognizer {
/**
- * Returns the non-<tt>null</tt> recognition of the first {@link #add(ExceptionRecognizer) add}ed {@link org.apache.isis.applib.services.exceprecog.ExceptionRecognizer}.
+ * Returns the non-<tt>null</tt> recognition of the first {@link #add(ExceptionRecognizer) add}ed
+ * {@link org.apache.isis.applib.services.exceprecog.ExceptionRecognizer}.
*
* <p>
* If none recognize the exception, then falls back to using {@link #recognize(Throwable)}, returning a
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerForType.java b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerForType.java
index ff3653c..2537a55 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerForType.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerForType.java
@@ -19,10 +19,11 @@
package org.apache.isis.applib.services.exceprecog;
import java.util.List;
+import java.util.function.Function;
+import java.util.function.Predicate;
+
import javax.jdo.JDODataStoreException;
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
+
import com.google.common.base.Throwables;
/**
@@ -35,24 +36,18 @@ import com.google.common.base.Throwables;
* If a messaging-parsing {@link Function} is provided through the constructor,
* then the message can be altered. Otherwise the exception's {@link Throwable#getMessage() message} is returned as-is.
*/
-@Deprecated //TODO ISIS-1827 remove guava from public API
public class ExceptionRecognizerForType extends ExceptionRecognizerAbstract {
-
- protected final static Predicate<Throwable> ofTypeExcluding(final Class<? extends Throwable> exceptionType, final String... messages) {
- return Predicates.and(ofType(exceptionType), excluding(messages));
+
+ protected final static Predicate<Throwable> ofTypeExcluding(final Class<? extends Throwable> exceptionType, final String... messages) {
+ return ofType(exceptionType).and(excluding(messages));
}
protected final static Predicate<Throwable> ofTypeIncluding(final Class<? extends Throwable> exceptionType, final String... messages) {
- return Predicates.and(ofType(exceptionType), including(messages));
+ return ofType(exceptionType).and(including(messages));
}
protected final static Predicate<Throwable> ofType(final Class<? extends Throwable> exceptionType) {
- return new Predicate<Throwable>() {
- @Override
- public boolean apply(Throwable input) {
- return exceptionType.isAssignableFrom(input.getClass());
- }
- };
+ return input->exceptionType.isAssignableFrom(input.getClass());
}
/**
@@ -64,9 +59,7 @@ public class ExceptionRecognizerForType extends ExceptionRecognizerAbstract {
* Intended to prevent too eager matching of an overly general exception type.
*/
protected final static Predicate<Throwable> excluding(final String... messages) {
- return new Predicate<Throwable>() {
- @Override
- public boolean apply(Throwable input) {
+ return input->{
final List<Throwable> causalChain = Throwables.getCausalChain(input);
for (String message : messages) {
for (Throwable throwable : causalChain) {
@@ -87,8 +80,8 @@ public class ExceptionRecognizerForType extends ExceptionRecognizerAbstract {
}
}
return true;
- }
- };
+ };
+
}
/**
@@ -100,9 +93,7 @@ public class ExceptionRecognizerForType extends ExceptionRecognizerAbstract {
* Intended to prevent more precise matching of a specific general exception type.
*/
protected final static Predicate<Throwable> including(final String... messages) {
- return new Predicate<Throwable>() {
- @Override
- public boolean apply(Throwable input) {
+ return input->{
final List<Throwable> causalChain = Throwables.getCausalChain(input);
for (String message : messages) {
for (Throwable throwable : causalChain) {
@@ -113,15 +104,20 @@ public class ExceptionRecognizerForType extends ExceptionRecognizerAbstract {
}
}
return false;
- }
- };
+ };
}
- public ExceptionRecognizerForType(Category category, final Class<? extends Exception> exceptionType, final Function<String,String> messageParser) {
+ public ExceptionRecognizerForType(
+ Category category,
+ final Class<? extends Exception> exceptionType,
+ final Function<String,String> messageParser) {
this(category, ofType(exceptionType), messageParser);
}
- public ExceptionRecognizerForType(Category category, final Predicate<Throwable> predicate, final Function<String,String> messageParser) {
+ public ExceptionRecognizerForType(
+ Category category,
+ final Predicate<Throwable> predicate,
+ final Function<String,String> messageParser) {
super(category, predicate, messageParser);
}
@@ -129,16 +125,20 @@ public class ExceptionRecognizerForType extends ExceptionRecognizerAbstract {
this(category, exceptionType, null);
}
- public ExceptionRecognizerForType(final Class<? extends Exception> exceptionType, final Function<String,String> messageParser) {
+ public ExceptionRecognizerForType(
+ final Class<? extends Exception> exceptionType,
+ final Function<String,String> messageParser) {
this(Category.OTHER, exceptionType, messageParser);
}
- public ExceptionRecognizerForType(final Predicate<Throwable> predicate, final Function<String,String> messageParser) {
+ public ExceptionRecognizerForType(
+ final Predicate<Throwable> predicate,
+ final Function<String,String> messageParser) {
this(Category.OTHER, predicate, messageParser);
}
public ExceptionRecognizerForType(Class<? extends Exception> exceptionType) {
this(Category.OTHER, exceptionType);
}
-
+
}
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerForType2.java b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerForTypeLegacy.java
similarity index 69%
rename from core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerForType2.java
rename to core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerForTypeLegacy.java
index 99a9ab8..593d14c 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerForType2.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerForTypeLegacy.java
@@ -19,11 +19,10 @@
package org.apache.isis.applib.services.exceprecog;
import java.util.List;
-import java.util.function.Function;
-import java.util.function.Predicate;
-
import javax.jdo.JDODataStoreException;
-
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
import com.google.common.base.Throwables;
/**
@@ -35,19 +34,29 @@ import com.google.common.base.Throwables;
* <p>
* If a messaging-parsing {@link Function} is provided through the constructor,
* then the message can be altered. Otherwise the exception's {@link Throwable#getMessage() message} is returned as-is.
+ *
+ * @deprecated use {@link ExceptionRecognizerForType} instead. (Will not be removed before Version 2.1.)
+ * (Requires you to refactor Guava Predicates, Functions, ... to Java Predicates, Functions, ... in your domain code.)
+ *
*/
-public class ExceptionRecognizerForType2 extends ExceptionRecognizerAbstract {
-
- protected final static Predicate<Throwable> ofTypeExcluding(final Class<? extends Throwable> exceptionType, final String... messages) {
- return ofType(exceptionType).and(excluding(messages));
+@Deprecated // (Will not be removed before Version 2.1.)
+public class ExceptionRecognizerForTypeLegacy extends ExceptionRecognizerAbstractLegacy {
+
+ protected final static Predicate<Throwable> ofTypeExcluding(final Class<? extends Throwable> exceptionType, final String... messages) {
+ return Predicates.and(ofType(exceptionType), excluding(messages));
}
protected final static Predicate<Throwable> ofTypeIncluding(final Class<? extends Throwable> exceptionType, final String... messages) {
- return ofType(exceptionType).and(including(messages));
+ return Predicates.and(ofType(exceptionType), including(messages));
}
protected final static Predicate<Throwable> ofType(final Class<? extends Throwable> exceptionType) {
- return input->exceptionType.isAssignableFrom(input.getClass());
+ return new Predicate<Throwable>() {
+ @Override
+ public boolean apply(Throwable input) {
+ return exceptionType.isAssignableFrom(input.getClass());
+ }
+ };
}
/**
@@ -59,7 +68,9 @@ public class ExceptionRecognizerForType2 extends ExceptionRecognizerAbstract {
* Intended to prevent too eager matching of an overly general exception type.
*/
protected final static Predicate<Throwable> excluding(final String... messages) {
- return input->{
+ return new Predicate<Throwable>() {
+ @Override
+ public boolean apply(Throwable input) {
final List<Throwable> causalChain = Throwables.getCausalChain(input);
for (String message : messages) {
for (Throwable throwable : causalChain) {
@@ -80,8 +91,8 @@ public class ExceptionRecognizerForType2 extends ExceptionRecognizerAbstract {
}
}
return true;
- };
-
+ }
+ };
}
/**
@@ -93,7 +104,9 @@ public class ExceptionRecognizerForType2 extends ExceptionRecognizerAbstract {
* Intended to prevent more precise matching of a specific general exception type.
*/
protected final static Predicate<Throwable> including(final String... messages) {
- return input->{
+ return new Predicate<Throwable>() {
+ @Override
+ public boolean apply(Throwable input) {
final List<Throwable> causalChain = Throwables.getCausalChain(input);
for (String message : messages) {
for (Throwable throwable : causalChain) {
@@ -104,41 +117,32 @@ public class ExceptionRecognizerForType2 extends ExceptionRecognizerAbstract {
}
}
return false;
- };
+ }
+ };
}
- public ExceptionRecognizerForType2(
- Category category,
- final Class<? extends Exception> exceptionType,
- final Function<String,String> messageParser) {
+ public ExceptionRecognizerForTypeLegacy(Category category, final Class<? extends Exception> exceptionType, final Function<String,String> messageParser) {
this(category, ofType(exceptionType), messageParser);
}
- public ExceptionRecognizerForType2(
- Category category,
- final Predicate<Throwable> predicate,
- final Function<String,String> messageParser) {
+ public ExceptionRecognizerForTypeLegacy(Category category, final Predicate<Throwable> predicate, final Function<String,String> messageParser) {
super(category, predicate, messageParser);
}
- public ExceptionRecognizerForType2(Category category, Class<? extends Exception> exceptionType) {
+ public ExceptionRecognizerForTypeLegacy(Category category, Class<? extends Exception> exceptionType) {
this(category, exceptionType, null);
}
- public ExceptionRecognizerForType2(
- final Class<? extends Exception> exceptionType,
- final Function<String,String> messageParser) {
+ public ExceptionRecognizerForTypeLegacy(final Class<? extends Exception> exceptionType, final Function<String,String> messageParser) {
this(Category.OTHER, exceptionType, messageParser);
}
- public ExceptionRecognizerForType2(
- final Predicate<Throwable> predicate,
- final Function<String,String> messageParser) {
+ public ExceptionRecognizerForTypeLegacy(final Predicate<Throwable> predicate, final Function<String,String> messageParser) {
this(Category.OTHER, predicate, messageParser);
}
- public ExceptionRecognizerForType2(Class<? extends Exception> exceptionType) {
+ public ExceptionRecognizerForTypeLegacy(Class<? extends Exception> exceptionType) {
this(Category.OTHER, exceptionType);
}
-
+
}
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/jdo/ExceptionRecognizerForJDODataStoreException.java b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/jdo/ExceptionRecognizerForJDODataStoreException.java
index 2273bbe..b52fc16 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/jdo/ExceptionRecognizerForJDODataStoreException.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/jdo/ExceptionRecognizerForJDODataStoreException.java
@@ -18,9 +18,9 @@
*/
package org.apache.isis.applib.services.exceprecog.jdo;
-import org.apache.isis.applib.services.exceprecog.ExceptionRecognizerForType2;
+import org.apache.isis.applib.services.exceprecog.ExceptionRecognizerForType;
-public class ExceptionRecognizerForJDODataStoreException extends ExceptionRecognizerForType2 {
+public class ExceptionRecognizerForJDODataStoreException extends ExceptionRecognizerForType {
public ExceptionRecognizerForJDODataStoreException() {
super(Category.SERVER_ERROR,
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/jdo/ExceptionRecognizerForJDODataStoreExceptionIntegrityConstraintViolationForeignKeyNoActionException.java b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/jdo/ExceptionRecognizerForJDODataStoreExceptionIntegrityConstraintViolationForeignKeyNoActionException.java
index 0e495a6..5e2b6ac 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/jdo/ExceptionRecognizerForJDODataStoreExceptionIntegrityConstraintViolationForeignKeyNoActionException.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/jdo/ExceptionRecognizerForJDODataStoreExceptionIntegrityConstraintViolationForeignKeyNoActionException.java
@@ -19,10 +19,10 @@
package org.apache.isis.applib.services.exceprecog.jdo;
import javax.jdo.JDODataStoreException;
-import org.apache.isis.applib.services.exceprecog.ExceptionRecognizerForType2;
+import org.apache.isis.applib.services.exceprecog.ExceptionRecognizerForType;
public class ExceptionRecognizerForJDODataStoreExceptionIntegrityConstraintViolationForeignKeyNoActionException
-extends ExceptionRecognizerForType2 {
+extends ExceptionRecognizerForType {
public ExceptionRecognizerForJDODataStoreExceptionIntegrityConstraintViolationForeignKeyNoActionException() {
super(Category.CONSTRAINT_VIOLATION,
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/jdo/ExceptionRecognizerForJDOObjectNotFoundException.java b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/jdo/ExceptionRecognizerForJDOObjectNotFoundException.java
index ec315c3..74e934a 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/jdo/ExceptionRecognizerForJDOObjectNotFoundException.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/jdo/ExceptionRecognizerForJDOObjectNotFoundException.java
@@ -18,9 +18,9 @@
*/
package org.apache.isis.applib.services.exceprecog.jdo;
-import org.apache.isis.applib.services.exceprecog.ExceptionRecognizerForType2;
+import org.apache.isis.applib.services.exceprecog.ExceptionRecognizerForType;
-public class ExceptionRecognizerForJDOObjectNotFoundException extends ExceptionRecognizerForType2 {
+public class ExceptionRecognizerForJDOObjectNotFoundException extends ExceptionRecognizerForType {
public ExceptionRecognizerForJDOObjectNotFoundException() {
super(Category.NOT_FOUND,
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/jdo/ExceptionRecognizerForSQLIntegrityConstraintViolationUniqueOrIndexException.java b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/jdo/ExceptionRecognizerForSQLIntegrityConstraintViolationUniqueOrIndexException.java
index cf74abe..331fbae 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/jdo/ExceptionRecognizerForSQLIntegrityConstraintViolationUniqueOrIndexException.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/exceprecog/jdo/ExceptionRecognizerForSQLIntegrityConstraintViolationUniqueOrIndexException.java
@@ -18,10 +18,10 @@
*/
package org.apache.isis.applib.services.exceprecog.jdo;
-import org.apache.isis.applib.services.exceprecog.ExceptionRecognizerForType2;
+import org.apache.isis.applib.services.exceprecog.ExceptionRecognizerForType;
public class ExceptionRecognizerForSQLIntegrityConstraintViolationUniqueOrIndexException
-extends ExceptionRecognizerForType2 {
+extends ExceptionRecognizerForType {
public ExceptionRecognizerForSQLIntegrityConstraintViolationUniqueOrIndexException() {
super(Category.CONSTRAINT_VIOLATION,
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/repository/RepositoryServiceLegacy.java b/core/applib/src/main/java/org/apache/isis/applib/services/repository/RepositoryServiceLegacy.java
index c3b4e3d..9bf7118 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/repository/RepositoryServiceLegacy.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/repository/RepositoryServiceLegacy.java
@@ -27,11 +27,11 @@ import org.apache.isis.applib.query.Query;
/**
* Legacy interface to ease transition from Isis 1.x to 2.x.
*
- * @deprecated use {@link RepositoryService} instead.
+ * @deprecated use {@link RepositoryService} instead. (Will not be removed before Version 2.1.)
* (Requires you to refactor Guava Predicates to Java Predicates in your domain code.)
*
*/
-@Deprecated
+@Deprecated // (Will not be removed before Version 2.1.)
public interface RepositoryServiceLegacy {
/**
diff --git a/core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerForType2Test.java b/core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerForType2Test.java
deleted file mode 100644
index c541001..0000000
--- a/core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerForType2Test.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-
-package org.apache.isis.applib.services.exceprecog;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
-
-import java.util.function.Function;
-
-import org.junit.Test;
-
-public class ExceptionRecognizerForType2Test {
-
- private ExceptionRecognizerForType2 ersForType;
-
- static class FooException extends Exception {
- private static final long serialVersionUID = 1L;
- public FooException() {
- super("foo");
- }
-
- }
- static class BarException extends Exception {
- private static final long serialVersionUID = 1L;
- public BarException() {
- super("bar");
- }
- }
-
- private Function<String,String> prepend = new Function<String, String>() {
- @Override
- public String apply(String input) {
- return "pre: " + input;
- }
- };
-
- @Test
- public void whenRecognized() {
- ersForType = new ExceptionRecognizerForType2(FooException.class);
- assertThat(ersForType.recognize(new FooException()), is("foo"));
- }
-
- @Test
- public void whenDoesNotRecognize() {
- ersForType = new ExceptionRecognizerForType2(FooException.class);
- assertThat(ersForType.recognize(new BarException()), is(nullValue()));
- }
-
- @Test
- public void whenRecognizedWithMessageParser() {
- ersForType = new ExceptionRecognizerForType2(FooException.class, prepend);
- assertThat(ersForType.recognize(new FooException()), is("pre: foo"));
- }
-
-}
diff --git a/core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerForTypeTest.java b/core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerForTypeTest.java
index 4a45d95..9c8da58 100644
--- a/core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerForTypeTest.java
+++ b/core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerForTypeTest.java
@@ -23,13 +23,13 @@ import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
-import com.google.common.base.Function;
+import java.util.function.Function;
import org.junit.Test;
public class ExceptionRecognizerForTypeTest {
- private ExceptionRecognizerForType ersForType;
+ private ExceptionRecognizer ersForType;
static class FooException extends Exception {
private static final long serialVersionUID = 1L;
@@ -51,7 +51,7 @@ public class ExceptionRecognizerForTypeTest {
return "pre: " + input;
}
};
-
+
@Test
public void whenRecognized() {
ersForType = new ExceptionRecognizerForType(FooException.class);
@@ -69,5 +69,35 @@ public class ExceptionRecognizerForTypeTest {
ersForType = new ExceptionRecognizerForType(FooException.class, prepend);
assertThat(ersForType.recognize(new FooException()), is("pre: foo"));
}
+
+ // -- LEGACY TESTS
+ private com.google.common.base.Function<String,String> prependLegacy =
+ new com.google.common.base.Function<String, String>() {
+ @Override
+ public String apply(String input) {
+ return "pre: " + input;
+ }
+ };
+
+ @Test
+ public void legacyWhenRecognized() {
+ ersForType = new ExceptionRecognizerForTypeLegacy(FooException.class);
+ assertThat(ersForType.recognize(new FooException()), is("foo"));
+ }
+
+ @Test
+ public void legacyWhenDoesNotRecognize() {
+ ersForType = new ExceptionRecognizerForTypeLegacy(FooException.class);
+ assertThat(ersForType.recognize(new BarException()), is(nullValue()));
+ }
+
+ @Test
+ public void legacyWhenRecognizedWithMessageParser() {
+ ersForType = new ExceptionRecognizerForTypeLegacy(FooException.class, prependLegacy);
+ assertThat(ersForType.recognize(new FooException()), is("pre: foo"));
+ }
+
+
+
}
diff --git a/core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerGeneralTest.java b/core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerGeneralTest.java
index a2a0118..e9c8bcb 100644
--- a/core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerGeneralTest.java
+++ b/core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerGeneralTest.java
@@ -29,7 +29,7 @@ import org.junit.Test;
public class ExceptionRecognizerGeneralTest {
- private ExceptionRecognizerAbstract ersGeneral;
+ private ExceptionRecognizer ersGeneral;
static class FooException extends Exception {
private static final long serialVersionUID = 1L;
@@ -48,19 +48,19 @@ public class ExceptionRecognizerGeneralTest {
@Test
public void whenRecognized_guava() {
- ersGeneral = new ExceptionRecognizerAbstract(com.google.common.base.Predicates.<Throwable>alwaysTrue()){};
+ ersGeneral = new ExceptionRecognizerAbstractLegacy(com.google.common.base.Predicates.<Throwable>alwaysTrue()){};
assertThat(ersGeneral.recognize(new FooException()), is("foo"));
}
@Test
public void whenDoesNotRecognize_guava() {
- ersGeneral = new ExceptionRecognizerAbstract(com.google.common.base.Predicates.<Throwable>alwaysFalse()){};
+ ersGeneral = new ExceptionRecognizerAbstractLegacy(com.google.common.base.Predicates.<Throwable>alwaysFalse()){};
assertThat(ersGeneral.recognize(new FooException()), is(nullValue()));
}
@Test
public void whenRecognizedWithMessageParser_guava() {
- ersGeneral = new ExceptionRecognizerAbstract(com.google.common.base.Predicates.<Throwable>alwaysTrue(), prepend){};
+ ersGeneral = new ExceptionRecognizerAbstractLegacy(com.google.common.base.Predicates.<Throwable>alwaysTrue(), prepend){};
assertThat(ersGeneral.recognize(new FooException()), is("pre: foo"));
}
--
To stop receiving notification emails like this one, please contact
ahuber@apache.org.