From 124c0a8dc9ba68b9c778015fec38bf18bb22ff4d Mon Sep 17 00:00:00 2001 From: Jeffrey Phillips Freeman <jeffrey.freeman@syncleus.com> Date: Sat, 30 Sep 2017 22:41:43 -0400 Subject: [PATCH] fix: fixed all the bugs caught by the new units tests and updated the changelog. --- CHANGELOG.md | 9 +++++++++ src/main/java/com/syncleus/ferma/AbstractEdgeFrame.java | 8 ++++++-- .../java/com/syncleus/ferma/AbstractVertexFrame.java | 8 ++++++-- .../java/com/syncleus/ferma/DelegatingFramedGraph.java | 5 +++-- .../annotation/AbstractAnnotationFrameFactory.java | 6 ++++-- src/main/java/com/syncleus/ferma/tx/TxAction.java | 2 +- src/main/java/com/syncleus/ferma/tx/TxAction0.java | 2 +- src/main/java/com/syncleus/ferma/tx/TxAction1.java | 2 +- src/main/java/com/syncleus/ferma/tx/TxAction2.java | 2 +- 9 files changed, 32 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb1914ca..c40a58fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ ## 3.2.1 +* Removed `throws exception` from the signature of the TxActions. +* Fixed a bug where the `VertexFrame.toJson()` and `EdgeFrame.toJson()` methods wouldn't encode properties that werent + of the type `Number` or `String` +* When constructing a `DelegatingFramedGraph` if a the delegate graph argument is null the constructor now throws an + exception. +* `AbstractAnnotationFrameFactory.constructClass()` method now throws an exception if the element argument is neither an + `Edge` or a `Vertex`. +* Added several more unit tests bring test coverage up an additional 5%. + ## 3.2.0 * Added nexus staging deployment plugin. diff --git a/src/main/java/com/syncleus/ferma/AbstractEdgeFrame.java b/src/main/java/com/syncleus/ferma/AbstractEdgeFrame.java index 7106cc9c..f9f2ab59 100644 --- a/src/main/java/com/syncleus/ferma/AbstractEdgeFrame.java +++ b/src/main/java/com/syncleus/ferma/AbstractEdgeFrame.java @@ -60,8 +60,12 @@ public abstract class AbstractEdgeFrame extends AbstractElementFrame implements final Object value = getProperty(key); if (value instanceof Number) json.addProperty(key, (Number) value); - else if (value instanceof String) - json.addProperty(key, (String) value); + else if (value instanceof Boolean) + json.addProperty(key, (Boolean) value); + else if (value instanceof Character) + json.addProperty(key, (Character) value); + else + json.addProperty(key, value.toString()); } return json; } diff --git a/src/main/java/com/syncleus/ferma/AbstractVertexFrame.java b/src/main/java/com/syncleus/ferma/AbstractVertexFrame.java index f06abb2e..8da3df5b 100644 --- a/src/main/java/com/syncleus/ferma/AbstractVertexFrame.java +++ b/src/main/java/com/syncleus/ferma/AbstractVertexFrame.java @@ -245,8 +245,12 @@ public abstract class AbstractVertexFrame extends AbstractElementFrame implement final Object value = getProperty(key); if (value instanceof Number) json.addProperty(key, (Number) value); - else if (value instanceof String) - json.addProperty(key, (String) value); + else if(value instanceof Boolean) + json.addProperty(key, (Boolean) value); + else if(value instanceof Character) + json.addProperty(key, (Character) value); + else + json.addProperty(key, value.toString()); } return json; } diff --git a/src/main/java/com/syncleus/ferma/DelegatingFramedGraph.java b/src/main/java/com/syncleus/ferma/DelegatingFramedGraph.java index 04258735..9fee13f7 100644 --- a/src/main/java/com/syncleus/ferma/DelegatingFramedGraph.java +++ b/src/main/java/com/syncleus/ferma/DelegatingFramedGraph.java @@ -63,13 +63,14 @@ public class DelegatingFramedGraph<G extends Graph> implements WrappedFramedGrap * The type defaultResolver that will decide the final frame type. */ public DelegatingFramedGraph(final G delegate, final FrameFactory builder, final TypeResolver defaultResolver) { - this.delegate = delegate; - if( builder == null ) throw new IllegalArgumentException("builder can not be null"); else if( defaultResolver == null ) throw new IllegalArgumentException("defaultResolver can not be null"); + else if( delegate == null ) + throw new IllegalArgumentException("delegate can not be null"); + this.delegate = delegate; this.defaultResolver = defaultResolver; this.untypedResolver = new UntypedTypeResolver(); this.builder = builder; diff --git a/src/main/java/com/syncleus/ferma/framefactories/annotation/AbstractAnnotationFrameFactory.java b/src/main/java/com/syncleus/ferma/framefactories/annotation/AbstractAnnotationFrameFactory.java index 38f0985b..61071199 100644 --- a/src/main/java/com/syncleus/ferma/framefactories/annotation/AbstractAnnotationFrameFactory.java +++ b/src/main/java/com/syncleus/ferma/framefactories/annotation/AbstractAnnotationFrameFactory.java @@ -84,9 +84,11 @@ public class AbstractAnnotationFrameFactory implements FrameFactory { else throw new IllegalStateException("class is neither an Edge or a vertex!"); else { - if (element instanceof Vertex && !VertexFrame.class.isAssignableFrom(clazz)) + if( !(element instanceof Vertex || element instanceof Edge) ) + throw new IllegalStateException("element is neither an edge nor a vertex"); + else if (element instanceof Vertex && !VertexFrame.class.isAssignableFrom(clazz)) throw new IllegalStateException(clazz.getName() + " Class is not a type of VertexFrame"); - if (element instanceof Edge && !EdgeFrame.class.isAssignableFrom(clazz)) + else if (element instanceof Edge && !EdgeFrame.class.isAssignableFrom(clazz)) throw new IllegalStateException(clazz.getName() + " Class is not a type of EdgeFrame"); classBuilder = new ByteBuddy().subclass(clazz); } diff --git a/src/main/java/com/syncleus/ferma/tx/TxAction.java b/src/main/java/com/syncleus/ferma/tx/TxAction.java index ab73b834..9784ee0f 100644 --- a/src/main/java/com/syncleus/ferma/tx/TxAction.java +++ b/src/main/java/com/syncleus/ferma/tx/TxAction.java @@ -18,6 +18,6 @@ package com.syncleus.ferma.tx; @FunctionalInterface public interface TxAction<T> { - T handle(Tx tx) throws Exception; + T handle(Tx tx); } diff --git a/src/main/java/com/syncleus/ferma/tx/TxAction0.java b/src/main/java/com/syncleus/ferma/tx/TxAction0.java index 09bb8650..4f74760f 100644 --- a/src/main/java/com/syncleus/ferma/tx/TxAction0.java +++ b/src/main/java/com/syncleus/ferma/tx/TxAction0.java @@ -18,6 +18,6 @@ package com.syncleus.ferma.tx; @FunctionalInterface public interface TxAction0 { - void handle() throws Exception; + void handle(); } diff --git a/src/main/java/com/syncleus/ferma/tx/TxAction1.java b/src/main/java/com/syncleus/ferma/tx/TxAction1.java index b38ff342..ed1527ac 100644 --- a/src/main/java/com/syncleus/ferma/tx/TxAction1.java +++ b/src/main/java/com/syncleus/ferma/tx/TxAction1.java @@ -18,6 +18,6 @@ package com.syncleus.ferma.tx; @FunctionalInterface public interface TxAction1<T> { - T handle() throws Exception; + T handle(); } diff --git a/src/main/java/com/syncleus/ferma/tx/TxAction2.java b/src/main/java/com/syncleus/ferma/tx/TxAction2.java index 723d18f3..692964b8 100644 --- a/src/main/java/com/syncleus/ferma/tx/TxAction2.java +++ b/src/main/java/com/syncleus/ferma/tx/TxAction2.java @@ -18,6 +18,6 @@ package com.syncleus.ferma.tx; @FunctionalInterface public interface TxAction2 { - void handle(Tx tx) throws Exception; + void handle(Tx tx); } -- GitLab