aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl
diff options
context:
space:
mode:
authorCharles Cole <cc847m@att.com>2017-10-06 09:18:45 -0500
committerCharles Cole <cc847m@att.com>2017-10-11 16:07:04 -0500
commit777302bddf16316fb555ebc0d9f32dd2ecc0ebf4 (patch)
tree57cc8bab695c89985670760475621e4360e35c05 /controlloop/common/model-impl
parent82b577dfb36788936d1503c7fd77320536cc2d10 (diff)
Enable junits to work with the archetype template
Control loop junits now use the actual PolicyEngine instead of a simulation, allowing them to work with the archetype template Issue-ID: POLICY-101 Change-Id: I910961996aaf831f4e91b7d7173d05fdfdd77683 Signed-off-by: Charles Cole <cc847m@att.com>
Diffstat (limited to 'controlloop/common/model-impl')
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java22
-rw-r--r--controlloop/common/model-impl/events/pom.xml6
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java7
3 files changed, 33 insertions, 2 deletions
diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java
index 7187ab1e7..e41fa3653 100644
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java
@@ -81,12 +81,27 @@ public final class Serialization {
@Override
public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
- return Instant.parse(json.getAsString());
+ return Instant.parse(json.getAsString());
}
@Override
public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
- return new JsonPrimitive(src.toString());
+ return new JsonPrimitive(src.toString());
+ }
+
+ }
+
+ public static class InstantJunitAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
+
+ @Override
+ public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+ throws JsonParseException {
+ return Instant.ofEpochMilli(json.getAsLong());
+ }
+
+ @Override
+ public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
+ return new JsonPrimitive(src.toEpochMilli());
}
}
@@ -97,5 +112,8 @@ public final class Serialization {
public static final Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
.registerTypeAdapter(LCMRequest.class, new RequestAdapter())
.registerTypeAdapter(LCMResponse.class, new ResponseAdapter()).create();
+
+ public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(Instant.class, new InstantJunitAdapter()).create();
}
diff --git a/controlloop/common/model-impl/events/pom.xml b/controlloop/common/model-impl/events/pom.xml
index a07bb4786..390d082c5 100644
--- a/controlloop/common/model-impl/events/pom.xml
+++ b/controlloop/common/model-impl/events/pom.xml
@@ -33,5 +33,11 @@
<version>2.5</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
index 37b148beb..858dc82b9 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
@@ -127,5 +127,12 @@ public final class Serialization {
.registerTypeAdapter(ControlLoopNotificationType.class, new notificationTypeAdapter())
.registerTypeAdapter(ControlLoopTargetType.class, new targetTypeAdapter())
.create();
+
+ final static public Gson gsonJunit = new GsonBuilder().disableHtmlEscaping()
+ .setPrettyPrinting()
+ .registerTypeAdapter(ZonedDateTime.class, new gsonUTCAdapter())
+ .registerTypeAdapter(Instant.class, new gsonInstantAdapter())
+ .registerTypeAdapter(ControlLoopTargetType.class, new targetTypeAdapter())
+ .create();
}